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
1=== modified file 'docs/HISTORY.txt'
2--- docs/HISTORY.txt 2009-04-21 05:57:48 +0000
3+++ docs/HISTORY.txt 2009-06-06 15:36:39 +0000
4@@ -4,7 +4,19 @@
5
6 gf.recipe.bzr - 1.0dev Unreleased
7
8- - ...
9+ - Add support for specifying 'shared-repo' and 'format', which is
10+ useful for branching inside a bzr branch and making it fast for
11+ subsequent large branches from the same repo, or 'rich-root'
12+ branches inside non-rich-root branches.
13+ [sidnei]
14+
15+ - Use 'shell=true' to subprocess and then call just 'bzr' instead
16+ of 'bzr.bat'. The shell will figure out the extension for us.
17+ [sidnei]
18+
19+ - Allow specifying a revisionspec for a branch in the url, using
20+ '@', just like in subversion.
21+ [sidnei]
22
23 gf.recipe.bzr - 1.0rc3 Released 2009-04-21
24
25
26=== modified file 'gf/recipe/bzr/bzr.py'
27--- gf/recipe/bzr/bzr.py 2009-04-21 05:56:47 +0000
28+++ gf/recipe/bzr/bzr.py 2009-06-06 15:26:04 +0000
29@@ -1,13 +1,18 @@
30
31-import logging, os, sys, zc.buildout, subprocess, re
32-
33-
34-if sys.platform == 'win32':
35- BZR = 'bzr.bat'
36-else:
37- BZR = 'bzr'
38-
39+import re
40+import os
41+import sys
42+import urlparse
43 import shutil
44+import subprocess
45+import logging
46+import zc.buildout
47+
48+# No need to specify '.bat' or '.exe' extension on Windows, PATHEXT
49+# will take care of it.
50+BZR = 'bzr'
51+is_win32 = sys.platform == "win32"
52+
53
54 def execute(cmd, logger):
55 logger.debug('Calling bazaar in %s:\n %s',
56@@ -16,9 +21,11 @@
57 # (if you use password authentication, install pycurl
58 # and specify the newlines in .netrc
59 proc = subprocess.Popen(cmd.split(),
60+ shell=True,
61 stdin=subprocess.PIPE,
62 stdout=subprocess.PIPE,
63- stderr=subprocess.PIPE)
64+ stderr=subprocess.PIPE,
65+ close_fds=not is_win32)
66 stdout, stderr = proc.communicate(input="\n\n\n")
67 return stdout, stderr
68
69@@ -62,12 +69,14 @@
70 def __init__(self, buildout, name, options):
71 self.buildout, self.name, self.options = buildout, name, options
72 self.setup_logging()
73+
74 in_parts = options.get('in_parts', 'False')
75 if in_parts not in ('True', 'False', 'true', 'false'):
76 self.logger.error(
77 'Bad in_parts parameter "%s", allowed values: True or False',
78 in_parts)
79 raise zc.buildout.UserError('Bad in_parts parameter')
80+
81 options['develop'] = develop = options.get('develop', 'True')
82 if develop not in ('True', 'False', 'true', 'false'):
83 self.logger.error(
84@@ -75,6 +84,15 @@
85 develop)
86 raise zc.buildout.UserError('Bad develop parameter')
87
88+ options['shared-repo'] = shared_repo = options.get('shared-repo', 'False')
89+ if shared_repo not in ('True', 'False', 'true', 'false'):
90+ self.logger.error(
91+ 'Bad shared_repo parameter "%s", allowed values: True or False',
92+ shared_repo)
93+ raise zc.buildout.UserError('Bad shared_repo parameter')
94+
95+ options['format'] = format = options.get('format', '')
96+
97 root_dir = buildout['buildout']['directory']
98 if in_parts.capitalize() == 'True':
99 root_dir = os.path.join(root_dir, 'parts')
100@@ -94,10 +112,20 @@
101
102 # Add password (if any) to location
103 repo = add_password(self.options, repo)
104- #
105+
106+ # See if there's a revisionspec specified as part of the URL
107+ revspec = None
108+ (scheme, netloc, path, query, fragment) = urlparse.urlsplit(repo)
109+ parts = path.rsplit("@", 1)
110+ if len(parts) > 1:
111+ path, revspec = parts
112+ repo = urlparse.urlunsplit(
113+ (scheme, netloc, path, query, fragment))
114+
115 branches.append(dict(
116 egg = egg,
117 repo = repo,
118+ revspec = revspec,
119 path = os.path.join(root_dir, egg),
120 ))
121 self.branches = branches
122@@ -115,7 +143,14 @@
123 def install(self):
124 root_dir = self.options['root_dir']
125 if not os.path.isdir(root_dir):
126- os.mkdir(root_dir)
127+ if self.options.get('shared-repo', 'false') in ('True', 'true'):
128+ cmd = BZR + ' init-repo'
129+ if self.options.get('format'):
130+ cmd = cmd + ' --format=%s' % self.options['format']
131+ cmd = cmd + ' %s' % root_dir
132+ stdout, stderr = self.execute(cmd)
133+ else:
134+ os.mkdir(root_dir)
135
136 # process required branches
137 for branch in self.branches:
138@@ -152,6 +187,8 @@
139
140 # Getting by calling bazaar
141 cmd = BZR + ' get %(repo)s %(path)s' % branch
142+ if branch.get('revspec') is not None:
143+ cmd += ' -r%(revspec)s' % branch
144 stdout, stderr = self.execute(cmd)
145
146 # check for errors
147@@ -169,6 +206,8 @@
148 try:
149 # Do the pull now, just to remember the location
150 cmd = BZR + ' pull --remember %(repo)s' % branch
151+ if branch.get('revspec') is not None:
152+ cmd += ' -r%(revspec)s' % branch
153 success = self.bzr_pull(cmd, branch)
154 except zc.buildout.UserError:
155 success = False
156@@ -200,6 +239,8 @@
157
158 # Do the pull now
159 cmd = '%s pull %s' % (BZR, location)
160+ if branch.get('revspec') is not None:
161+ cmd += ' -r%(revspec)s' % branch
162 status = self.bzr_pull(cmd, branch)
163 return status
164

Subscribers

People subscribed via source and target branches