Rev 2741: Move same repository check up to Repository.fetch to allow all fetch implementations to benefit. in http://people.ubuntu.com/~robertc/baz2.0/repository

Robert Collins robertc at robertcollins.net
Sun Aug 26 03:06:39 BST 2007


At http://people.ubuntu.com/~robertc/baz2.0/repository

------------------------------------------------------------
revno: 2741
revision-id: robertc at robertcollins.net-20070826020611-4y80los70jgigih3
parent: robertc at robertcollins.net-20070825012039-m8oajomk0ej8r5q5
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository
timestamp: Sun 2007-08-26 12:06:11 +1000
message:
  Move same repository check up to Repository.fetch to allow all fetch implementations to benefit.
modified:
  bzrlib/fetch.py                fetch.py-20050818234941-26fea6105696365d
  bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
=== modified file 'bzrlib/fetch.py'
--- a/bzrlib/fetch.py	2007-08-23 02:18:37 +0000
+++ b/bzrlib/fetch.py	2007-08-26 02:06:11 +0000
@@ -80,11 +80,9 @@
         self.failed_revisions = []
         self.count_copied = 0
         if to_repository.has_same_location(from_repository):
-            # check that last_revision is in 'from' and then return a
-            # no-operation.
-            if last_revision is not None and not is_null(last_revision):
-                to_repository.get_revision(last_revision)
-            return
+            # repository.fetch should be taking care of this case.
+            raise errors.BzrError('unreachable code - Interrepository fetch'
+                ' with the same repository.')
         self.to_repository = to_repository
         self.from_repository = from_repository
         # must not mutate self._last_revision as its potentially a shared instance

=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py	2007-08-25 01:20:39 +0000
+++ b/bzrlib/repository.py	2007-08-26 02:06:11 +0000
@@ -444,6 +444,14 @@
         If revision_id is None all content is copied.
         """
         revision_id = osutils.safe_revision_id(revision_id)
+        # fast path same-url fetch operations
+        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, []
         inter = InterRepository.get(source, self)
         try:
             return inter.fetch(revision_id=revision_id, pb=pb)



More information about the bazaar-commits mailing list