Merge lp:~abentley/launchpad/qa-ready into lp:launchpad

Proposed by Aaron Bentley
Status: Merged
Approved by: Edwin Grubbs
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~abentley/launchpad/qa-ready
Merge into: lp:launchpad
Diff against target: 41 lines (+21/-2)
1 file modified
utilities/qa-ready (+21/-2)
To merge this branch: bzr merge lp:~abentley/launchpad/qa-ready
Reviewer Review Type Date Requested Status
Edwin Grubbs (community) Approve
Review via email: mp+20563@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Aaron Bentley (abentley) wrote :

= Summary =
Handle stale local mirrors more gracefully

== Proposed fix ==
If the revno does not correspond to a revision-id in the local mirror, try
the remote branch. If the determined revision-id does not exist in the local
mirror's repository, fetch it.

== Pre-implementation notes ==
None

== Implementation details ==
Fetching does not update the branch pointer or the tags. It has no effect on
the branch, only on what revisions are accessible in the branch's repository.

== Tests ==
None

== Demo and Q/A ==
With a stale local mirror, run qa-ready. It will tell you that the mirror is
stale, but will not raise NoSuchRevision.

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  utilities/qa-ready

Revision history for this message
Edwin Grubbs (edwin-grubbs) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'utilities/qa-ready'
2--- utilities/qa-ready 2010-02-25 19:07:52 +0000
3+++ utilities/qa-ready 2010-03-06 05:27:33 +0000
4@@ -8,6 +8,7 @@
5
6 from bzrlib.branch import Branch
7 from bzrlib.config import LocationConfig
8+from bzrlib.errors import NoSuchRevision
9 from bzrlib.transport import get_transport
10
11
12@@ -52,9 +53,27 @@
13 deployed_branch = Branch.open(deployed_location)
14 else:
15 deployed_branch = Branch.open(local_mirror)
16- deployed_branch.lock_read()
17+ deployed_branch.lock_write()
18 try:
19- deployed_rev_id = deployed_branch.get_rev_id(deployed_revno)
20+ try:
21+ deployed_rev_id = deployed_branch.get_rev_id(deployed_revno)
22+ except NoSuchRevision:
23+ if local_mirror is None:
24+ raise
25+ else:
26+ remote = Branch.open(deployed_location)
27+ remote.lock_read()
28+ try:
29+ deployed_rev_id = remote.get_rev_id(deployed_revno)
30+ print "Mirror %s is out of date." % deployed_branch.base
31+ if not deployed_branch.repository.has_revision(
32+ deployed_rev_id):
33+ deployed_branch.repository.fetch(
34+ remote.repository, deployed_rev_id)
35+ assert deployed_branch.repository.has_revision(
36+ deployed_rev_id)
37+ finally:
38+ remote.unlock()
39 graph = local_branch.repository.get_graph(deployed_branch.repository)
40 return graph.is_ancestor(local_branch.last_revision(), deployed_rev_id)
41 finally: