Merge lp:~jelmer/launchpad/upgrade-sourcecode into lp:launchpad

Proposed by Jelmer Vernooij on 2010-04-08
Status: Merged
Approved by: Michael Hudson-Doyle on 2010-04-08
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~jelmer/launchpad/upgrade-sourcecode
Merge into: lp:launchpad
Diff against target: 56 lines (+20/-6)
1 file modified
lib/devscripts/sourcecode.py (+20/-6)
To merge this branch: bzr merge lp:~jelmer/launchpad/upgrade-sourcecode
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle 2010-04-08 Approve on 2010-04-08
Review via email: mp+23034@code.launchpad.net

Commit Message

Automatically upgrade Bazaar branches when encountering IncompatibleRepositories errors.

Description of the Change

This makes update-sourcecode automatically upgrade branches when the remote branch that they're tracking gets upgraded.

This change should allow me to land the updated pygpgme, the branch of which has recently been upgraded to 2a.

To post a comment you must log in.
Michael Hudson-Doyle (mwhudson) wrote :

It's not *that* hard to dig the real format out of a remote branch iirc, but it's probably not worth it. Please land.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/devscripts/sourcecode.py'
2--- lib/devscripts/sourcecode.py 2010-02-04 23:23:32 +0000
3+++ lib/devscripts/sourcecode.py 2010-04-08 15:54:28 +0000
4@@ -16,12 +16,12 @@
5 import sys
6
7 from bzrlib.branch import Branch
8-from bzrlib.bzrdir import BzrDir
9-from bzrlib.errors import BzrError, NotBranchError
10+from bzrlib.errors import BzrError, NotBranchError, IncompatibleRepositories
11 from bzrlib.plugin import load_plugins
12 from bzrlib.revisionspec import RevisionSpec
13 from bzrlib.trace import enable_default_logging, report_exception
14 from bzrlib import ui
15+from bzrlib.upgrade import upgrade
16 from bzrlib.workingtree import WorkingTree
17
18 from devscripts import get_launchpad_root
19@@ -146,6 +146,7 @@
20 else:
21 return 'tip'
22
23+
24 def get_branches(sourcecode_directory, new_branches,
25 possible_transports=None, tip=False):
26 """Get the new branches into sourcecode."""
27@@ -202,12 +203,25 @@
28 possible_transports.append(
29 remote_branch.bzrdir.root_transport)
30 revision_id = get_revision_id(revision, remote_branch, tip)
31- if revision_id == local_tree.last_revision():
32+ try:
33+ result = local_tree.pull(
34+ remote_branch, stop_revision=revision_id, overwrite=True,
35+ possible_transports=possible_transports)
36+ except IncompatibleRepositories:
37+ # XXX JRV 20100407: Ideally remote_branch.bzrdir._format
38+ # should be passed into upgrade() to ensure the format is the same
39+ # locally and remotely. Unfortunately smart server branches
40+ # have their _format set to RemoteFormat rather than an actual
41+ # format instance.
42+ upgrade(destination)
43+ # Upgraded, repoen working tree
44+ local_tree = WorkingTree.open(destination)
45+ result = local_tree.pull(
46+ remote_branch, stop_revision=revision_id, overwrite=True,
47+ possible_transports=possible_transports)
48+ if result.old_revid == result.new_revid:
49 print ' (No change)'
50 else:
51- result = local_tree.pull(
52- remote_branch, stop_revision=revision_id, overwrite=True,
53- possible_transports=possible_transports)
54 if result.old_revno < result.new_revno:
55 change = 'Updated'
56 else: