Merge lp:~frankban/charms/precise/juju-gui/revision-support into lp:~juju-gui/charms/precise/juju-gui/trunk

Proposed by Francesco Banconi
Status: Merged
Merged at revision: 58
Proposed branch: lp:~frankban/charms/precise/juju-gui/revision-support
Merge into: lp:~juju-gui/charms/precise/juju-gui/trunk
Diff against target: 117 lines (+38/-8)
4 files modified
config.yaml (+2/-1)
hooks/utils.py (+26/-5)
revision (+1/-1)
tests/test_utils.py (+9/-1)
To merge this branch: bzr merge lp:~frankban/charms/precise/juju-gui/revision-support
Reviewer Review Type Date Requested Status
charmers Pending
Review via email: mp+164326@code.launchpad.net

Description of the change

Support juju-gui-source=branch:revno

Added support for creating and deploying
a release from a specific branch revision.

https://codereview.appspot.com/9464043/

To post a comment you must log in.
Revision history for this message
Francesco Banconi (frankban) wrote :
Download full text (5.5 KiB)

Reviewers: mp+164326_code.launchpad.net,

Message:
Please take a look.

Description:
Support juju-gui-source=branch:revno

Added support for creating and deploying
a release from a specific branch revision.

https://code.launchpad.net/~frankban/charms/precise/juju-gui/revision-support/+merge/164326

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/9464043/

Affected files:
   A [revision details]
   M config.yaml
   M hooks/utils.py
   M revision
   M tests/test_utils.py

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision:
<email address hidden>

Index: config.yaml
=== modified file 'config.yaml'
--- config.yaml 2013-05-02 14:57:04 +0000
+++ config.yaml 2013-05-11 00:18:47 +0000
@@ -10,7 +10,8 @@
          will be deployed;
        - a Bazaar branch (e.g. 'lp:juju-gui'): a release will be created and
          deployed from the specified Bazaar branch. 'http://' prefixed
branches
- work as well.
+ work as well. It is also possible to include the specific branch
+ revision, e.g. 'lp:juju-gui:42' will checkout revno 42.
        - a 'url:' prefixed url (ex: url:http://...) of a specific location
          to pull a release from.
      type: string

Index: revision
=== modified file 'revision'
--- revision 2013-05-02 14:57:04 +0000
+++ revision 2013-05-16 13:54:35 +0000
@@ -1,1 +1,1 @@
-45
+46

Index: hooks/utils.py
=== modified file 'hooks/utils.py'
--- hooks/utils.py 2013-05-03 10:37:06 +0000
+++ hooks/utils.py 2013-05-17 09:07:28 +0000
@@ -44,6 +44,7 @@
  import json
  import os
  import logging
+import re
  import shutil
  from subprocess import CalledProcessError
  import tempfile
@@ -211,6 +212,14 @@
          log("<<< Exiting {}".format(script))

+bzr_url_expression = re.compile(r"""
+ ^ # Beginning of line.
+ ((?:lp:|http:\/\/)[^:]+) # Branch URL (scheme + domain/path).
+ (?::(\d+))? # Optional branch revision.
+ $ # End of line.
+""", re.VERBOSE)
+
+
  def parse_source(source):
      """Parse the ``juju-gui-source`` option.

@@ -220,7 +229,9 @@
         - ('stable', '0.1.0'): stable release v0.1.0;
         - ('trunk', None): latest trunk release;
         - ('trunk', '0.1.0+build.1'): trunk release v0.1.0 bzr revision 1;
- - ('branch', 'lp:juju-gui'): release is made from a branch;
+ - ('branch', ('lp:juju-gui', 42): release is made from a branch -
+ in this case the second element includes the branch URL and
revision;
+ - ('branch', ('lp:juju-gui', None): no revision is specified;
         - ('url', 'http://example.com/gui'): release from a downloaded file.
      """
      if source.startswith('url:'):
@@ -233,8 +244,9 @@
          return 'url', source
      if source in ('stable', 'trunk'):
          return source, None
- if source.startswith('lp:') or source.startswith('http://'):
- return 'branch', source
+ match = bzr_url_expression.match(sourc...

Read more...

Revision history for this message
Brad Crittenden (bac) wrote :

LGTM where G=great. Thanks Frankban.

https://codereview.appspot.com/9464043/diff/1/hooks/utils.py
File hooks/utils.py (right):

https://codereview.appspot.com/9464043/diff/1/hooks/utils.py#newcode220
hooks/utils.py:220: """, re.VERBOSE)
If only all regex-es were this well documented. Thanks Francesco!

https://codereview.appspot.com/9464043/

Revision history for this message
Jeff Pihach (hatch) wrote :

LGTM - Thanks for this great upgrade

https://codereview.appspot.com/9464043/

Revision history for this message
Francesco Banconi (frankban) wrote :

*** Submitted:

Support juju-gui-source=branch:revno

Added support for creating and deploying
a release from a specific branch revision.

R=bac, jeff.pihach
CC=
https://codereview.appspot.com/9464043

https://codereview.appspot.com/9464043/

Revision history for this message
Francesco Banconi (frankban) wrote :

Thanks for the reviews Brad and Jeff!

https://codereview.appspot.com/9464043/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.yaml'
2--- config.yaml 2013-05-02 14:57:04 +0000
3+++ config.yaml 2013-05-17 09:13:43 +0000
4@@ -10,7 +10,8 @@
5 will be deployed;
6 - a Bazaar branch (e.g. 'lp:juju-gui'): a release will be created and
7 deployed from the specified Bazaar branch. 'http://' prefixed branches
8- work as well.
9+ work as well. It is also possible to include the specific branch
10+ revision, e.g. 'lp:juju-gui:42' will checkout revno 42.
11 - a 'url:' prefixed url (ex: url:http://...) of a specific location
12 to pull a release from.
13 type: string
14
15=== modified file 'hooks/utils.py'
16--- hooks/utils.py 2013-05-03 10:37:06 +0000
17+++ hooks/utils.py 2013-05-17 09:13:43 +0000
18@@ -44,6 +44,7 @@
19 import json
20 import os
21 import logging
22+import re
23 import shutil
24 from subprocess import CalledProcessError
25 import tempfile
26@@ -211,6 +212,14 @@
27 log("<<< Exiting {}".format(script))
28
29
30+bzr_url_expression = re.compile(r"""
31+ ^ # Beginning of line.
32+ ((?:lp:|http:\/\/)[^:]+) # Branch URL (scheme + domain/path).
33+ (?::(\d+))? # Optional branch revision.
34+ $ # End of line.
35+""", re.VERBOSE)
36+
37+
38 def parse_source(source):
39 """Parse the ``juju-gui-source`` option.
40
41@@ -220,7 +229,9 @@
42 - ('stable', '0.1.0'): stable release v0.1.0;
43 - ('trunk', None): latest trunk release;
44 - ('trunk', '0.1.0+build.1'): trunk release v0.1.0 bzr revision 1;
45- - ('branch', 'lp:juju-gui'): release is made from a branch;
46+ - ('branch', ('lp:juju-gui', 42): release is made from a branch -
47+ in this case the second element includes the branch URL and revision;
48+ - ('branch', ('lp:juju-gui', None): no revision is specified;
49 - ('url', 'http://example.com/gui'): release from a downloaded file.
50 """
51 if source.startswith('url:'):
52@@ -233,8 +244,9 @@
53 return 'url', source
54 if source in ('stable', 'trunk'):
55 return source, None
56- if source.startswith('lp:') or source.startswith('http://'):
57- return 'branch', source
58+ match = bzr_url_expression.match(source)
59+ if match is not None:
60+ return 'branch', match.groups()
61 if 'build' in source:
62 return 'trunk', source
63 return 'stable', source
64@@ -438,14 +450,23 @@
65 # Retrieve a Juju GUI release.
66 origin, version_or_branch = parse_source(juju_gui_source)
67 if origin == 'branch':
68+ branch_url, revision = version_or_branch
69 # Make sure we have the dependencies necessary for us to actually make
70 # a build.
71 _get_build_dependencies()
72 # Create a release starting from a branch.
73 juju_gui_source_dir = os.path.join(CURRENT_DIR, 'juju-gui-source')
74- log('Retrieving Juju GUI source checkout from %s.' % version_or_branch)
75+ if revision is None:
76+ checkout_args = []
77+ revno = 'latest revno'
78+ else:
79+ checkout_args = ['--revision', revision]
80+ revno = 'revno {}'.format(revision)
81+ log('Retrieving Juju GUI source checkout from {} ({}).'.format(
82+ branch_url, revno))
83 cmd_log(run('rm', '-rf', juju_gui_source_dir))
84- cmd_log(bzr_checkout(version_or_branch, juju_gui_source_dir))
85+ checkout_args.extend([branch_url, juju_gui_source_dir])
86+ cmd_log(bzr_checkout(*checkout_args))
87 log('Preparing a Juju GUI release.')
88 logdir = os.path.dirname(logpath)
89 fd, name = tempfile.mkstemp(prefix='make-distfile-', dir=logdir)
90
91=== modified file 'revision'
92--- revision 2013-05-02 14:57:04 +0000
93+++ revision 2013-05-17 09:13:43 +0000
94@@ -1,1 +1,1 @@
95-45
96+46
97
98=== modified file 'tests/test_utils.py'
99--- tests/test_utils.py 2013-05-03 10:37:06 +0000
100+++ tests/test_utils.py 2013-05-17 09:13:43 +0000
101@@ -402,7 +402,15 @@
102 # Ensure a Bazaar branch is correctly parsed.
103 sources = ('lp:example', 'http://bazaar.launchpad.net/example')
104 for source in sources:
105- self.assertTupleEqual(('branch', source), parse_source(source))
106+ expected = ('branch', (source, None))
107+ self.assertEqual(expected, parse_source(source))
108+
109+ def test_bzr_branch_and_revision(self):
110+ # A Bazaar branch is correctly parsed when including revision.
111+ sources = ('lp:example:42', 'http://bazaar.launchpad.net/example:1')
112+ for source in sources:
113+ expected = ('branch', tuple(source.rsplit(':', 1)))
114+ self.assertEqual(expected, parse_source(source))
115
116 def test_url(self):
117 expected = ('url', 'http://example.com/gui')

Subscribers

People subscribed via source and target branches