Rev 3056: If we are going to overwrite the target, we don't have to do in http://bzr.arbash-meinel.com/branches/bzr/0.93-dev/pull_set_last_revision_info_172970

John Arbash Meinel john at arbash-meinel.com
Fri Nov 30 23:27:42 GMT 2007


At http://bzr.arbash-meinel.com/branches/bzr/0.93-dev/pull_set_last_revision_info_172970

------------------------------------------------------------
revno: 3056
revision-id:john at arbash-meinel.com-20071130232718-9e3thvmobvj799br
parent: john at arbash-meinel.com-20071130232100-dwv5q1y86svbcts2
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: pull_set_last_revision_info_172970
timestamp: Fri 2007-11-30 17:27:18 -0600
message:
  If we are going to overwrite the target, we don't have to do
  any ancestry checks. Just nuke it right away.
  This makes 'bzr pull --overwrite' a bit faster.
modified:
  bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
  bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
-------------- next part --------------
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py	2007-11-30 23:18:15 +0000
+++ b/bzrlib/branch.py	2007-11-30 23:27:18 +0000
@@ -1439,7 +1439,7 @@
             last_rev, other_branch))
 
     @needs_write_lock
-    def update_revisions(self, other, stop_revision=None):
+    def update_revisions(self, other, stop_revision=None, overwrite=False):
         """See Branch.update_revisions."""
         other.lock_read()
         try:
@@ -1458,24 +1458,28 @@
             # be cached in memory.
             self.fetch(other, stop_revision)
             # Check to see if one is an ancestor of the other
-            heads = self.repository.get_graph().heads([stop_revision,
-                                                       last_rev])
-            if heads == set([last_rev]):
-                # The current revision is a decendent of the target, nothing to
-                # do
-                return
-            elif heads == set([stop_revision, last_rev]):
-                # These branches have diverged
-                raise errors.DivergedBranches(self, other)
-            assert heads == set([stop_revision])
+            if not overwrite:
+                heads = self.repository.get_graph().heads([stop_revision,
+                                                           last_rev])
+                if heads == set([last_rev]):
+                    # The current revision is a decendent of the target,
+                    # nothing to do
+                    return
+                elif heads == set([stop_revision, last_rev]):
+                    # These branches have diverged
+                    raise errors.DivergedBranches(self, other)
+                assert heads == set([stop_revision])
             if other_last_revision == stop_revision:
                 self.set_last_revision_info(other_last_revno,
                                             other_last_revision)
             else:
                 # TODO: jam 2007-11-29 Is there a way to determine the
                 #       revno without searching all of history??
-                self.generate_revision_history(stop_revision, last_rev=last_rev,
-                    other_branch=other)
+                if overwrite:
+                    self.generate_revision_history(stop_revision)
+                else:
+                    self.generate_revision_history(stop_revision,
+                        last_rev=last_rev, other_branch=other)
         finally:
             other.unlock()
 
@@ -1500,19 +1504,7 @@
         source.lock_read()
         try:
             result.old_revno, result.old_revid = self.last_revision_info()
-            try:
-                self.update_revisions(source, stop_revision)
-            except DivergedBranches:
-                if not overwrite:
-                    raise
-            if overwrite:
-                last_revno, last_revision = source.last_revision_info()
-                if stop_revision is None or stop_revision == last_revision:
-                    self.set_last_revision_info(last_revno, last_revision)
-                else:
-                    # TODO: jam 2007-11-29 Is there a way to determine the
-                    #       revno without searching all of history??
-                    self.generate_revision_history(stop_revision)
+            self.update_revisions(source, stop_revision, overwrite=overwrite)
             result.tag_conflicts = source.tags.merge_to(self.tags, overwrite)
             result.new_revno, result.new_revid = self.last_revision_info()
             if _hook_master:

=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py	2007-11-30 06:04:54 +0000
+++ b/bzrlib/remote.py	2007-11-30 23:27:18 +0000
@@ -1283,10 +1283,10 @@
         self._ensure_real()
         return self._real_branch.set_push_location(location)
 
-    def update_revisions(self, other, stop_revision=None):
+    def update_revisions(self, other, stop_revision=None, overwrite=False):
         self._ensure_real()
         return self._real_branch.update_revisions(
-            other, stop_revision=stop_revision)
+            other, stop_revision=stop_revision, overwrite=overwrite)
 
 
 class RemoteBranchConfig(BranchConfig):



More information about the bazaar-commits mailing list