launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #20554
[Merge] lp:~cjwatson/launchpad/fix-bzrsync-with-ghosts into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/fix-bzrsync-with-ghosts into lp:launchpad.
Commit message:
Fix scanning branches with ghost revisions in their ancestry.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #1587948 in Launchpad itself: "Fails to scan branches with ghosts"
https://bugs.launchpad.net/launchpad/+bug/1587948
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/fix-bzrsync-with-ghosts/+merge/296239
Fix scanning branches with ghost revisions in their ancestry. This notably includes Launchpad itself.
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/fix-bzrsync-with-ghosts into lp:launchpad.
=== modified file 'lib/lp/code/model/branch.py'
--- lib/lp/code/model/branch.py 2016-05-24 05:30:44 +0000
+++ lib/lp/code/model/branch.py 2016-06-01 17:34:22 +0000
@@ -1102,7 +1102,8 @@
(BranchRevision.branch, BranchRevision.revision_id,
BranchRevision.sequence),
[(self, rev_db_ids[revid], seq)
- for revid, seq in revision_id_sequence_pairs])
+ for revid, seq in revision_id_sequence_pairs
+ if revid in rev_db_ids])
def getTipRevision(self):
"""See `IBranch`."""
=== modified file 'lib/lp/code/model/tests/test_branch.py'
--- lib/lp/code/model/tests/test_branch.py 2016-02-06 01:41:00 +0000
+++ lib/lp/code/model/tests/test_branch.py 2016-06-01 17:34:22 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2015 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2016 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Tests for Branches."""
@@ -2135,6 +2135,22 @@
branch.createBranchRevisionFromIDs(
[(rev.revision_id, revision_number)])
+ def test_ghost(self):
+ # createBranchRevisionFromIDs skips ghost revisions for which no
+ # Revision rows exist.
+ branch = self.factory.makeAnyBranch()
+ rev = self.factory.makeRevision()
+ revision_number = self.factory.getUniqueInteger()
+ ghost_rev_id = self.factory.getUniqueString("revision-id")
+ revision_id_sequence_pairs = [
+ (rev.revision_id, revision_number),
+ (ghost_rev_id, None),
+ ]
+ branch.createBranchRevisionFromIDs(revision_id_sequence_pairs)
+ self.assertEqual(
+ revision_number, branch.getBranchRevision(revision=rev).sequence)
+ self.assertIsNone(branch.getBranchRevision(revision_id=ghost_rev_id))
+
class TestRevisionHistory(TestCaseWithFactory):
"""Tests for a branch's revision history."""
Follow ups