Merge lp:~chris-gondolin/charm-helpers/fetch-bzr-revnos into lp:charm-helpers

Proposed by Chris Stratford
Status: Merged
Merged at revision: 587
Proposed branch: lp:~chris-gondolin/charm-helpers/fetch-bzr-revnos
Merge into: lp:charm-helpers
Diff against target: 40 lines (+13/-5)
1 file modified
charmhelpers/fetch/bzrurl.py (+13/-5)
To merge this branch: bzr merge lp:~chris-gondolin/charm-helpers/fetch-bzr-revnos
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Approve
Review via email: mp+289942@code.launchpad.net

Description of the change

Adds the option to specify a revno when fetching from a bzr repo.

Updated and resubmitted, since the code the original merge request was made against (8 months ago) has now changed.

To post a comment you must log in.
Revision history for this message
Stuart Bishop (stub) wrote :

Looks fine, but there is no test for the new arguments. I've added the trivial test, which demonstrated a bug (revno needs to be cast to a string), which I have also fixed.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/fetch/bzrurl.py'
2--- charmhelpers/fetch/bzrurl.py 2015-12-10 21:01:00 +0000
3+++ charmhelpers/fetch/bzrurl.py 2016-03-23 17:06:53 +0000
4@@ -42,15 +42,23 @@
5 else:
6 return True
7
8- def branch(self, source, dest):
9+ def branch(self, source, dest, revno=None):
10 if not self.can_handle(source):
11 raise UnhandledSource("Cannot handle {}".format(source))
12+ cmd_opts = []
13+ if revno:
14+ cmd_opts += ['-r', revno]
15 if os.path.exists(dest):
16- check_call(['bzr', 'pull', '--overwrite', '-d', dest, source])
17+ cmd = ['bzr', 'pull']
18+ cmd += cmd_opts
19+ cmd += ['--overwrite', '-d', dest, source]
20 else:
21- check_call(['bzr', 'branch', source, dest])
22+ cmd = ['bzr', 'branch']
23+ cmd += cmd_opts
24+ cmd += [source, dest]
25+ check_call(cmd)
26
27- def install(self, source, dest=None):
28+ def install(self, source, dest=None, revno=None):
29 url_parts = self.parse_url(source)
30 branch_name = url_parts.path.strip("/").split("/")[-1]
31 if dest:
32@@ -62,7 +70,7 @@
33 if not os.path.exists(dest_dir):
34 mkdir(dest_dir, perms=0o755)
35 try:
36- self.branch(source, dest_dir)
37+ self.branch(source, dest_dir, revno)
38 except OSError as e:
39 raise UnhandledSource(e.strerror)
40 return dest_dir

Subscribers

People subscribed via source and target branches