Rev 1374: make sure multiple revisions can be pushed correctly. in http://people.samba.org/bzr/jelmer/bzr-svn/0.4

Jelmer Vernooij jelmer at samba.org
Sun Jun 29 03:34:15 BST 2008


At http://people.samba.org/bzr/jelmer/bzr-svn/0.4

------------------------------------------------------------
revno: 1374
revision-id: jelmer at samba.org-20080629023413-w5tzn5wy5f2jnbaj
parent: jelmer at samba.org-20080629021727-f39qtwzn14jqonqm
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Sun 2008-06-29 04:34:13 +0200
message:
  make sure multiple revisions can be pushed correctly.
modified:
  __init__.py                    __init__.py-20051008155114-eae558e6cf149e1d
  commit.py                      commit.py-20060607190346-qvq128wgfubhhgm2-1
  tests/test_push.py             test_push.py-20070201165715-g2ievcdfqi33wqsy-1
=== modified file '__init__.py'
--- a/__init__.py	2008-06-29 02:14:07 +0000
+++ b/__init__.py	2008-06-29 02:34:13 +0000
@@ -26,8 +26,7 @@
 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 @@
 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',

=== modified file 'commit.py'
--- a/commit.py	2008-06-29 00:33:29 +0000
+++ b/commit.py	2008-06-29 02:34:13 +0000
@@ -676,7 +676,7 @@
 
 
 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 @@
                 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 @@
     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 @@
     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 @@
                 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()
  

=== modified file 'tests/test_push.py'
--- a/tests/test_push.py	2008-06-29 01:04:25 +0000
+++ b/tests/test_push.py	2008-06-29 02:34:13 +0000
@@ -54,7 +54,7 @@
     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 @@
                 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):




More information about the bazaar-commits mailing list