[Pkg-bazaar-commits] ./bzr-builddeb/trunk.old r242: Don't try and commit with no parents if it's not the initial commit.

James Westby jw+debian at jameswestby.net
Wed Dec 10 08:32:49 UTC 2008


------------------------------------------------------------
revno: 242
committer: James Westby <jw+debian at jameswestby.net>
branch nick: read-only-import
timestamp: Mon 2008-07-14 18:22:34 +0100
message:
  Don't try and commit with no parents if it's not the initial commit.
  
  If a sync was done from Debian then history was dropped from the changelog,
  this means that it can't determine any parents and so asks for none, it
  should just use the current tip as a parent. (LP: #248440)
modified:
  import_dsc.py
  tests/test_import_dsc.py
-------------- next part --------------
=== modified file 'import_dsc.py'
--- a/import_dsc.py	2008-07-11 21:58:43 +0000
+++ b/import_dsc.py	2008-07-14 17:22:34 +0000
@@ -1530,6 +1530,13 @@
                 mutter("Adding current tip as parent: %s"
                         % self.branch.last_revision())
                 parents.insert(0, self.branch.last_revision())
+        elif self.branch.last_revision() != NULL_REVISION:
+            # We were told to import with no parents. That's not
+            # right, so import with the current parent. Should
+            # perhaps be fixed in the methods to determine the parents.
+            mutter("Told to import with no parents. Adding current tip "
+                   "as the single parent")
+            parents = [self.branch.last_revision()]
         other_branches = self.get_other_branches()
         def get_last_revision_tree(br):
             return br.repository.revision_tree(br.last_revision())

=== modified file 'tests/test_import_dsc.py'
--- a/tests/test_import_dsc.py	2008-07-14 17:02:25 +0000
+++ b/tests/test_import_dsc.py	2008-07-14 17:22:34 +0000
@@ -2287,6 +2287,34 @@
         self.assertTrue(self.db1.is_version_native(version1))
         self.assertTrue(self.db1.is_version_native(version2))
 
+    def test_import_native_two_unrelated(self):
+        version1 = Version("1.0")
+        version2 = Version("1.1")
+        builder = SourcePackageBuilder("package", version1, native=True)
+        builder.add_default_control()
+        builder.add_upstream_file("README", "foo")
+        builder.build()
+        self.db1.import_package(builder.dsc_name())
+        builder = SourcePackageBuilder("package", version2, native=True)
+        builder.add_default_control()
+        builder.add_upstream_file("README", "bar")
+        builder.build()
+        self.db1.import_package(builder.dsc_name())
+        rh1 = self.tree1.branch.revision_history()
+        up_rh1 = self.up_tree1.branch.revision_history()
+        self.assertEqual(len(rh1), 2)
+        self.assertEqual(len(up_rh1), 0)
+        rev_tree1 = self.tree1.branch.repository.revision_tree(rh1[0])
+        rev_tree2 = self.tree1.branch.repository.revision_tree(rh1[1])
+        self.assertEqual(rev_tree1.get_parent_ids(), [])
+        self.assertEqual(rev_tree2.get_parent_ids(), [rh1[0]])
+        self.check_changes(rev_tree2.changes_from(rev_tree1),
+                modified=["README", "debian/changelog"])
+        self.assertEqual(self.db1.revid_of_version(version1), rh1[0])
+        self.assertEqual(self.db1.revid_of_version(version2), rh1[1])
+        self.assertTrue(self.db1.is_version_native(version1))
+        self.assertTrue(self.db1.is_version_native(version2))
+
 
 class SourcePackageBuilder(object):
 



More information about the Pkg-bazaar-commits mailing list