Rev 23: Merge help text, tests and bug fixes from James. in file:///data/jelmer/bzr-rebase/trunk/

Jelmer Vernooij jelmer at samba.org
Fri Jul 13 11:40:25 BST 2007


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

------------------------------------------------------------
revno: 23
revision-id: jelmer at samba.org-20070712215843-8c8hmugip11uife3
parent: jelmer at samba.org-20070712215451-f8a3ub1badwvj3a1
parent: jw+debian at jameswestby.net-20070712213119-vqj3whqsjrcgia8m
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Fri 2007-07-13 00:58:43 +0300
message:
  Merge help text, tests and bug fixes from James.
modified:
  __init__.py                    __init__.py-20070626215909-fi0s39bkwxn4gcto-1
  test_blackbox.py               test_blackbox.py-20070709202607-dyvt95dfu09tuv6a-1
    ------------------------------------------------------------
    revno: 21.1.5
    revision-id: jw+debian at jameswestby.net-20070712213119-vqj3whqsjrcgia8m
    parent: jw+debian at jameswestby.net-20070712174627-4fqik1iaxowpvbt9
    committer: James Westby <jw+debian at jameswestby.net>
    branch nick: rebase
    timestamp: Thu 2007-07-12 22:31:19 +0100
    message:
      Add some help text to the rebase command.
      
      Don't document the revision parameter as it does not do anything yet.
    ------------------------------------------------------------
    revno: 21.1.4
    revision-id: jw+debian at jameswestby.net-20070712174627-4fqik1iaxowpvbt9
    parent: jw+debian at jameswestby.net-20070712173404-54ktoezg7it4w4nd
    committer: James Westby <jw+debian at jameswestby.net>
    branch nick: rebase
    timestamp: Thu 2007-07-12 18:46:27 +0100
    message:
      Import rebase_todo as it is needed for --verbose.
    ------------------------------------------------------------
    revno: 21.1.3
    revision-id: jw+debian at jameswestby.net-20070712173404-54ktoezg7it4w4nd
    parent: jw+debian at jameswestby.net-20070712172838-8qpp71w4vpgdfgc4
    committer: James Westby <jw+debian at jameswestby.net>
    branch nick: rebase
    timestamp: Thu 2007-07-12 18:34:04 +0100
    message:
      Provide a hint in the conflicts present message to rebase-continue.
    ------------------------------------------------------------
    revno: 21.1.2
    revision-id: jw+debian at jameswestby.net-20070712172838-8qpp71w4vpgdfgc4
    parent: jw+debian at jameswestby.net-20070712171905-1xq90og33116wrjd
    committer: James Westby <jw+debian at jameswestby.net>
    branch nick: rebase
    timestamp: Thu 2007-07-12 18:28:38 +0100
    message:
      Lookup the onto revision in the upstream branch.
      
      The --onto argument is passed to RevisionSpec.from_string. This returns
      a revision spec. This needs to be looked up the the upstream branch and
      the revision id found.
      
      Add a blackbox test for --onto.
    ------------------------------------------------------------
    revno: 21.1.1
    revision-id: jw+debian at jameswestby.net-20070712171905-1xq90og33116wrjd
    parent: jelmer at samba.org-20070710132401-2uwonjhe2lq38rbj
    committer: James Westby <jw+debian at jameswestby.net>
    branch nick: rebase
    timestamp: Thu 2007-07-12 18:19:05 +0100
    message:
      --onto needs to take a parameter. It was a boolean flag before.
=== modified file '__init__.py'
--- a/__init__.py	2007-07-09 20:44:02 +0000
+++ b/__init__.py	2007-07-12 21:31:19 +0000
@@ -22,10 +22,40 @@
 class cmd_rebase(Command):
     """Re-base a branch.
 
+    Rebasing is the process of taking a branch and modifying the history so
+    that it appears to start from a different point. This can be useful
+    to clean up the history before submitting your changes. The tree at the
+    end of the process will be the same as if you had merged the other branch,
+    but the history will be different.
+
+    The command takes the location of another branch on to which the branch in
+    the current working directory will be rebased. If a branch is not specified
+    then the parent branch is used, and this is usually the desired result.
+
+    The first step identifies the revisions that are in the current branch that
+    are not in the parent branch. The current branch is then set to be at the
+    same revision as the target branch, and each revision is replayed on top
+    of the branch. At the end of the process it will appear as though your
+    current branch was branched off the current last revision of the target.
+
+    Each revision that is replayed may cause conflicts in the tree. If this
+    happens the command will stop and allow you to fix them up. Resolve the
+    commits as you would for a merge, and then run 'bzr resolve' to marked
+    them as resolved. Once you have resolved all the conflicts you should
+    run 'bzr rebase-continue' to continue the rebase operation.
+
+    If conflicts are encountered and you decide that you do not wish to continue
+    you can run 'bzr rebase-abort'.
+
+    The '--onto' option allows you to specify a different revision in the
+    target branch to start at when replaying the revisions. This means that
+    you can change the point at which the current branch will appear to be
+    branched from when the operation completes.
     """
     takes_args = ['upstream_location?']
     takes_options = ['revision', 'merge-type', 'verbose',
-                     Option('onto', help='Different revision to replay onto')]
+                     Option('onto', help='Different revision to replay onto',
+                            type=str)]
     
     @display_command
     def run(self, upstream_location=None, onto=None, revision=None, 
@@ -35,7 +65,8 @@
         from bzrlib.workingtree import WorkingTree
         from rebase import (generate_simple_plan, rebase, rebase_plan_exists, 
                             read_rebase_plan, remove_rebase_plan, 
-                            workingtree_replay, write_rebase_plan)
+                            workingtree_replay, write_rebase_plan,
+                            rebase_todo)
         wt = WorkingTree.open('.')
         wt.lock_write()
         if upstream_location is None:
@@ -54,7 +85,8 @@
             if onto is None:
                 onto = upstream.last_revision()
             else:
-                onto = RevisionSpec.from_string(onto)
+                rev_spec = RevisionSpec.from_string(onto)
+                onto = rev_spec.in_history(upstream).rev_id
 
             wt.branch.repository.fetch(upstream_repository, onto)
 
@@ -138,7 +170,9 @@
         try:
             # Abort if there are any conflicts
             if len(wt.conflicts()) != 0:
-                raise BzrCommandError("There are still conflicts present")
+                raise BzrCommandError("There are still conflicts present. "
+                                      "Resolve the conflicts and then run "
+                                      "'bzr resolve' and try again.")
             # Read plan file
             try:
                 replace_map = read_rebase_plan(wt)[1]

=== modified file 'test_blackbox.py'
--- a/test_blackbox.py	2007-07-10 13:24:01 +0000
+++ b/test_blackbox.py	2007-07-12 17:46:27 +0000
@@ -93,3 +93,30 @@
     def test_todo_nothing(self):
         self.run_bzr_error('bzr: ERROR: No rebase in progress', 
                            'rebase-todo')
+
+    def test_onto(self):
+        self.make_file('hello', '42')
+        self.run_bzr('add')
+        self.run_bzr('commit -m that')
+        self.make_file('other', '43')
+        self.run_bzr('add')
+        self.run_bzr('commit -m that_other')
+        os.chdir('../feature')
+        self.make_file('hoi', "my data")
+        self.run_bzr('add')
+        self.run_bzr('commit -m this')
+        self.check_output('', 'rebase --onto -2 ../main')
+        self.check_output('3\n', 'revno')
+
+    def test_verbose(self):
+        self.make_file('hello', '42')
+        self.run_bzr('commit -m that')
+        os.chdir('../feature')
+        self.make_file('hoi', "my data")
+        self.run_bzr('add')
+        self.run_bzr('commit -m this')
+        out, err = self.run_bzr('rebase -v ../main')
+        self.assertContainsRe(err, ' -> ')
+        self.assertEqual('', out)
+        self.check_output('3\n', 'revno')
+




More information about the bazaar-commits mailing list