Rev 1187: Rebase after dpush. in file:///data/jelmer/bzr-svn/dpush/

Jelmer Vernooij jelmer at samba.org
Sun Jun 29 02:04:26 BST 2008


At file:///data/jelmer/bzr-svn/dpush/

------------------------------------------------------------
revno: 1187
revision-id: jelmer at samba.org-20080629010425-a4iyg0fm6zr0iw2f
parent: jelmer at samba.org-20080629003329-4at2clmy70o8t2n4
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: dpush
timestamp: Sun 2008-06-29 03:04:25 +0200
message:
  Rebase after dpush.
modified:
  __init__.py                    __init__.py-20051008155114-eae558e6cf149e1d
  tests/test_push.py             test_push.py-20070201165715-g2ievcdfqi33wqsy-1
=== modified file '__init__.py'
--- a/__init__.py	2008-06-29 00:33:29 +0000
+++ b/__init__.py	2008-06-29 01:04:25 +0000
@@ -377,7 +377,7 @@
     branch. 
     """
     takes_args = ['location?']
-    takes_options = ['revision', 'remember', Option('directory',
+    takes_options = ['remember', Option('directory',
             help='Branch to push from, '
                  'rather than the one containing the working directory.',
             short_name='d',
@@ -385,17 +385,22 @@
             ),
             Option('no-rebase', help="Don't rebase after push")]
 
-    def run(self, location=None, revision=None, remember=False, 
+    def run(self, location=None, remember=False, 
             directory=None, no_rebase=False):
         from bzrlib.bzrdir import BzrDir
         from bzrlib.branch import Branch
-        from bzrlib.errors import NotBranchError, BzrCommandError
+        from bzrlib.errors import NotBranchError, BzrCommandError, NoWorkingTree
         from bzrlib.commit import dpush
         from bzrlib import urlutils
 
         if directory is None:
             directory = "."
-        source_branch = Branch.open_containing(directory)[0]
+        try:
+            source_wt = WorkingTree.open_containing(directory)[0]
+            source_branch = source_wt.branch
+        except NoWorkingTree:
+            source_branch = Branch.open_containing(directory)[0]
+            source_wt = None
         stored_loc = source_branch.get_push_location()
         if location is None:
             if stored_loc is None:
@@ -417,14 +422,16 @@
             revision_id = None
         target_branch = bzrdir.open_branch()
         target_branch.lock_write()
-        revid_map = dpush(target_branch, source_branch, stop_revision=revision_id)
+        revid_map = dpush(target_branch, source_branch)
         # We successfully created the target, remember it
         if source_branch.get_push_location() is None or remember:
             source_branch.set_push_location(target_branch.base)
         if not no_rebase:
-            check_rebase_version((0, 2))
-            from bzrlib.plugins.rebase import rebase
-            # FIXME
+            new_last_revid = revid_map[source_branch.last_revision()]
+            source_branch.set_last_revision(new_last_revid)
+            if source_wt is not None:
+                source_wt.set_last_revision(new_last_revid)
+
 
 register_command(cmd_svn_dpush)
 

=== modified file 'tests/test_push.py'
--- a/tests/test_push.py	2008-06-29 00:33:29 +0000
+++ b/tests/test_push.py	2008-06-29 01:04:25 +0000
@@ -59,13 +59,21 @@
         wt = self.bzrdir.open_workingtree()
         newid = wt.commit(message="Commit from Bzr")
 
-        dpush(self.svndir.open_branch(), self.bzrdir.open_branch())
+        revid_map = dpush(self.svndir.open_branch(), self.bzrdir.open_branch())
+
+        self.assertEquals([newid], revid_map.keys())
 
         c = ra.RemoteAccess(self.repos_url)
         (entries, fetch_rev, props) = c.get_dir("", c.get_latest_revnum())
         self.assertEquals(set(['svn:entry:committed-rev', 
             'svn:entry:last-author', 'svn:entry:uuid', 
             'svn:entry:committed-date']), set(props.keys()))
+
+        r = self.svndir.find_repository()
+        self.assertEquals([r.generate_revision_id(
+                c.get_latest_revnum(),
+                "", 
+                r.get_mapping())], revid_map.values())
  
 
 class TestPush(TestCaseWithSubversionRepository):




More information about the bazaar-commits mailing list