Rev 8: Couple more minor fixes. in file:///data/jelmer/bzr-rebase/trunk/

Jelmer Vernooij jelmer at samba.org
Thu Jul 12 09:22:37 BST 2007


At file:///data/jelmer/bzr-rebase/trunk/

------------------------------------------------------------
revno: 8
revision-id: jelmer at samba.org-20070704203154-3px851kiifoetfry
parent: jelmer at samba.org-20070704195529-cpcs228123xsidqy
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: bzr-rebase
timestamp: Wed 2007-07-04 22:31:54 +0200
message:
  Couple more minor fixes.
modified:
  README                         readme-20070626220000-c62864tuxlldx6uc-1
  __init__.py                    __init__.py-20070626215909-fi0s39bkwxn4gcto-1
  rebase.py                      rebase.py-20070626221123-ellanmf93nw8z9r1-1
=== modified file 'README'
--- a/README	2007-07-04 17:00:26 +0000
+++ b/README	2007-07-04 20:31:54 +0000
@@ -1,7 +1,16 @@
 This plugin provides a 'bzr rebase' command, in the same fashion of the 
 famous git-rebase.
 
-
+==========
+How to use
+==========
+
+Simply run ``bzr rebase``, optionally specifying an upstream branch. If no branch is specified, 
+it will use the current parent branch (which is usually what you want).
+
+In the future, I hope it can also support rebasing on top of an unrelated branch.
+
+============
 How it works
 ============
 The plugin will start off by writing a plan for the rebase, which it 

=== modified file '__init__.py'
--- a/__init__.py	2007-07-04 19:55:29 +0000
+++ b/__init__.py	2007-07-04 20:31:54 +0000
@@ -15,7 +15,7 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 from bzrlib.commands import Command, Option, display_command, register_command
-from bzrlib.errors import BzrCommandError, UnrelatedBranches
+from bzrlib.errors import BzrCommandError, UnrelatedBranches, ConflictsInTree
 
 class cmd_rebase(Command):
     """Re-base a branch.
@@ -31,7 +31,7 @@
         from bzrlib.workingtree import WorkingTree
         from rebase import (generate_simple_plan, rebase, 
                             rebase_plan_exists, write_rebase_plan, 
-                            read_rebase_plan, workingtree_replay, MergeConflicted, remove_rebase_plan)
+                            read_rebase_plan, workingtree_replay, remove_rebase_plan)
         wt = WorkingTree.open('.')
         wt.lock_write()
         if upstream_location is None:
@@ -76,8 +76,8 @@
             # Start executing plan
             try:
                 rebase(wt.branch.repository, replace_map, workingtree_replay(wt))
-            except MergeConflicted:
-                raise BzrCommandError("A conflict occurred applying a patch. Resolve the conflict and run 'bzr rebase-continue' or run 'bzr rebase-abort'.")
+            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
             remove_rebase_plan(wt)
         finally:
@@ -99,6 +99,7 @@
             last_rev_info = read_rebase_plan(wt)[0]
             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)
             remove_rebase_plan(wt)
         finally:
             wt.unlock()
@@ -111,7 +112,7 @@
     
     @display_command
     def run(self):
-        from rebase import read_rebase_plan, rebase_plan_exists, workingtree_replay, MergeConflicted, rebase, remove_rebase_plan
+        from rebase import read_rebase_plan, rebase_plan_exists, workingtree_replay, rebase, remove_rebase_plan
         from bzrlib.workingtree import WorkingTree
         wt = WorkingTree.open('.')
         wt.lock_write()
@@ -125,8 +126,8 @@
             try:
                 # Start executing plan from current Branch.last_revision()
                 rebase(wt.branch.repository, replace_map, workingtree_replay(wt))
-            except MergeConflicted:
-                raise BzrCommandError("A conflict occurred applying a patch. Resolve the conflict and run 'bzr rebase-continue' or run 'bzr rebase-abort'.")
+            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  
             remove_rebase_plan(wt)
         finally:

=== modified file 'rebase.py'
--- a/rebase.py	2007-07-04 19:55:29 +0000
+++ b/rebase.py	2007-07-04 20:31:54 +0000
@@ -340,6 +340,8 @@
         raise BzrError("Working tree has uncommitted changes.")
     wt.branch.generate_revision_history(newparents[0])
     wt.set_parent_ids(newparents)
+    wt.revert([], backups=False)
+    assert not wt.changes_from(wt.basis_tree()).has_changed()
 
     oldtree = repository.revision_tree(oldrevid)
     basetree = repository.revision_tree(oldrev.parent_ids[0])
@@ -357,6 +359,7 @@
     wt.commit(message=oldrev.message, timestamp=oldrev.timestamp, timezone=oldrev.timezone,
               revprops=revprops, rev_id=newrevid)
 
+
 def workingtree_replay(wt, map_ids=False):
     """Returns a function that can replay revisions in wt.
 




More information about the bazaar-commits mailing list