Rev 1565: Fix tests, share more code. in file:///data/jelmer/bzr-svn/pushmerged/

Jelmer Vernooij jelmer at samba.org
Mon Aug 4 17:08:27 BST 2008


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

------------------------------------------------------------
revno: 1565
revision-id: jelmer at samba.org-20080804160825-k9k3pn6ahyfxot27
parent: jelmer at samba.org-20080804154802-1192erejvzdal0oe
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: pushmerged
timestamp: Mon 2008-08-04 18:08:25 +0200
message:
  Fix tests, share more code.
modified:
  AUTHORS                        AUTHORS-20060508114718-4c90c0062645106d
  BRANCH.TODO                    branch.todo-20070721175243-w23kkak0gm2jbr8b-1
  branch.py                      svnbranch.py-20051017135706-11c749eb0dab04a7
  commit.py                      commit.py-20060607190346-qvq128wgfubhhgm2-1
  tests/test_revids.py           test_revids.py-20070516230044-d7x872cqi7xb4eow-1
=== modified file 'AUTHORS'
--- a/AUTHORS	2008-07-30 10:42:53 +0000
+++ b/AUTHORS	2008-08-04 16:08:25 +0000
@@ -13,6 +13,7 @@
 Jerry Carter
 Chandler Carruth
 Robert Collins
+Mattias Eriksson
 David Foerster
 Mirko Friedenhagen
 Martin von Gagern

=== modified file 'BRANCH.TODO'
--- a/BRANCH.TODO	2008-08-03 05:48:23 +0000
+++ b/BRANCH.TODO	2008-08-04 16:08:25 +0000
@@ -1,7 +1,6 @@
 pushmerge:
  - make pushmerge option in repository configuration
  - create branches/ dir automatically
- - invoke from InterSvnBzrRepository as well
 
 before 0.4.10:
  - use parents cache more agressively

=== modified file 'branch.py'
--- a/branch.py	2008-08-04 15:47:27 +0000
+++ b/branch.py	2008-08-04 16:08:25 +0000
@@ -30,7 +30,7 @@
 from bzrlib.plugins.svn import core, wc
 from bzrlib.plugins.svn.auth import create_auth_baton
 from bzrlib.plugins.svn.client import Client, get_config
-from bzrlib.plugins.svn.commit import push, push_new
+from bzrlib.plugins.svn.commit import push, push_new, push_ancestors
 from bzrlib.plugins.svn.config import BranchConfig
 from bzrlib.plugins.svn.core import SubversionException
 from bzrlib.plugins.svn.errors import NotSvnBranchPath, ERR_FS_NO_SUCH_REVISION
@@ -516,22 +516,7 @@
                           len(todo))
                 if push_merged:
                     parent_revids = graph.get_parent_map([revid])[revid]
-                    for parent_revid in parent_revids[1:]:
-                        if self.repository.has_revision(parent_revid):
-                            continue
-                        # Push merged revisions
-                        unique_ancestors = graph.find_unique_ancestors(parent_revid, [parent_revids[0]])
-                        for x in graph.iter_topo_order(unique_ancestors):
-                            if self.repository.has_revision(x):
-                                continue
-                            rev = other.repository.get_revision(x)
-                            nick = (rev.properties.get('branch-nick') or "merged").encode("utf-8").replace("/","_")
-                            rhs_branch_path = self.layout.get_branch_path(nick, self.project)
-                            assert rhs_branch_path != self.get_branch_path()
-                            push_new(self.repository, 
-                                    rhs_branch_path,
-                                    other, x)
-                            self._clear_cached_state()
+                    push_ancestors(self.repository, self.layout, self.project, parent_revids, graph)
                 push(self, other, revid)
                 self._clear_cached_state()
         finally:

=== modified file 'commit.py'
--- a/commit.py	2008-08-04 15:48:02 +0000
+++ b/commit.py	2008-08-04 16:08:25 +0000
@@ -859,13 +859,8 @@
                 return
             mutter("pushing %r into svn", todo)
             target_branch = None
-            layout = target_branch.repository.get_layout()
-            if layout.push_merged_revisions(target_branch.project):
-                push_merged = True
-                graph = target.repository.get_graph()
-            else:
-                push_merged = False
-            target_config = target_branch.get_config()
+            layout = self.target.get_layout()
+            graph = self.target.get_graph()
             for revision_id in todo:
                 if pb is not None:
                     pb.update("pushing revisions", todo.index(revision_id), len(todo))
@@ -881,15 +876,10 @@
                 if target_branch.get_branch_path() != bp:
                     target_branch.set_branch_path(bp)
 
-                if push_merged and len(rev.parent_ids) > 1:
-                    # Push merged revisions
-                    unique_ancestors = graph.find_unique_ancestors(revision_id, todo)
-                    merged_revs = dict(zip(unique_ancestors, self.source.get_revisions(unique_ancestors)))
-                    for x in graph.iter_topo_order(unique_ancestors):
-                        push_revision_tree(layout.get_branch_path(merged_revs[x].properties['nick']), target_config, 
-                                       self.source, 
-                                       merged_revs[x].parent_ids[0], x, merged_revs[x])
+                if layout.push_merged_revisions(target_branch.project) and len(rev.parent_ids) > 1:
+                    push_ancestors(self.target, layout, "", rev.parent_ids, graph)
 
+                target_config = target_branch.get_config()
                 push_revision_tree(target_branch, target_config, self.source, 
                                    parent_revid, revision_id, rev)
         finally:
@@ -904,3 +894,18 @@
     def is_compatible(source, target):
         """Be compatible with SvnRepository."""
         return isinstance(target, SvnRepository)
+
+
+def push_ancestors(repository, layout, project, parent_revids, graph):
+    for parent_revid in parent_revids[1:]:
+        if repository.has_revision(parent_revid):
+            continue
+        # Push merged revisions
+        unique_ancestors = graph.find_unique_ancestors(parent_revid, [parent_revids[0]])
+        for x in graph.iter_topo_order(unique_ancestors):
+            if repository.has_revision(x):
+                continue
+            rev = other.repository.get_revision(x)
+            nick = (rev.properties.get('branch-nick') or "merged").encode("utf-8").replace("/","_")
+            rhs_branch_path = layout.get_branch_path(nick, project)
+            push_new(repository, rhs_branch_path, other, x)

=== modified file 'tests/test_revids.py'
--- a/tests/test_revids.py	2008-06-04 15:20:12 +0000
+++ b/tests/test_revids.py	2008-08-04 16:08:25 +0000
@@ -54,6 +54,6 @@
 
     def test_lookup_branch_incomplete(self):
         revidmap = RevisionIdMapCache()
-        revidmap.insert_revid("bla", "mypath", 200, 42, "brainslug")
+        revidmap.insert_revid("bla", "mypath", 42, 200, "brainslug")
         self.assertEquals(None, 
                 revidmap.lookup_branch_revnum(42, "mypath", "brainslug"))




More information about the bazaar-commits mailing list