[Pkg-bazaar-commits] ./bzr-builddeb/trunk r338: Merge 2.1 fixes.

James Westby james.westby at canonical.com
Sat Jul 4 20:49:10 UTC 2009


------------------------------------------------------------
revno: 338
committer: James Westby <james.westby at canonical.com>
branch nick: trunk
timestamp: Mon 2009-06-08 12:32:19 +0100
message:
  Merge 2.1 fixes.
modified:
  import_dsc.py
  tests/test_import_dsc.py
    ------------------------------------------------------------
    revno: 327.1.60
    committer: James Westby <james.westby at canonical.com>
    branch nick: 2.1
    timestamp: Wed 2009-05-13 21:26:49 +0100
    message:
      Don't deadlock when the pristine-tar delta is large.
    modified:
      import_dsc.py
    ------------------------------------------------------------
    revno: 327.1.61
    committer: James Westby <james.westby at canonical.com>
    branch nick: 2.1
    timestamp: Wed 2009-05-13 23:10:24 +0100
    message:
      Also allow "higher" branches when looking for branches to pull parts from.
    modified:
      import_dsc.py
      tests/test_import_dsc.py
-------------- next part --------------
=== modified file 'import_dsc.py'
--- a/import_dsc.py	2009-06-08 11:31:06 +0000
+++ b/import_dsc.py	2009-06-08 11:32:19 +0000
@@ -775,7 +775,7 @@
         Looks in all the lesser branches for the given version/md5 pair
         in a branch that has not diverged from this.
 
-        If it is present in a lower branch that has not diverged this
+        If it is present in another branch that has not diverged this
         method will return the greatest branch that it is present in,
         otherwise it will return None. If it returns a branch then it
         indicates that a pull should be done from that branch, rather
@@ -805,6 +805,18 @@
                             return branch
                     finally:
                         branch.branch.unlock()
+            for branch in self.get_greater_branches():
+                if branch.has_version(version, md5=md5):
+                    # Check that they haven't diverged
+                    branch.branch.lock_read()
+                    try:
+                        graph = branch.branch.repository.get_graph(
+                                self.branch.repository)
+                        if len(graph.heads([branch.branch.last_revision(),
+                                    self.branch.last_revision()])) == 1:
+                            return branch
+                    finally:
+                        branch.branch.unlock()
             return None
         finally:
             self.branch.unlock()
@@ -812,7 +824,7 @@
     def branch_to_pull_upstream_from(self, version, md5):
         """Checks whether this upstream is a pull from a lesser branch.
 
-        Looks in all the lesser upstream branches for the given
+        Looks in all the other upstream branches for the given
         version/md5 pair in a branch that has not diverged from this.
         If it is present in a lower branch this method will return the
         greatest branch that it is present in that has not diverged,
@@ -846,6 +858,19 @@
                             return branch
                     finally:
                         other_up_branch.unlock()
+            for branch in self.get_greater_branches():
+                if branch.has_upstream_version(version, md5=md5):
+                    # Check for divergenge.
+                    other_up_branch = branch.upstream_branch
+                    other_up_branch.lock_read()
+                    try:
+                        graph = other_up_branch.repository.get_graph(
+                                up_branch.repository)
+                        if len(graph.heads([other_up_branch.last_revision(),
+                                    up_branch.last_revision()])) == 1:
+                            return branch
+                    finally:
+                        other_up_branch.unlock()
             return None
         finally:
             up_branch.unlock()
@@ -1334,9 +1359,9 @@
         dsc_filename = os.path.abspath(dsc_filename)
         proc = Popen("dpkg-source -su -x %s" % (dsc_filename,), shell=True,
                 cwd=tempdir, stdout=PIPE, stderr=PIPE)
-        ret = proc.wait()
-        assert ret == 0, "dpkg-source -x failed, output:\n%s\n%s" % \
-                    (proc.stdout.read(), proc.stderr.read())
+        (stdout, stderr) = proc.communicate()
+        assert proc.returncode == 0, "dpkg-source -x failed, output:\n%s\n%s" % \
+                    (stdout, stderr)
         return tempdir
 
     def _do_import_package(self, version, versions, debian_part, md5,
@@ -1619,11 +1644,9 @@
                        dest_filename]
             print command
             proc = Popen(command, stdin=PIPE, cwd=dest)
-            proc.stdin.write(delta)
-            proc.stdin.close()
-            ret = proc.wait()
-            if ret != 0:
-                raise PristineTarError("Generating tar from delta failed")
+            (stdout, stderr) = proc.communicate(delta)
+            if proc.returncode != 0:
+                raise PristineTarError("Generating tar from delta failed: %s" % stderr)
         finally:
             shutil.rmtree(tmpdir)
 
@@ -1637,9 +1660,9 @@
             command = ["/usr/bin/pristine-tar", "gendelta", tarball_path, "-"]
             info(" ".join(command))
             proc = Popen(command, stdout=PIPE, cwd=dest)
-            ret = proc.wait()
-            if ret != 0:
-                raise PristineTarError("Generating delta from tar failed")
-            return proc.stdout.read()
+            (stdout, stderr) = proc.communicate()
+            if proc.returncode != 0:
+                raise PristineTarError("Generating delta from tar failed: %s" % stderr)
+            return stdout
         finally:
             shutil.rmtree(tmpdir)

=== modified file 'tests/test_import_dsc.py'
--- a/tests/test_import_dsc.py	2009-03-16 16:22:41 +0000
+++ b/tests/test_import_dsc.py	2009-06-08 11:32:19 +0000
@@ -825,6 +825,20 @@
         self.assertEqual(len(self.up_tree2.branch.revision_history()), 2)
         self.assertEqual(len(self.tree2.branch.revision_history()), 3)
 
+    def test_import_package_init_upstream_from_other(self):
+        version1 = Version("0.1-1")
+        version2 = Version("0.1-2")
+        builder = SourcePackageBuilder("package", version1)
+        builder.add_default_control()
+        builder.build()
+        self.db2.import_package(builder.dsc_name())
+        self.db2.upstream_tree = None
+        builder.new_version(version2)
+        builder.build()
+        self.db1.import_package(builder.dsc_name())
+        self.assertEqual(len(self.up_tree1.branch.revision_history()), 1)
+        self.assertEqual(len(self.tree1.branch.revision_history()), 3)
+
     def import_package_single(self):
         version1 = Version("0.1-1")
         builder = SourcePackageBuilder("package", version1)



More information about the Pkg-bazaar-commits mailing list