Merge lp:~maxb/launchpad/update-sourcecode-miscellanea into lp:launchpad

Proposed by Max Bowsher on 2010-02-04
Status: Merged
Approved by: Jonathan Lange on 2010-02-05
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~maxb/launchpad/update-sourcecode-miscellanea
Merge into: lp:launchpad
Diff against target: 79 lines (+20/-14)
1 file modified
lib/devscripts/sourcecode.py (+20/-14)
To merge this branch: bzr merge lp:~maxb/launchpad/update-sourcecode-miscellanea
Reviewer Review Type Date Requested Status
Jonathan Lange (community) 2010-02-04 Approve on 2010-02-05
Review via email: mp+18648@code.launchpad.net

Commit Message

Fix some small bugs in update-sourcecode

To post a comment you must log in.
Max Bowsher (maxb) wrote :

Three fairly small improvements to update-sourcecode.

Rationales are explained in the individual revision commit messages.

Jonathan Lange (jml) wrote :

Fine by me.

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 2009-12-09 07:44:40 +0000
3+++ lib/devscripts/sourcecode.py 2010-02-04 23:29:14 +0000
4@@ -17,11 +17,10 @@
5
6 from bzrlib.branch import Branch
7 from bzrlib.bzrdir import BzrDir
8-from bzrlib.errors import BzrError
9+from bzrlib.errors import BzrError, NotBranchError
10 from bzrlib.plugin import load_plugins
11 from bzrlib.revisionspec import RevisionSpec
12-from bzrlib.trace import report_exception
13-from bzrlib.transport import get_transport
14+from bzrlib.trace import enable_default_logging, report_exception
15 from bzrlib import ui
16 from bzrlib.workingtree import WorkingTree
17
18@@ -112,10 +111,16 @@
19
20 def find_branches(directory):
21 """List the directory names in 'directory' that are branches."""
22- transport = get_transport(directory)
23- return (
24- os.path.basename(branch.base.rstrip('/'))
25- for branch in BzrDir.find_branches(transport))
26+ branches = []
27+ for name in os.listdir(directory):
28+ if name in ('.', '..'):
29+ continue
30+ try:
31+ Branch.open(os.path.join(directory, name))
32+ branches.append(name)
33+ except NotBranchError:
34+ pass
35+ return branches
36
37
38 def get_revision_id(revision, from_branch, tip=False):
39@@ -183,7 +188,7 @@
40 # Update project from branch_url.
41 destination = os.path.join(sourcecode_directory, project)
42 print 'Updating %s to %s' % (
43- project, _format_revision_name(revision, tip)),
44+ project, _format_revision_name(revision, tip))
45 local_tree = WorkingTree.open(destination)
46 try:
47 remote_branch = Branch.open(
48@@ -197,17 +202,17 @@
49 possible_transports.append(
50 remote_branch.bzrdir.root_transport)
51 revision_id = get_revision_id(revision, remote_branch, tip)
52- result = local_tree.pull(
53- remote_branch, stop_revision=revision_id, overwrite=True,
54- possible_transports=possible_transports)
55- if result.old_revno == result.new_revno:
56- print '(No change)'
57+ if revision_id == local_tree.last_revision():
58+ print ' (No change)'
59 else:
60+ result = local_tree.pull(
61+ remote_branch, stop_revision=revision_id, overwrite=True,
62+ possible_transports=possible_transports)
63 if result.old_revno < result.new_revno:
64 change = 'Updated'
65 else:
66 change = 'Reverted'
67- print '(%s from %s to %s)' % (
68+ print ' (%s from %s to %s)' % (
69 change, result.old_revno, result.new_revno)
70
71
72@@ -277,6 +282,7 @@
73 parser.error("Too many arguments.")
74 print 'Sourcecode: %s' % (sourcecode_directory,)
75 print 'Config: %s' % (config_filename,)
76+ enable_default_logging()
77 # Tell bzr to use the terminal (if any) to show progress bars
78 ui.ui_factory = ui.make_ui_for_terminal(
79 sys.stdin, sys.stdout, sys.stderr)