Rev 126: Use bzrlib's topo sorter rather than reinventing the wheel. in file:///home/jelmer/bzr-rebase/trunk/
Jelmer Vernooij
jelmer at samba.org
Fri Feb 13 03:44:08 GMT 2009
At file:///home/jelmer/bzr-rebase/trunk/
------------------------------------------------------------
revno: 126
revision-id: jelmer at samba.org-20090213034408-m7yetq1i3hbr1hmm
parent: jelmer at samba.org-20090213032837-biqhpc7ghfo96hn6
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Fri 2009-02-13 04:44:08 +0100
message:
Use bzrlib's topo sorter rather than reinventing the wheel.
modified:
rebase.py rebase.py-20070626221123-ellanmf93nw8z9r1-1
=== modified file 'rebase.py'
--- a/rebase.py 2009-02-13 03:28:37 +0000
+++ b/rebase.py 2009-02-13 03:44:08 +0000
@@ -294,35 +294,23 @@
dependencies = {}
# Figure out the dependencies
+ graph = {}
for revid in todo:
- for p in replace_map[revid][1]:
- if repository.has_revision(p):
- continue
- if not dependencies.has_key(p):
- dependencies[p] = []
- dependencies[p].append(revid)
+ graph[revid] = replace_map[revid][1]
- import pdb; pdb.set_trace()
total = len(todo)
i = 0
pb = ui.ui_factory.nested_progress_bar()
try:
- while len(todo) > 0:
+ for revid in topo_sort(graph):
pb.update('rebase revisions', i, total)
i += 1
- revid = todo.pop()
(newrevid, newparents) = replace_map[revid]
assert isinstance(newparents, tuple), "Expected tuple for %r" % newparents
- if repository.has_revisions(newparents) != set(newparents):
- # Not all parents present yet, avoid for now
- continue
if repository.has_revision(newrevid):
# Was already converted, no need to worry about it again
continue
replay_fn(repository, revid, newrevid, newparents)
- if dependencies.has_key(newrevid):
- todo.extend(dependencies[newrevid])
- del dependencies[newrevid]
finally:
pb.finished()
More information about the bazaar-commits
mailing list