Rev 1186: make dpush test pass. in file:///data/jelmer/bzr-svn/dpush/

Jelmer Vernooij jelmer at samba.org
Sun Jun 29 01:33:31 BST 2008


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

------------------------------------------------------------
revno: 1186
revision-id: jelmer at samba.org-20080629003329-4at2clmy70o8t2n4
parent: jelmer at samba.org-20080628234728-sg6urj2iqxraiiik
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: dpush
timestamp: Sun 2008-06-29 02:33:29 +0200
message:
  make dpush test pass.
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-28 23:47:28 +0000
+++ b/__init__.py	2008-06-29 00:33:29 +0000
@@ -390,6 +390,7 @@
         from bzrlib.bzrdir import BzrDir
         from bzrlib.branch import Branch
         from bzrlib.errors import NotBranchError, BzrCommandError
+        from bzrlib.commit import dpush
         from bzrlib import urlutils
 
         if directory is None:
@@ -416,15 +417,7 @@
             revision_id = None
         target_branch = bzrdir.open_branch()
         target_branch.lock_write()
-        revid_map = {}
-        # FIXME: figure out what revisions to push
-        todo = []
-        try:
-            for revid in todo:
-                revid_map[revid] = push(target_branch, source_branch, revid, 
-                     push_metadata=False)
-        finally:
-            target_branch.unlock()
+        revid_map = dpush(target_branch, source_branch, stop_revision=revision_id)
         # 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)

=== modified file 'commit.py'
--- a/commit.py	2008-06-27 18:23:06 +0000
+++ b/commit.py	2008-06-29 00:33:29 +0000
@@ -15,13 +15,13 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 """Committing and pushing to Subversion repositories."""
 
-from bzrlib import debug, osutils, urlutils
+from bzrlib import debug, osutils, urlutils, ui
 from bzrlib.branch import Branch
 from bzrlib.errors import (BzrError, InvalidRevisionId, DivergedBranches, 
                            UnrelatedBranches, AppendRevisionsOnlyViolation)
 from bzrlib.inventory import Inventory
 from bzrlib.repository import RootCommitBuilder, InterRepository
-from bzrlib.revision import NULL_REVISION
+from bzrlib.revision import NULL_REVISION, ensure_null
 from bzrlib.trace import mutter, warning
 
 from cStringIO import StringIO
@@ -515,7 +515,7 @@
 
         revid = self.branch.generate_revision_id(result_revision)
 
-        assert self._new_revision_id is None or self._new_revision_id == revid
+        assert not self.push_metadata or self._new_revision_id is None or self._new_revision_id == revid
 
         self.mutter('commit %d finished. author: %r, date: %r, revid: %r',
                result_revision, result_author, 
@@ -675,6 +675,37 @@
     push(ImaginaryBranch(target_repository), source, start_revid, push_metadata=push_metadata)
 
 
+def dpush(target, source, stop_revision=None):
+    source.lock_read()
+    try:
+        if stop_revision is None:
+            stop_revision = ensure_null(source.last_revision())
+        if target.last_revision() in (stop_revision, source.last_revision()):
+            return
+        graph = target.repository.get_graph()
+        if not source.repository.get_graph().is_ancestor(target.last_revision(), 
+                                                        stop_revision):
+            if graph.is_ancestor(stop_revision, target.last_revision()):
+                return
+            raise DivergedBranches(self, other)
+        todo = target.repository.lhs_missing_revisions(source.revision_history(), 
+                                                     stop_revision)
+        revid_map = {}
+        pb = ui.ui_factory.nested_progress_bar()
+        try:
+            for revid in todo:
+                pb.update("pushing revisions", todo.index(revid), 
+                          len(todo))
+                revid_map[revid] = push(target, source, revid, push_metadata=False)
+                target._clear_cached_state()
+        finally:
+            pb.finished()
+        (new_revno, new_revid) = target.last_revision_info()
+        return revid_map
+    finally:
+        source.unlock()
+
+
 def push_revision_tree(target, config, source_repo, base_revid, revision_id, 
                        rev, push_metadata=True):
     old_tree = source_repo.revision_tree(revision_id)

=== modified file 'tests/test_push.py'
--- a/tests/test_push.py	2008-06-28 17:39:31 +0000
+++ b/tests/test_push.py	2008-06-29 00:33:29 +0000
@@ -33,7 +33,7 @@
 
 from bzrlib.plugins.svn import format, ra
 from bzrlib.plugins.svn.errors import ChangesRootLHSHistory, MissingPrefix
-from bzrlib.plugins.svn.commit import push
+from bzrlib.plugins.svn.commit import push, dpush
 from bzrlib.plugins.svn.mapping import SVN_PROP_BZR_REVISION_ID
 from bzrlib.plugins.svn.tests import TestCaseWithSubversionRepository
 
@@ -59,14 +59,13 @@
         wt = self.bzrdir.open_workingtree()
         newid = wt.commit(message="Commit from Bzr")
 
-        svnbranch = self.svndir.open_branch()
-        svnbranch.pull(self.bzrdir.open_branch())
+        dpush(self.svndir.open_branch(), self.bzrdir.open_branch())
 
         c = ra.RemoteAccess(self.repos_url)
         (entries, fetch_rev, props) = c.get_dir("", c.get_latest_revnum())
-        self.assertEquals(['svn:entry:committed-rev', 
+        self.assertEquals(set(['svn:entry:committed-rev', 
             'svn:entry:last-author', 'svn:entry:uuid', 
-            'svn:entry:committed-date'], props.keys())
+            'svn:entry:committed-date']), set(props.keys()))
  
 
 class TestPush(TestCaseWithSubversionRepository):




More information about the bazaar-commits mailing list