[MERGE] Move responsibility for detecting same-repo fetching from the optimiser to the wrapper function.

Martin Pool mbp at canonical.com
Thu Oct 4 06:48:52 BST 2007


Martin Pool has voted approve.
Status is now: Approved
Comment:

          self.from_repository = from_repository
          # must not mutate self._last_revision as its potentially a 
shared instance

=== modified file 'bzrlib/remote.py'
--- bzrlib/remote.py    2007-10-03 05:25:50 +0000
+++ bzrlib/remote.py    2007-10-04 01:24:06 +0000
@@ -607,6 +607,13 @@
          return False

      def fetch(self, source, revision_id=None, pb=None):
+        if self.has_same_location(source):
+            # check that last_revision is in 'from' and then return a
+            # no-operation.
+            if (revision_id is not None and
+                not _mod_revision.is_null(revision_id)):
+                self.get_revision(revision_id)
+            return 0, []
          self._ensure_real()


Why is this a no-op on remote repos but an error on local repositories?

+            mutter_callsite(3, "has_revision is a LBYL symptom.")

I realize you're just updating this, but I think the message would be 
more
clear by telling the caller to "don't call has_revision, just try to 
access it"
or something similar.


+    @staticmethod
+    def _same_model(source, target):
+        """True if source and target have the same data 
representation."""
+        if source.supports_rich_root() != target.supports_rich_root():
+            return False
+        if source._serializer != target._serializer:
+            return False
+        return True
+


Adding such a method sounds good.  It seems like it ought to be exposed 
as repo.has_same_model(other_repo), but I guess that can be done later.


For details, see: 
http://bundlebuggy.aaronbentley.com/request/%3C1191461207.30729.0.camel%40lifeless-64%3E



More information about the bazaar mailing list