Merge lp:~jelmer/bzr-stats/no-get-ancestry into lp:bzr-stats

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Martin Packman
Approved revision: 54
Merged at revision: 51
Proposed branch: lp:~jelmer/bzr-stats/no-get-ancestry
Merge into: lp:bzr-stats
Diff against target: 48 lines (+10/-7)
1 file modified
cmds.py (+10/-7)
To merge this branch: bzr merge lp:~jelmer/bzr-stats/no-get-ancestry
Reviewer Review Type Date Requested Status
Martin Packman (community) Approve
bzr-stats developers Pending
Review via email: mp+121017@code.launchpad.net

Description of the change

Avoid the use of Repository.get_ancestry().

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Looks good, and you forestalled my question about tests in irc...

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cmds.py'
2--- cmds.py 2012-03-08 17:48:51 +0000
3+++ cmds.py 2012-08-23 15:03:22 +0000
4@@ -28,6 +28,7 @@
5 ui,
6 workingtree,
7 )
8+from bzrlib.revision import NULL_REVISION
9 from bzrlib.plugins.stats.classify import classify_delta
10
11 from itertools import izip
12@@ -168,7 +169,10 @@
13 a_repo.lock_read()
14 try:
15 trace.note('getting ancestry')
16- ancestry = a_repo.get_ancestry(revision)[1:]
17+ graph = a_repo.get_graph()
18+ ancestry = [
19+ r for (r, ps) in graph.iter_ancestry([revision])
20+ if ps is not None and r != NULL_REVISION]
21 revs, canonical_committer = get_revisions_and_committers(a_repo, ancestry)
22 finally:
23 a_repo.unlock()
24@@ -185,11 +189,9 @@
25 pb = ui.ui_factory.nested_progress_bar()
26 a_repo.lock_read()
27 try:
28- trace.note('getting ancestry 1')
29- start_ancestry = set(a_repo.get_ancestry(start_rev))
30- trace.note('getting ancestry 2')
31- ancestry = a_repo.get_ancestry(end_rev)[1:]
32- ancestry = [rev for rev in ancestry if rev not in start_ancestry]
33+ graph = a_repo.get_graph()
34+ trace.note('getting ancestry diff')
35+ ancestry = graph.find_difference(start_rev, end_rev)[1]
36 revs, canonical_committer = get_revisions_and_committers(a_repo, ancestry)
37 finally:
38 a_repo.unlock()
39@@ -368,7 +370,8 @@
40 }
41 repository.lock_read()
42 try:
43- ancestry = filter(lambda x: x is not None, repository.get_ancestry(revid))
44+ graph = repository.get_graph()
45+ ancestry = [r for (r, ps) in graph.iter_ancestry([revid]) if ps is not None]
46 revs = repository.get_revisions(ancestry)
47 pb = ui.ui_factory.nested_progress_bar()
48 try:

Subscribers

People subscribed via source and target branches

to all changes: