Rev 1566: Require source repository to be passed to push only, not source branch. in file:///data/jelmer/bzr-svn/pushmerged/

Jelmer Vernooij jelmer at samba.org
Mon Aug 4 17:23:25 BST 2008


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

------------------------------------------------------------
revno: 1566
revision-id: jelmer at samba.org-20080804162324-73wmjhv74lmbzgmh
parent: jelmer at samba.org-20080804160825-k9k3pn6ahyfxot27
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: pushmerged
timestamp: Mon 2008-08-04 18:23:24 +0200
message:
  Require source repository to be passed to push only, not source branch.
modified:
  branch.py                      svnbranch.py-20051017135706-11c749eb0dab04a7
  commit.py                      commit.py-20060607190346-qvq128wgfubhhgm2-1
  remote.py                      format.py-20060406233823-b6fa009fe35dfde7
  tests/test_push.py             test_push.py-20070201165715-g2ievcdfqi33wqsy-1
=== modified file 'branch.py'
--- a/branch.py	2008-08-04 16:08:25 +0000
+++ b/branch.py	2008-08-04 16:23:24 +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, push_ancestors
+from bzrlib.plugins.svn.commit import push, 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
@@ -335,7 +335,7 @@
         """See Branch.set_revision_history()."""
         if rev_history == [] or not self.repository.has_revision(rev_history[-1]):
             raise NotImplementedError("set_revision_history can't add ghosts")
-        push(self, self, rev_history[-1])
+        push(self, self.repository, rev_history[-1])
         self._clear_cached_state()
 
     def set_last_revision_info(self, revno, revid):
@@ -516,8 +516,8 @@
                           len(todo))
                 if push_merged:
                     parent_revids = graph.get_parent_map([revid])[revid]
-                    push_ancestors(self.repository, self.layout, self.project, parent_revids, graph)
-                push(self, other, revid)
+                    push_ancestors(self.repository, other.repository, self.layout, self.project, parent_revids, graph)
+                push(self, other.repository, revid)
                 self._clear_cached_state()
         finally:
             pb.finished()

=== modified file 'commit.py'
--- a/commit.py	2008-08-04 16:08:25 +0000
+++ b/commit.py	2008-08-04 16:23:24 +0000
@@ -21,7 +21,7 @@
                            UnrelatedBranches, AppendRevisionsOnlyViolation,
                            NoSuchRevision)
 from bzrlib.inventory import Inventory
-from bzrlib.repository import RootCommitBuilder, InterRepository
+from bzrlib.repository import RootCommitBuilder, InterRepository, Repository
 from bzrlib.revision import NULL_REVISION, ensure_null
 from bzrlib.trace import mutter, warning
 
@@ -649,10 +649,10 @@
 
     :param target_repository: Repository to push to
     :param target_branch_path: Path to create new branch at
-    :param source: Branch to pull the revision from
+    :param source: Source repository
     """
-    assert isinstance(source, Branch)
-    revhistory = list(source.repository.iter_reverse_revision_history(stop_revision))
+    assert isinstance(source, Repository)
+    revhistory = list(source.iter_reverse_revision_history(stop_revision))
     history = list(revhistory)
     history.reverse()
     start_revid_parent = NULL_REVISION
@@ -735,7 +735,7 @@
             for revid in todo:
                 pb.update("pushing revisions", todo.index(revid), 
                           len(todo))
-                revid_map[revid] = push(target, source, revid, 
+                revid_map[revid] = push(target, source.repository, revid, 
                                         push_metadata=False)
                 source.repository.fetch(target.repository, 
                                         revision_id=revid_map[revid])
@@ -781,18 +781,18 @@
     return revid
 
 
-def push(target, source, revision_id, push_metadata=True):
+def push(target, source_repo, revision_id, push_metadata=True):
     """Push a revision into Subversion.
 
     This will do a new commit in the target branch.
 
     :param target: Branch to push to
-    :param source: Branch to pull the revision from
+    :param source_repo: Branch to pull the revision from
     :param revision_id: Revision id of the revision to push
     :return: revision id of revision that was pushed
     """
-    assert isinstance(source, Branch)
-    rev = source.repository.get_revision(revision_id)
+    assert isinstance(source_repo, Repository)
+    rev = source_repo.get_revision(revision_id)
     mutter('pushing %r (%r)', revision_id, rev.parent_ids)
 
     # revision on top of which to commit
@@ -804,13 +804,13 @@
     else:
         base_revid = target.last_revision()
 
-    source.lock_read()
+    source_repo.lock_read()
     try:
         revid = push_revision_tree(target, target.get_config(), 
-                                   source.repository, base_revid, revision_id, 
+                                   source_repo, base_revid, revision_id, 
                                    rev, push_metadata=push_metadata)
     finally:
-        source.unlock()
+        source_repo.unlock()
 
     assert revid == revision_id or not push_metadata
 
@@ -877,7 +877,7 @@
                     target_branch.set_branch_path(bp)
 
                 if layout.push_merged_revisions(target_branch.project) and len(rev.parent_ids) > 1:
-                    push_ancestors(self.target, layout, "", rev.parent_ids, graph)
+                    push_ancestors(self.target, self.source, layout, "", rev.parent_ids, graph)
 
                 target_config = target_branch.get_config()
                 push_revision_tree(target_branch, target_config, self.source, 
@@ -896,16 +896,16 @@
         return isinstance(target, SvnRepository)
 
 
-def push_ancestors(repository, layout, project, parent_revids, graph):
+def push_ancestors(target_repo, source_repo, layout, project, parent_revids, graph):
     for parent_revid in parent_revids[1:]:
-        if repository.has_revision(parent_revid):
+        if target_repo.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):
+            if target_repo.has_revision(x):
                 continue
-            rev = other.repository.get_revision(x)
+            rev = source_repo.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)
+            push_new(target_repo, rhs_branch_path, source_repo, x)

=== modified file 'remote.py'
--- a/remote.py	2008-07-08 23:28:17 +0000
+++ b/remote.py	2008-08-04 16:23:24 +0000
@@ -139,7 +139,7 @@
                 if repos.transport.check_path(target_branch_path,
                     repos.get_latest_revnum()) != core.NODE_NONE:
                     raise AlreadyBranchError(full_branch_url)
-                push_new(repos, target_branch_path, source, stop_revision)
+                push_new(repos, target_branch_path, source.repository, stop_revision)
             finally:
                 repos.unlock()
             branch = self.open_branch()

=== modified file 'tests/test_push.py'
--- a/tests/test_push.py	2008-08-02 21:53:02 +0000
+++ b/tests/test_push.py	2008-08-04 16:23:24 +0000
@@ -437,12 +437,12 @@
         self.build_tree({'mybranch/foo': 'bladata'})
         wt = self.bzrdir.open_workingtree()
         revid = wt.commit(message="Commit from Bzr")
-        push(Branch.open("%s/trunk" % self.repos_url), wt.branch, 
+        push(Branch.open("%s/trunk" % self.repos_url), wt.branch.repository, 
              wt.branch.revision_history()[-2])
         mutter('log %r' % self.client_log("%s/trunk" % self.repos_url, 0, 4)[4][0])
         self.assertEquals('M',
             self.client_log("%s/trunk" % self.repos_url, 0, 4)[4][0]['/trunk'][0])
-        push(Branch.open("%s/trunk" % self.repos_url), wt.branch, wt.branch.last_revision())
+        push(Branch.open("%s/trunk" % self.repos_url), wt.branch.repository, wt.branch.last_revision())
         mutter('log %r' % self.client_log("%s/trunk" % self.repos_url, 0, 5)[5][0])
         self.assertEquals("/branches/mybranch", 
             self.client_log("%s/trunk" % self.repos_url, 0, 5)[5][0]['/trunk'][1])




More information about the bazaar-commits mailing list