Rev 3174: * Fetching via bzr+ssh will no longer fill ghosts by default (this is in http://people.ubuntu.com/~robertc/baz2.0/more-find-ghosts

Robert Collins robertc at robertcollins.net
Fri Jan 11 04:33:28 GMT 2008


At http://people.ubuntu.com/~robertc/baz2.0/more-find-ghosts

------------------------------------------------------------
revno: 3174
revision-id:robertc at robertcollins.net-20080111043302-0pi5csqyr1ugry00
parent: robertc at robertcollins.net-20080111035451-52at4031ohbmtoh2
committer: Robert Collins <robertc at robertcollins.net>
branch nick: more-find-ghosts
timestamp: Fri 2008-01-11 15:33:02 +1100
message:
   * Fetching via bzr+ssh will no longer fill ghosts by default (this is
     consistent with pack-0.92 fetching over SFTP). (Robert Collins)
  
   * Fetching now passes the find_ghosts flag through to the 
     ``InterRepository.missing_revision_ids`` call consistently for all
     repository types. This will enable faster missing revision discovery with
     bzr+ssh. (Robert Collins)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/fetch.py                fetch.py-20050818234941-26fea6105696365d
  bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
=== modified file 'NEWS'
--- a/NEWS	2008-01-11 03:54:51 +0000
+++ b/NEWS	2008-01-11 04:33:02 +0000
@@ -14,6 +14,9 @@
      been made to remove the ambiguity where ``branch2`` is in fact a
      specific file to diff within ``branch1``.
 
+   * Fetching via bzr+ssh will no longer fill ghosts by default (this is
+     consistent with pack-0.92 fetching over SFTP). (Robert Collins)
+
   FEATURES:
 
    * New option to use custom template-based formats in  ``bzr version-info``.
@@ -144,6 +147,11 @@
    * Add -Dtimes debug flag, which records a timestamp against each mutter to
      the trace file, relative to the first mutter.  (Andrew Bennetts)
    
+   * Fetching now passes the find_ghosts flag through to the 
+     ``InterRepository.missing_revision_ids`` call consistently for all
+     repository types. This will enable faster missing revision discovery with
+     bzr+ssh. (Robert Collins)
+
    * find_* methods available for BzrDirs, Branches and WorkingTrees.
      (Aaron Bentley)
 

=== modified file 'bzrlib/fetch.py'
--- a/bzrlib/fetch.py	2008-01-09 00:51:01 +0000
+++ b/bzrlib/fetch.py	2008-01-11 04:33:02 +0000
@@ -75,7 +75,13 @@
     This should not be used directly, it's essential a object to encapsulate
     the logic in InterRepository.fetch().
     """
-    def __init__(self, to_repository, from_repository, last_revision=None, pb=None):
+
+    def __init__(self, to_repository, from_repository, last_revision=None, pb=None,
+        find_ghosts=True):
+        """Create a repo fetcher.
+
+        :param find_ghosts: If True search the entire history for ghosts.
+        """
         # result variables.
         self.failed_revisions = []
         self.count_copied = 0
@@ -88,6 +94,7 @@
         self.from_repository = from_repository
         # must not mutate self._last_revision as its potentially a shared instance
         self._last_revision = last_revision
+        self.find_ghosts = find_ghosts
         if pb is None:
             self.pb = bzrlib.ui.ui_factory.nested_progress_bar()
             self.nested_pb = self.pb
@@ -196,7 +203,7 @@
             # XXX: this gets the full graph on both sides, and will make sure
             # that ghosts are filled whether or not you care about them.
             return self.to_repository.missing_revision_ids(self.from_repository,
-                                                           self._last_revision)
+                self._last_revision, find_ghosts=self.find_ghosts)
         except errors.NoSuchRevision:
             raise InstallFailed([self._last_revision])
 
@@ -372,10 +379,10 @@
     """Fetch from a Model1 repository into a Knit2 repository
     """
     def __init__(self, to_repository, from_repository, last_revision=None,
-                 pb=None):
+                 pb=None, find_ghosts=True):
         self.helper = Inter1and2Helper(from_repository, to_repository)
         GenericRepoFetcher.__init__(self, to_repository, from_repository,
-                                    last_revision, pb)
+            last_revision, pb, find_ghosts)
 
     def _generate_root_texts(self, revs):
         self.helper.generate_root_texts(revs)
@@ -388,10 +395,10 @@
     """Fetch from a Knit1 repository into a Knit2 repository"""
 
     def __init__(self, to_repository, from_repository, last_revision=None, 
-                 pb=None):
+                 pb=None, find_ghosts=True):
         self.helper = Inter1and2Helper(from_repository, to_repository)
         KnitRepoFetcher.__init__(self, to_repository, from_repository,
-                                 last_revision, pb)
+            last_revision, pb, find_ghosts)
 
     def _generate_root_texts(self, revs):
         self.helper.generate_root_texts(revs)

=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py	2008-01-11 03:54:51 +0000
+++ b/bzrlib/repository.py	2008-01-11 04:33:02 +0000
@@ -2312,7 +2312,31 @@
 
         :param revision_id: only return revision ids included by this
                             revision_id.
+        :param find_ghosts: If True find missing revisions in deep history
+            rather than just finding the surface difference.
         """
+        # stop searching at found target revisions.
+        if not find_ghosts and revision_id is not None:
+            graph = self.source.get_graph()
+            missing_revs = set()
+            searcher = graph._make_breadth_first_searcher([revision_id])
+            null_set = frozenset([_mod_revision.NULL_REVISION])
+            while True:
+                try:
+                    next_revs = set(searcher.next())
+                except StopIteration:
+                    break
+                next_revs.difference_update(null_set)
+                have_revs = self.target.has_revisions(next_revs)
+                missing_revs.update(next_revs - have_revs)
+                searcher.stop_searching_any(have_revs)
+            if next_revs - have_revs == set([revision_id]):
+                # we saw the start rev itself, but no parents from it (or
+                # next_revs would have been updated to e.g. set(). We remove
+                # have_revs because if we found revision_id locally we
+                # stop_searching at the first time around.
+                raise errors.NoSuchRevision(self.source, revision_id)
+            return missing_revs
         # generic, possibly worst case, slow code path.
         target_ids = set(self.target.all_revision_ids())
         if revision_id is not None:
@@ -2390,7 +2414,7 @@
         f = GenericRepoFetcher(to_repository=self.target,
                                from_repository=self.source,
                                last_revision=revision_id,
-                               pb=pb)
+                               pb=pb, find_ghosts=find_ghosts)
         return f.count_copied, f.failed_revisions
 
 
@@ -2468,7 +2492,7 @@
         f = GenericRepoFetcher(to_repository=self.target,
                                from_repository=self.source,
                                last_revision=revision_id,
-                               pb=pb)
+                               pb=pb, find_ghosts=find_ghosts)
         return f.count_copied, f.failed_revisions
 
     @needs_read_lock
@@ -2546,7 +2570,7 @@
         f = KnitRepoFetcher(to_repository=self.target,
                             from_repository=self.source,
                             last_revision=revision_id,
-                            pb=pb)
+                            pb=pb, find_ghosts=find_ghosts)
         return f.count_copied, f.failed_revisions
 
     @needs_read_lock
@@ -2651,7 +2675,7 @@
     def missing_revision_ids(self, revision_id=None, find_ghosts=True):
         """See InterRepository.missing_revision_ids().
         
-        :param find_ghosts: Find ghosts throughough the ancestry of
+        :param find_ghosts: Find ghosts throughout the ancestry of
             revision_id.
         """
         if not find_ghosts and revision_id is not None:
@@ -2709,7 +2733,7 @@
         f = Model1toKnit2Fetcher(to_repository=self.target,
                                  from_repository=self.source,
                                  last_revision=revision_id,
-                                 pb=pb)
+                                 pb=pb, find_ghosts=find_ghosts)
         return f.count_copied, f.failed_revisions
 
     @needs_write_lock
@@ -2766,7 +2790,7 @@
         f = Knit1to2Fetcher(to_repository=self.target,
                             from_repository=self.source,
                             last_revision=revision_id,
-                            pb=pb)
+                            pb=pb, find_ghosts=find_ghosts)
         return f.count_copied, f.failed_revisions
 
 
@@ -2792,7 +2816,7 @@
     def fetch(self, revision_id=None, pb=None, find_ghosts=False):
         """See InterRepository.fetch()."""
         revision_ids = self.target.missing_revision_ids(self.source,
-                                                        revision_id)
+            revision_id, find_ghosts=find_ghosts)
         def revisions_iterator():
             for current_revision_id in revision_ids:
                 revision = self.source.get_revision(current_revision_id)
@@ -2847,7 +2871,7 @@
         f = RemoteToOtherFetcher(to_repository=self.target,
                                  from_repository=self.source,
                                  last_revision=revision_id,
-                                 pb=pb)
+                                 pb=pb, find_ghosts=find_ghosts)
         return f.count_copied, f.failed_revisions
 
     @classmethod
@@ -2879,7 +2903,8 @@
 
     def fetch(self, revision_id=None, pb=None, find_ghosts=False):
         self._ensure_real_inter()
-        self._real_inter.fetch(revision_id=revision_id, pb=pb)
+        self._real_inter.fetch(revision_id=revision_id, pb=pb,
+            find_ghosts=find_ghosts)
 
     @classmethod
     def _get_repo_format_to_test(self):



More information about the bazaar-commits mailing list