Merge lp://staging/~sidnei/gf.recipe.bzr/revisionspec-in-url into lp://staging/~ree/gf.recipe.bzr/trunk

Proposed by Sidnei da Silva
Status: Merged
Merged at revision: not available
Proposed branch: lp://staging/~sidnei/gf.recipe.bzr/revisionspec-in-url
Merge into: lp://staging/~ree/gf.recipe.bzr/trunk
Diff against target: None lines
To merge this branch: bzr merge lp://staging/~sidnei/gf.recipe.bzr/revisionspec-in-url
Reviewer Review Type Date Requested Status
Balazs Ree Approve
Review via email: mp+7149@code.staging.launchpad.net
To post a comment you must log in.
Revision history for this message
Sidnei da Silva (sidnei) wrote :

- Adds support for revisionspec in the URL, by using '@' just like in subversion.

Revision history for this message
Balazs Ree (ree) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'docs/HISTORY.txt'
--- docs/HISTORY.txt 2009-04-21 05:57:48 +0000
+++ docs/HISTORY.txt 2009-06-06 15:36:39 +0000
@@ -4,7 +4,19 @@
44
5gf.recipe.bzr - 1.0dev Unreleased5gf.recipe.bzr - 1.0dev Unreleased
66
7 - ...7 - Add support for specifying 'shared-repo' and 'format', which is
8 useful for branching inside a bzr branch and making it fast for
9 subsequent large branches from the same repo, or 'rich-root'
10 branches inside non-rich-root branches.
11 [sidnei]
12
13 - Use 'shell=true' to subprocess and then call just 'bzr' instead
14 of 'bzr.bat'. The shell will figure out the extension for us.
15 [sidnei]
16
17 - Allow specifying a revisionspec for a branch in the url, using
18 '@', just like in subversion.
19 [sidnei]
820
9gf.recipe.bzr - 1.0rc3 Released 2009-04-2121gf.recipe.bzr - 1.0rc3 Released 2009-04-21
1022
1123
=== modified file 'gf/recipe/bzr/bzr.py'
--- gf/recipe/bzr/bzr.py 2009-04-21 05:56:47 +0000
+++ gf/recipe/bzr/bzr.py 2009-06-06 15:26:04 +0000
@@ -1,13 +1,18 @@
11
2import logging, os, sys, zc.buildout, subprocess, re2import re
33import os
44import sys
5if sys.platform == 'win32':5import urlparse
6 BZR = 'bzr.bat'
7else:
8 BZR = 'bzr'
9
10import shutil6import shutil
7import subprocess
8import logging
9import zc.buildout
10
11# No need to specify '.bat' or '.exe' extension on Windows, PATHEXT
12# will take care of it.
13BZR = 'bzr'
14is_win32 = sys.platform == "win32"
15
1116
12def execute(cmd, logger):17def execute(cmd, logger):
13 logger.debug('Calling bazaar in %s:\n %s', 18 logger.debug('Calling bazaar in %s:\n %s',
@@ -16,9 +21,11 @@
16 # (if you use password authentication, install pycurl21 # (if you use password authentication, install pycurl
17 # and specify the newlines in .netrc22 # and specify the newlines in .netrc
18 proc = subprocess.Popen(cmd.split(),23 proc = subprocess.Popen(cmd.split(),
24 shell=True,
19 stdin=subprocess.PIPE,25 stdin=subprocess.PIPE,
20 stdout=subprocess.PIPE,26 stdout=subprocess.PIPE,
21 stderr=subprocess.PIPE)27 stderr=subprocess.PIPE,
28 close_fds=not is_win32)
22 stdout, stderr = proc.communicate(input="\n\n\n")29 stdout, stderr = proc.communicate(input="\n\n\n")
23 return stdout, stderr30 return stdout, stderr
2431
@@ -62,12 +69,14 @@
62 def __init__(self, buildout, name, options):69 def __init__(self, buildout, name, options):
63 self.buildout, self.name, self.options = buildout, name, options70 self.buildout, self.name, self.options = buildout, name, options
64 self.setup_logging()71 self.setup_logging()
72
65 in_parts = options.get('in_parts', 'False')73 in_parts = options.get('in_parts', 'False')
66 if in_parts not in ('True', 'False', 'true', 'false'):74 if in_parts not in ('True', 'False', 'true', 'false'):
67 self.logger.error(75 self.logger.error(
68 'Bad in_parts parameter "%s", allowed values: True or False',76 'Bad in_parts parameter "%s", allowed values: True or False',
69 in_parts)77 in_parts)
70 raise zc.buildout.UserError('Bad in_parts parameter')78 raise zc.buildout.UserError('Bad in_parts parameter')
79
71 options['develop'] = develop = options.get('develop', 'True')80 options['develop'] = develop = options.get('develop', 'True')
72 if develop not in ('True', 'False', 'true', 'false'):81 if develop not in ('True', 'False', 'true', 'false'):
73 self.logger.error(82 self.logger.error(
@@ -75,6 +84,15 @@
75 develop)84 develop)
76 raise zc.buildout.UserError('Bad develop parameter')85 raise zc.buildout.UserError('Bad develop parameter')
7786
87 options['shared-repo'] = shared_repo = options.get('shared-repo', 'False')
88 if shared_repo not in ('True', 'False', 'true', 'false'):
89 self.logger.error(
90 'Bad shared_repo parameter "%s", allowed values: True or False',
91 shared_repo)
92 raise zc.buildout.UserError('Bad shared_repo parameter')
93
94 options['format'] = format = options.get('format', '')
95
78 root_dir = buildout['buildout']['directory']96 root_dir = buildout['buildout']['directory']
79 if in_parts.capitalize() == 'True':97 if in_parts.capitalize() == 'True':
80 root_dir = os.path.join(root_dir, 'parts')98 root_dir = os.path.join(root_dir, 'parts')
@@ -94,10 +112,20 @@
94112
95 # Add password (if any) to location113 # Add password (if any) to location
96 repo = add_password(self.options, repo)114 repo = add_password(self.options, repo)
97 #115
116 # See if there's a revisionspec specified as part of the URL
117 revspec = None
118 (scheme, netloc, path, query, fragment) = urlparse.urlsplit(repo)
119 parts = path.rsplit("@", 1)
120 if len(parts) > 1:
121 path, revspec = parts
122 repo = urlparse.urlunsplit(
123 (scheme, netloc, path, query, fragment))
124
98 branches.append(dict(125 branches.append(dict(
99 egg = egg, 126 egg = egg,
100 repo = repo,127 repo = repo,
128 revspec = revspec,
101 path = os.path.join(root_dir, egg),129 path = os.path.join(root_dir, egg),
102 )) 130 ))
103 self.branches = branches131 self.branches = branches
@@ -115,7 +143,14 @@
115 def install(self):143 def install(self):
116 root_dir = self.options['root_dir']144 root_dir = self.options['root_dir']
117 if not os.path.isdir(root_dir):145 if not os.path.isdir(root_dir):
118 os.mkdir(root_dir)146 if self.options.get('shared-repo', 'false') in ('True', 'true'):
147 cmd = BZR + ' init-repo'
148 if self.options.get('format'):
149 cmd = cmd + ' --format=%s' % self.options['format']
150 cmd = cmd + ' %s' % root_dir
151 stdout, stderr = self.execute(cmd)
152 else:
153 os.mkdir(root_dir)
119154
120 # process required branches155 # process required branches
121 for branch in self.branches:156 for branch in self.branches:
@@ -152,6 +187,8 @@
152187
153 # Getting by calling bazaar188 # Getting by calling bazaar
154 cmd = BZR + ' get %(repo)s %(path)s' % branch189 cmd = BZR + ' get %(repo)s %(path)s' % branch
190 if branch.get('revspec') is not None:
191 cmd += ' -r%(revspec)s' % branch
155 stdout, stderr = self.execute(cmd)192 stdout, stderr = self.execute(cmd)
156193
157 # check for errors194 # check for errors
@@ -169,6 +206,8 @@
169 try:206 try:
170 # Do the pull now, just to remember the location207 # Do the pull now, just to remember the location
171 cmd = BZR + ' pull --remember %(repo)s' % branch208 cmd = BZR + ' pull --remember %(repo)s' % branch
209 if branch.get('revspec') is not None:
210 cmd += ' -r%(revspec)s' % branch
172 success = self.bzr_pull(cmd, branch)211 success = self.bzr_pull(cmd, branch)
173 except zc.buildout.UserError:212 except zc.buildout.UserError:
174 success = False213 success = False
@@ -200,6 +239,8 @@
200239
201 # Do the pull now240 # Do the pull now
202 cmd = '%s pull %s' % (BZR, location)241 cmd = '%s pull %s' % (BZR, location)
242 if branch.get('revspec') is not None:
243 cmd += ' -r%(revspec)s' % branch
203 status = self.bzr_pull(cmd, branch)244 status = self.bzr_pull(cmd, branch)
204 return status245 return status
205246

Subscribers

People subscribed via source and target branches