Rev 13: Add progress bar, some optimizations. Make merge type configurable. in file:///data/jelmer/bzr-rebase/trunk/
Jelmer Vernooij
jelmer at samba.org
Thu Jul 12 09:22:40 BST 2007
At file:///data/jelmer/bzr-rebase/trunk/
------------------------------------------------------------
revno: 13
revision-id: jelmer at samba.org-20070705100556-yrerx4w8gbsqtp93
parent: jelmer at samba.org-20070704222709-g4w9omwnp8frqeas
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: bzr-rebase
timestamp: Thu 2007-07-05 12:05:56 +0200
message:
Add progress bar, some optimizations. Make merge type configurable.
modified:
__init__.py __init__.py-20070626215909-fi0s39bkwxn4gcto-1
rebase.py rebase.py-20070626221123-ellanmf93nw8z9r1-1
=== modified file '__init__.py'
--- a/__init__.py 2007-07-04 22:27:09 +0000
+++ b/__init__.py 2007-07-05 10:05:56 +0000
@@ -23,10 +23,11 @@
"""
takes_args = ['upstream_location?']
- takes_options = ['revision', Option('onto', help='Different revision to replay onto')]
+ takes_options = ['revision', 'merge-type',
+ Option('onto', help='Different revision to replay onto')]
@display_command
- def run(self, upstream_location=None, onto=None, revision=None):
+ def run(self, upstream_location=None, onto=None, revision=None, merge_type=None):
from bzrlib.branch import Branch
from bzrlib.revisionspec import RevisionSpec
from bzrlib.workingtree import WorkingTree
@@ -81,7 +82,7 @@
# Start executing plan
try:
- rebase(wt.branch.repository, replace_map, workingtree_replay(wt))
+ rebase(wt.branch.repository, replace_map, workingtree_replay(wt, merge_type=merge_type))
except ConflictsInTree:
raise BzrCommandError("A conflict occurred replaying a commit. Resolve the conflict and run 'bzr rebase-continue' or run 'bzr rebase-abort'.")
# Remove plan file
@@ -117,9 +118,10 @@
"""Continue an interrupted rebase after resolving conflicts
"""
+ takes_options = ['merge-type']
@display_command
- def run(self):
+ def run(self, merge_type=None):
from rebase import read_rebase_plan, rebase_plan_exists, workingtree_replay, rebase, remove_rebase_plan, commit_rebase, read_active_rebase_revid
from bzrlib.workingtree import WorkingTree
wt = WorkingTree.open('.')
@@ -139,7 +141,7 @@
commit_rebase(wt, oldrev, replace_map[oldrevid][0])
try:
# Start executing plan from current Branch.last_revision()
- rebase(wt.branch.repository, replace_map, workingtree_replay(wt))
+ rebase(wt.branch.repository, replace_map, workingtree_replay(wt, merge_type=merge_type))
except ConflictsInTree:
raise BzrCommandError("A conflict occurred replaying a commit. Resolve the conflict and run 'bzr rebase-continue' or run 'bzr rebase-abort'.")
# Remove plan file
=== modified file 'rebase.py'
--- a/rebase.py 2007-07-04 22:09:38 +0000
+++ b/rebase.py 2007-07-05 10:05:56 +0000
@@ -159,32 +159,44 @@
replace_map[r] = (renames[r],
repository.revision_parents(renames[r]))
todo.append(r)
-
- def find_revision_children(revid):
- for x in graph:
- if revid in graph[x]:
- yield x
-
- while len(todo) > 0:
- r = todo.pop()
- # Find children of r in graph
- children = list(find_revision_children(r))
- # Add entry for them in replace_map
- for c in children:
- if c in renames:
- continue
- rev = repository.get_revision(c)
- if replace_map.has_key(c):
- parents = replace_map[c][1]
- else:
- parents = rev.parent_ids
- # replace r in parents with replace_map[r][0]
- if not replace_map[r][0] in parents:
- parents[parents.index(r)] = replace_map[r][0]
- replace_map[c] = (generate_revid(rev), parents)
- assert replace_map[c][0] != rev.revision_id
- # Add them to todo[]
- todo.extend(children)
+
+ children = {}
+ for r in graph:
+ if not children.has_key(r):
+ children[r] = []
+ for p in graph[r]:
+ if not children.has_key(p):
+ children[p] = []
+ children[p].append(r)
+
+ total = len(todo)
+ processed = set()
+ i = 0
+ pb = ui.ui_factory.nested_progress_bar()
+ try:
+ while len(todo) > 0:
+ r = todo.pop()
+ i += 1
+ pb.update('determining dependencies', i, total)
+ # Add entry for them in replace_map
+ for c in children[r]:
+ if c in renames:
+ continue
+ rev = repository.get_revision(c)
+ if replace_map.has_key(c):
+ parents = replace_map[c][1]
+ else:
+ parents = rev.parent_ids
+ # replace r in parents with replace_map[r][0]
+ if not replace_map[r][0] in parents:
+ parents[parents.index(r)] = replace_map[r][0]
+ replace_map[c] = (generate_revid(rev), parents)
+ assert replace_map[c][0] != rev.revision_id
+ processed.add(r)
+ # Add them to todo[]
+ todo.extend(filter(lambda x: x in processed, children[r]))
+ finally:
+ pb.finished()
return replace_map
@@ -384,7 +396,7 @@
commit_rebase(wt, oldrev, newrevid)
-def workingtree_replay(wt, map_ids=False):
+def workingtree_replay(wt, map_ids=False, merge_type=None):
"""Returns a function that can replay revisions in wt.
:param wt: Working tree in which to do the replays.
@@ -392,7 +404,7 @@
"""
def replay(repository, oldrevid, newrevid, newparents):
assert wt.branch.repository == repository
- return replay_delta_workingtree(wt, oldrevid, newrevid, newparents)
+ return replay_delta_workingtree(wt, oldrevid, newrevid, newparents, merge_type=merge_type)
return replay
More information about the bazaar-commits
mailing list