[Pkg-bazaar-commits] ./bzr-builddeb/trunk r367: Merge fix for invisible revisions due to locking.

James Westby james.westby at canonical.com
Fri Aug 28 14:07:59 UTC 2009


------------------------------------------------------------
revno: 367 [merge]
committer: James Westby <james.westby at canonical.com>
branch nick: trunk
timestamp: Fri 2009-08-28 15:07:59 +0100
message:
  Merge fix for invisible revisions due to locking.
modified:
  import_dsc.py
  merge_package.py
-------------- next part --------------
=== modified file 'import_dsc.py'
--- a/import_dsc.py	2009-08-19 12:22:29 +0000
+++ b/import_dsc.py	2009-08-28 14:07:59 +0000
@@ -1080,26 +1080,10 @@
 
     def _fetch_upstream_to_branch(self, revid):
         """Fetch the revision from the upstream branch in to the pacakging one.
-
-        This will unlock self.tree, then re-lock it and fetch. This is
-        necessary as if the two branches share a repository the branch
-        won't see any revisions added by the upstream branch since self.tree
-        was locked.
-
-        It will check that the last revision is the same before and after,
-        and that there are no working tree changes, to prevent unexpected
-        things happening if say a commit was done in this time.
         """
-        if self.tree.is_locked():
-            last_revision = self.branch.last_revision()
-            # Unlock the tree and lock it again
-            self.tree.unlock()
-            self.tree.lock_write()
-            assert self.branch.last_revision() == last_revision, \
-                    "Branch committed to while refreshing it. Not proceeding."
-            assert not self.tree.changes_from(
-                    self.tree.basis_tree()).has_changed(), \
-                    "Treee altered while refreshing it. Not proceeding."
+        # Make sure we see any revisions added by the upstream branch
+        # since self.tree was locked.
+        self.branch.repository.refresh_data()
         self.branch.fetch(self.upstream_branch, last_revision=revid)
         self.upstream_branch.tags.merge_to(self.branch.tags)
 

=== modified file 'merge_package.py'
--- a/merge_package.py	2009-08-25 10:27:07 +0000
+++ b/merge_package.py	2009-08-25 17:54:52 +0000
@@ -24,8 +24,8 @@
 import shutil
 import tempfile
 
-from bzrlib import errors
-
+from bzrlib.plugins.builddeb.errors import (
+    SharedUpstreamConflictsWithTargetPackaging)
 from bzrlib.plugins.builddeb.import_dsc import DistributionBranch
 from bzrlib.plugins.builddeb.util import find_changelog
 
@@ -147,12 +147,15 @@
                     tmp_target_utree.set_parent_ids((ut_revid, us_revid))
                     tmp_target_utree.commit(
                         'Prepared upstream tree for merging into target branch.')
+                    # Repository updates during a held lock are not visible,
+                    # hence the call to refresh the data in the /target/ repo.
+                    tree.branch.repository.refresh_data()
 
                     # Merge shared upstream parent into the target merge branch. This
                     # creates revison L in the digram above.
                     conflicts = tree.merge_from_branch(tmp_target_utree.branch)
                     if conflicts > 0:
-                        raise errors.SharedUpstreamConflictsWithTargetPackaging()
+                        raise SharedUpstreamConflictsWithTargetPackaging()
                     else:
                         tree.commit('Merging shared upstream rev into target branch.')
 



More information about the Pkg-bazaar-commits mailing list