make sure multiple revisions can be pushed correctly.
authorJelmer Vernooij <jelmer@samba.org>
Sun, 29 Jun 2008 02:34:13 +0000 (04:34 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Sun, 29 Jun 2008 02:34:13 +0000 (04:34 +0200)
__init__.py
commit.py
tests/test_push.py

index 1f82997d614e8c9a56175cac745bf15fdf084c15..40a5a5e5d9960bdc817ad4b5e441da2f1a13e98e 100644 (file)
@@ -26,8 +26,7 @@ from bzrlib.revisionspec import SPEC_TYPES
 from bzrlib.trace import warning, mutter
 from bzrlib.transport import register_lazy_transport, register_transport_proto
 
-from bzrlib.plugins.svn import format
-from bzrlib.plugins.svn import revspec
+from bzrlib.plugins.svn import format, revspec
 
 # versions ending in 'exp' mean experimental mappings
 # versions ending in 'dev' mean development version
@@ -370,11 +369,11 @@ class cmd_svn_push(Command):
 register_command(cmd_svn_push)
 
 class cmd_dpush(Command):
-    """Push revisions to Subversion without setting any magic Bazaar-specific 
-    properties.
+    """Push diffs into Subversion avoiding the use of any Bazaar-specific properties.
 
     This will afterwards rebase the local Bazaar branch on the Subversion 
-    branch. 
+    branch unless the --no-rebase option is used, in which case 
+    the two branches will be out of sync. 
     """
     takes_args = ['location?']
     takes_options = ['remember', Option('directory',
index ce830c4ea01db13b5dafc4b90c2ebb81261d2702..99f249aac5b8b9717b42d39f09564221b8454c91 100644 (file)
--- a/commit.py
+++ b/commit.py
@@ -676,7 +676,7 @@ def push_new(target_repository, target_branch_path, source,
 
 
 def dpush(target, source, stop_revision=None):
-    source.lock_read()
+    source.lock_write()
     try:
         if stop_revision is None:
             stop_revision = ensure_null(source.last_revision())
@@ -697,6 +697,7 @@ def dpush(target, source, stop_revision=None):
                 pb.update("pushing revisions", todo.index(revid), 
                           len(todo))
                 revid_map[revid] = push(target, source, revid, push_metadata=False)
+                source.repository.fetch(target.repository, revision_id=revid_map[revid])
                 target._clear_cached_state()
         finally:
             pb.finished()
@@ -711,7 +712,8 @@ def push_revision_tree(target, config, source_repo, base_revid, revision_id,
     old_tree = source_repo.revision_tree(revision_id)
     base_tree = source_repo.revision_tree(base_revid)
 
-    builder = SvnCommitBuilder(target.repository, target, rev.parent_ids,
+    builder = SvnCommitBuilder(target.repository, target, 
+                               rev.parent_ids if push_metadata else [base_revid],
                                config, rev.timestamp,
                                rev.timezone, rev.committer, rev.properties, 
                                revision_id, base_tree.inventory, 
@@ -748,10 +750,13 @@ def push(target, source, revision_id, push_metadata=True):
     mutter('pushing %r (%r)', revision_id, rev.parent_ids)
 
     # revision on top of which to commit
-    if rev.parent_ids == []:
-        base_revid = None
+    if push_metadata:
+        if rev.parent_ids == []:
+            base_revid = None
+        else:
+            base_revid = rev.parent_ids[0]
     else:
-        base_revid = rev.parent_ids[0]
+        base_revid = target.last_revision()
 
     source.lock_read()
     try:
@@ -822,7 +827,8 @@ class InterToSvnRepository(InterRepository):
                 if target_branch.get_branch_path() != bp:
                     target_branch.set_branch_path(bp)
 
-                push_revision_tree(target_branch, target_branch.get_config(), self.source, parent_revid, revision_id, rev)
+                push_revision_tree(target_branch, target_branch.get_config(), self.source, 
+                                   parent_revid, revision_id, rev)
         finally:
             self.source.unlock()
  
index 556a65a6e2294af0038723f2d0393c814a4f8c91..b0cdfd56f309494dcd522692a7bba86dfdbbf176 100644 (file)
@@ -54,7 +54,7 @@ class TestDPush(TestCaseWithSubversionRepository):
     def commit_editor(self):
         return self.get_commit_editor(self.repos_url)
 
-    def test_change(self):
+    def test_change_single(self):
         self.build_tree({'dc/foo/bla': 'other data'})
         wt = self.bzrdir.open_workingtree()
         newid = wt.commit(message="Commit from Bzr")
@@ -74,6 +74,31 @@ class TestDPush(TestCaseWithSubversionRepository):
                 c.get_latest_revnum(),
                 "", 
                 r.get_mapping())], revid_map.values())
+
+    def test_change_multiple(self):
+        self.build_tree({'dc/foo/bla': 'other data'})
+        wt = self.bzrdir.open_workingtree()
+        self.build_tree({'dc/foo/bla': 'other data'})
+        newid1 = wt.commit(message="Commit from Bzr")
+        self.build_tree({'dc/foo/bla': 'yet other data'})
+        newid2 = wt.commit(message="Commit from Bzr")
+
+        revid_map = dpush(self.svndir.open_branch(), self.bzrdir.open_branch())
+
+        self.assertEquals(set([newid1, newid2]), set(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(set([r.generate_revision_id(
+                rev,
+                "", 
+                r.get_mapping()) for rev in (c.get_latest_revnum()-1, c.get_latest_revnum())]), 
+                set(revid_map.values()))
  
 
 class TestPush(TestCaseWithSubversionRepository):