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

Proposed by Jelmer Vernooij on 2012-08-23
Status: Merged
Approved by: Martin Packman on 2012-08-23
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 on 2012-08-23
bzr-stats developers 2012-08-23 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.
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
=== modified file 'cmds.py'
--- cmds.py 2012-03-08 17:48:51 +0000
+++ cmds.py 2012-08-23 15:03:22 +0000
@@ -28,6 +28,7 @@
28 ui,28 ui,
29 workingtree,29 workingtree,
30 )30 )
31from bzrlib.revision import NULL_REVISION
31from bzrlib.plugins.stats.classify import classify_delta32from bzrlib.plugins.stats.classify import classify_delta
3233
33from itertools import izip34from itertools import izip
@@ -168,7 +169,10 @@
168 a_repo.lock_read()169 a_repo.lock_read()
169 try:170 try:
170 trace.note('getting ancestry')171 trace.note('getting ancestry')
171 ancestry = a_repo.get_ancestry(revision)[1:]172 graph = a_repo.get_graph()
173 ancestry = [
174 r for (r, ps) in graph.iter_ancestry([revision])
175 if ps is not None and r != NULL_REVISION]
172 revs, canonical_committer = get_revisions_and_committers(a_repo, ancestry)176 revs, canonical_committer = get_revisions_and_committers(a_repo, ancestry)
173 finally:177 finally:
174 a_repo.unlock()178 a_repo.unlock()
@@ -185,11 +189,9 @@
185 pb = ui.ui_factory.nested_progress_bar()189 pb = ui.ui_factory.nested_progress_bar()
186 a_repo.lock_read()190 a_repo.lock_read()
187 try:191 try:
188 trace.note('getting ancestry 1')192 graph = a_repo.get_graph()
189 start_ancestry = set(a_repo.get_ancestry(start_rev))193 trace.note('getting ancestry diff')
190 trace.note('getting ancestry 2')194 ancestry = graph.find_difference(start_rev, end_rev)[1]
191 ancestry = a_repo.get_ancestry(end_rev)[1:]
192 ancestry = [rev for rev in ancestry if rev not in start_ancestry]
193 revs, canonical_committer = get_revisions_and_committers(a_repo, ancestry)195 revs, canonical_committer = get_revisions_and_committers(a_repo, ancestry)
194 finally:196 finally:
195 a_repo.unlock()197 a_repo.unlock()
@@ -368,7 +370,8 @@
368 }370 }
369 repository.lock_read()371 repository.lock_read()
370 try:372 try:
371 ancestry = filter(lambda x: x is not None, repository.get_ancestry(revid))373 graph = repository.get_graph()
374 ancestry = [r for (r, ps) in graph.iter_ancestry([revid]) if ps is not None]
372 revs = repository.get_revisions(ancestry)375 revs = repository.get_revisions(ancestry)
373 pb = ui.ui_factory.nested_progress_bar()376 pb = ui.ui_factory.nested_progress_bar()
374 try:377 try:

Subscribers

People subscribed via source and target branches

to all changes: