Rev 10: Add more agressive version of revert. in file:///data/jelmer/bzr-rebase/trunk/
Jelmer Vernooij
jelmer at samba.org
Thu Jul 12 09:22:38 BST 2007
At file:///data/jelmer/bzr-rebase/trunk/
------------------------------------------------------------
revno: 10
revision-id: jelmer at samba.org-20070704220327-q2dxrr0w0vbq03lh
parent: jelmer at samba.org-20070704211144-x24jnvqimeakxpq0
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: bzr-rebase
timestamp: Thu 2007-07-05 00:03:27 +0200
message:
Add more agressive version of revert.
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 21:11:44 +0000
+++ b/__init__.py 2007-07-04 22:03:27 +0000
@@ -91,7 +91,7 @@
@display_command
def run(self):
- from rebase import read_rebase_plan, remove_rebase_plan
+ from rebase import read_rebase_plan, remove_rebase_plan, complete_revert
from bzrlib.workingtree import WorkingTree
wt = WorkingTree.open('.')
wt.lock_write()
@@ -101,9 +101,7 @@
last_rev_info = read_rebase_plan(wt)[0]
except NoSuchFile:
raise BzrCommandError("No rebase to abort")
- wt.branch.set_last_revision_info(last_rev_info[0], last_rev_info[1])
- wt.set_last_revision(last_rev_info[1])
- wt.revert([], backups=False)
+ complete_revert(wt, [last_rev_info[1]])
remove_rebase_plan(wt)
finally:
wt.unlock()
@@ -167,6 +165,7 @@
finally:
wt.unlock()
+
register_command(cmd_rebase)
register_command(cmd_rebase_abort)
register_command(cmd_rebase_continue)
=== modified file 'rebase.py'
--- a/rebase.py 2007-07-04 21:11:44 +0000
+++ b/rebase.py 2007-07-04 22:03:27 +0000
@@ -17,6 +17,7 @@
from bzrlib.config import Config
from bzrlib.errors import UnknownFormatError, NoSuchFile, BzrError
from bzrlib.generate_ids import gen_revision_id
+from bzrlib import osutils
from bzrlib.revision import NULL_REVISION
from bzrlib.trace import mutter
import bzrlib.ui as ui
@@ -363,9 +364,7 @@
# in the working tree
if wt.changes_from(wt.basis_tree()).has_changed():
raise BzrError("Working tree has uncommitted changes.")
- wt.branch.generate_revision_history(newparents[0])
- wt.set_parent_ids(newparents)
- wt.revert([], backups=False)
+ complete_revert(wt, newparents)
assert not wt.changes_from(wt.basis_tree()).has_changed()
oldtree = repository.revision_tree(oldrevid)
@@ -381,6 +380,7 @@
commit_rebase(wt, oldrev, newrevid)
+
def workingtree_replay(wt, map_ids=False):
"""Returns a function that can replay revisions in wt.
@@ -398,6 +398,7 @@
revid = NULL_REVISION
wt._control_files.put_utf8(REBASE_CURRENT_REVID_FILENAME, revid)
+
def read_active_rebase_revid(wt):
try:
text = wt._control_files.get(REBASE_CURRENT_REVID_FILENAME).read().rstrip("\n")
@@ -406,3 +407,19 @@
return text
except NoSuchFile:
return None
+
+
+def complete_revert(wt, newparents):
+ """Simple helper that reverts to specified new
+ parents and makes sure none of the extra files
+ are left around.
+ """
+ newtree = wt.branch.repository.revision_tree(newparents[0])
+ delta = wt.changes_from(newtree)
+ wt.branch.generate_revision_history(newparents[0])
+ wt.set_parent_ids(newparents)
+ for (f, _, _) in delta.added:
+ abs_path = wt.abspath(f)
+ if osutils.lexists(abs_path):
+ osutils.delete_any(abs_path)
+ wt.revert([], old_tree=newtree, backups=False)
More information about the bazaar-commits
mailing list