Rev 5877: (jelmer) Make lossy an argument to Branch.pull. (Jelmer Vernooij) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Tue May 17 12:45:06 UTC 2011


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 5877 [merge]
revision-id: pqm at pqm.ubuntu.com-20110517124455-8mzoceddh4wjmtgp
parent: pqm at pqm.ubuntu.com-20110517015521-96ie5w6ix04utat2
parent: jelmer at samba.org-20110517103037-iwjz4q4r6ggmiado
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2011-05-17 12:44:55 +0000
message:
  (jelmer) Make lossy an argument to Branch.pull. (Jelmer Vernooij)
modified:
  bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
  bzrlib/foreign.py              foreign.py-20081112170002-olsxmandkk8qyfuq-1
  bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
  bzrlib/tests/per_branch/test_push.py test_push.py-20070130153159-fhfap8uoifevg30j-1
  bzrlib/tests/test_foreign.py   test_foreign.py-20081125004048-ywb901edgp9lluxo-1
  doc/en/release-notes/bzr-2.4.txt bzr2.4.txt-20110114053217-k7ym9jfz243fddjm-1
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py	2011-05-09 10:53:44 +0000
+++ b/bzrlib/branch.py	2011-05-17 10:26:44 +0000
@@ -1102,35 +1102,14 @@
             stop_revision=stop_revision,
             possible_transports=possible_transports, *args, **kwargs)
 
-    def push(self, target, overwrite=False, stop_revision=None, *args,
-        **kwargs):
+    def push(self, target, overwrite=False, stop_revision=None, lossy=False,
+            *args, **kwargs):
         """Mirror this branch into target.
 
         This branch is considered to be 'local', having low latency.
         """
         return InterBranch.get(self, target).push(overwrite, stop_revision,
-            *args, **kwargs)
-
-    def lossy_push(self, target, stop_revision=None):
-        """Push deltas into another branch.
-
-        :note: This does not, like push, retain the revision ids from 
-            the source branch and will, rather than adding bzr-specific 
-            metadata, push only those semantics of the revision that can be 
-            natively represented by this branch' VCS.
-
-        :param target: Target branch
-        :param stop_revision: Revision to push, defaults to last revision.
-        :return: BranchPushResult with an extra member revidmap: 
-            A dictionary mapping revision ids from the target branch 
-            to new revision ids in the target branch, for each 
-            revision that was pushed.
-        """
-        inter = InterBranch.get(self, target)
-        lossy_push = getattr(inter, "lossy_push", None)
-        if lossy_push is None:
-            raise errors.LossyPushToSameVCS(self, target)
-        return lossy_push(stop_revision)
+            lossy, *args, **kwargs)
 
     def basis_tree(self):
         """Return `Tree` object for last revision."""
@@ -3251,7 +3230,7 @@
         raise NotImplementedError(self.pull)
 
     @needs_write_lock
-    def push(self, overwrite=False, stop_revision=None,
+    def push(self, overwrite=False, stop_revision=None, lossy=False,
              _override_hook_source_branch=None):
         """Mirror the source branch into the target branch.
 
@@ -3405,7 +3384,7 @@
             if master_branch:
                 master_branch.unlock()
 
-    def push(self, overwrite=False, stop_revision=None,
+    def push(self, overwrite=False, stop_revision=None, lossy=False,
              _override_hook_source_branch=None):
         """See InterBranch.push.
 
@@ -3416,13 +3395,15 @@
         This is for use of RemoteBranch, where push is delegated to the
         underlying vfs-based Branch.
         """
+        if lossy:
+            raise errors.LossyPushToSameVCS(self.source, self.target)
         # TODO: Public option to disable running hooks - should be trivial but
         # needs tests.
         self.source.lock_read()
         try:
             return _run_with_write_locked_target(
                 self.target, self._push_with_bound_branches, overwrite,
-                stop_revision,
+                stop_revision, 
                 _override_hook_source_branch=_override_hook_source_branch)
         finally:
             self.source.unlock()

=== modified file 'bzrlib/foreign.py'
--- a/bzrlib/foreign.py	2011-04-07 10:36:24 +0000
+++ b/bzrlib/foreign.py	2011-05-14 07:56:12 +0000
@@ -20,7 +20,6 @@
 
 from bzrlib.branch import (
     Branch,
-    InterBranch,
     )
 from bzrlib.commands import Command, Option
 from bzrlib.repository import Repository
@@ -315,7 +314,7 @@
         target_branch.lock_write()
         try:
             try:
-                push_result = source_branch.lossy_push(target_branch)
+                push_result = source_branch.push(target_branch, lossy=True)
             except errors.LossyPushToSameVCS:
                 raise BzrCommandError("%r and %r are in the same VCS, lossy "
                     "push not necessary. Please use regular push." %
@@ -338,23 +337,3 @@
             push_result.report(self.outf)
         finally:
             target_branch.unlock()
-
-
-class InterToForeignBranch(InterBranch):
-
-    def lossy_push(self, stop_revision=None):
-        """Push deltas into another branch.
-
-        :note: This does not, like push, retain the revision ids from 
-            the source branch and will, rather than adding bzr-specific 
-            metadata, push only those semantics of the revision that can be 
-            natively represented by this branch' VCS.
-
-        :param target: Target branch
-        :param stop_revision: Revision to push, defaults to last revision.
-        :return: BranchPushResult with an extra member revidmap: 
-            A dictionary mapping revision ids from the target branch 
-            to new revision ids in the target branch, for each 
-            revision that was pushed.
-        """
-        raise NotImplementedError(self.lossy_push)

=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py	2011-05-13 09:30:57 +0000
+++ b/bzrlib/remote.py	2011-05-15 15:47:43 +0000
@@ -2995,10 +2995,10 @@
             _override_hook_target=self, **kwargs)
 
     @needs_read_lock
-    def push(self, target, overwrite=False, stop_revision=None):
+    def push(self, target, overwrite=False, stop_revision=None, lossy=False):
         self._ensure_real()
         return self._real_branch.push(
-            target, overwrite=overwrite, stop_revision=stop_revision,
+            target, overwrite=overwrite, stop_revision=stop_revision, lossy=lossy,
             _override_hook_source_branch=self)
 
     def is_locked(self):

=== modified file 'bzrlib/tests/per_branch/test_push.py'
--- a/bzrlib/tests/per_branch/test_push.py	2011-03-23 05:15:48 +0000
+++ b/bzrlib/tests/per_branch/test_push.py	2011-05-14 20:01:04 +0000
@@ -461,4 +461,4 @@
     def test_lossy_push_raises_same_vcs(self):
         target = self.make_branch('target')
         source = self.make_branch('source')
-        self.assertRaises(errors.LossyPushToSameVCS, source.lossy_push, target)
+        self.assertRaises(errors.LossyPushToSameVCS, source.push, target, lossy=True)

=== modified file 'bzrlib/tests/test_foreign.py'
--- a/bzrlib/tests/test_foreign.py	2011-05-02 17:07:16 +0000
+++ b/bzrlib/tests/test_foreign.py	2011-05-17 10:29:43 +0000
@@ -110,11 +110,9 @@
     def import_last_revision_info_and_tags(self, source, revno, revid,
                                            lossy=False):
         interbranch = InterToDummyVcsBranch(source, self)
+        result = interbranch.push(stop_revision=revid, lossy=True)
         if lossy:
-            result = interbranch.lossy_push(revid)
             revid = result.revidmap[revid]
-        else:
-            interbranch.push(revid)
         return (revno, revid)
 
 
@@ -150,17 +148,15 @@
         return "Dummy Foreign Vcs Repository"
 
 
-class InterToDummyVcsBranch(branch.GenericInterBranch,
-                            foreign.InterToForeignBranch):
+class InterToDummyVcsBranch(branch.GenericInterBranch):
 
     @staticmethod
     def is_compatible(source, target):
         return isinstance(target, DummyForeignVcsBranch)
 
-    def push(self, overwrite=False, stop_revision=None):
-        raise errors.NoRoundtrippingSupport(self.source, self.target)
-
-    def lossy_push(self, stop_revision=None):
+    def push(self, overwrite=False, stop_revision=None, lossy=False):
+        if not lossy:
+            raise errors.NoRoundtrippingSupport(self.source, self.target)
         result = branch.BranchPushResult()
         result.source_branch = self.source
         result.target_branch = self.target
@@ -171,7 +167,8 @@
             my_history = self.target.revision_history()
             if stop_revision is None:
                 stop_revision = self.source.last_revision()
-            their_history = list(self.source.repository.iter_reverse_revision_history(stop_revision))
+            their_history = list(
+                self.source.repository.iter_reverse_revision_history(stop_revision))
             their_history.reverse()
             if their_history[:min(len(my_history), len(their_history))] != my_history:
                 raise errors.DivergedBranches(self.target, self.source)
@@ -453,7 +450,7 @@
         source_tree = self.make_branch_and_tree("source")
         target_tree = self.make_branch_and_tree("target", 
             format=DummyForeignVcsDirFormat())
-        pushresult = source_tree.branch.lossy_push(target_tree.branch)
+        pushresult = source_tree.branch.push(target_tree.branch, lossy=True)
         self.assertEquals(revision.NULL_REVISION, pushresult.old_revid)
         self.assertEquals(revision.NULL_REVISION, pushresult.new_revid)
         self.assertEquals({}, pushresult.revidmap)
@@ -467,7 +464,7 @@
             format=DummyForeignVcsDirFormat())
         target_tree.branch.lock_write()
         try:
-            pushresult = source_tree.branch.lossy_push(target_tree.branch)
+            pushresult = source_tree.branch.push(target_tree.branch, lossy=True)
         finally:
             target_tree.branch.unlock()
         self.assertEquals(revision.NULL_REVISION, pushresult.old_revid)

=== modified file 'doc/en/release-notes/bzr-2.4.txt'
--- a/doc/en/release-notes/bzr-2.4.txt	2011-05-17 01:55:21 +0000
+++ b/doc/en/release-notes/bzr-2.4.txt	2011-05-17 10:30:37 +0000
@@ -106,6 +106,10 @@
   compatible optimisers rather than an instance of the class it is called
   on. (Jelmer Vernooij)
 
+* ``Branch.push`` now takes a ``lossy`` argument.
+  ``Branch.lossy_push`` has been removed.
+  (Jelmer Vernooij)
+
 * New method ``Repository.get_file_graph`` which can return the
   per-file revision graph. (Jelmer Vernooij, #775578)
 




More information about the bazaar-commits mailing list