Merge lp:~maxb/bzr-builddeb/graph-heads-misuse into lp:bzr-builddeb

Proposed by Max Bowsher
Status: Merged
Approved by: James Westby
Approved revision: 562
Merged at revision: 562
Proposed branch: lp:~maxb/bzr-builddeb/graph-heads-misuse
Merge into: lp:bzr-builddeb
Diff against target: 65 lines (+10/-16)
1 file modified
import_dsc.py (+10/-16)
To merge this branch: bzr merge lp:~maxb/bzr-builddeb/graph-heads-misuse
Reviewer Review Type Date Requested Status
James Westby Approve
Review via email: mp+63337@code.launchpad.net

Description of the change

Via some weirdness in the rxtx UDD import (mentioned in bug 785859), I discovered some code which assumes that:

   len(graph.heads([A, B])) == 1

means that it is safe to pull A into a branch currently at B.

This, however, fails to take into account whether A is an ancestor of B, or B is an ancestor of A.

The end result was that the importer elided the Ubuntu-specific history from the oneiric branch after a ./requeue_package.py --full, pulling the Debian revision corresponding to a synced package version into the Ubuntu branch.

The fix is simply to take account of *which* of A and B is the head.

To post a comment you must log in.
Revision history for this message
James Westby (james-w) :
review: Approve
Revision history for this message
James Westby (james-w) wrote :

Nice catch Max, thanks.

James

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'import_dsc.py'
2--- import_dsc.py 2011-04-29 12:54:58 +0000
3+++ import_dsc.py 2011-06-03 07:57:30 +0000
4@@ -572,9 +572,8 @@
5 try:
6 graph = branch.branch.repository.get_graph(
7 self.branch.repository)
8- other_revid = branch.revid_of_version(version)
9- if len(graph.heads([other_revid,
10- self.branch.last_revision()])) == 1:
11+ if graph.is_ancestor(self.branch.last_revision(),
12+ branch.revid_of_version(version)):
13 return branch
14 finally:
15 branch.branch.unlock()
16@@ -585,9 +584,8 @@
17 try:
18 graph = branch.branch.repository.get_graph(
19 self.branch.repository)
20- other_revid = branch.revid_of_version(version)
21- if len(graph.heads([other_revid,
22- self.branch.last_revision()])) == 1:
23+ if graph.is_ancestor(self.branch.last_revision(),
24+ branch.revid_of_version(version)):
25 return branch
26 finally:
27 branch.branch.unlock()
28@@ -622,31 +620,27 @@
29 try:
30 for branch in reversed(self.get_lesser_branches()):
31 if branch.has_upstream_version(version, md5=md5):
32- # Check for divergenge.
33+ # Check that they haven't diverged
34 other_up_branch = branch.upstream_branch
35 other_up_branch.lock_read()
36 try:
37 graph = other_up_branch.repository.get_graph(
38 up_branch.repository)
39- other_revid = branch.revid_of_upstream_version(
40- version)
41- if len(graph.heads([other_revid,
42- up_branch.last_revision()])) == 1:
43+ if graph.is_ancestor(up_branch.last_revision(),
44+ branch.revid_of_upstream_version(version)):
45 return branch
46 finally:
47 other_up_branch.unlock()
48 for branch in self.get_greater_branches():
49 if branch.has_upstream_version(version, md5=md5):
50- # Check for divergenge.
51+ # Check that they haven't diverged
52 other_up_branch = branch.upstream_branch
53 other_up_branch.lock_read()
54 try:
55 graph = other_up_branch.repository.get_graph(
56 up_branch.repository)
57- other_revid = branch.revid_of_upstream_version(
58- version)
59- if len(graph.heads([other_revid,
60- up_branch.last_revision()])) == 1:
61+ if graph.is_ancestor(up_branch.last_revision(),
62+ branch.revid_of_upstream_version(version)):
63 return branch
64 finally:
65 other_up_branch.unlock()

Subscribers

People subscribed via source and target branches