Merge lp:~mterry/quickly/revert-bzr into lp:quickly
- revert-bzr
- Merge into trunk
Proposed by
Michael Terry
Status: | Merged |
---|---|
Merged at revision: | 540 |
Proposed branch: | lp:~mterry/quickly/revert-bzr |
Merge into: | lp:quickly |
Diff against target: |
376 lines (+91/-110) 7 files modified
NEWS (+3/-2) data/templates/ubuntu-application/create.py (+6/-5) data/templates/ubuntu-application/internal/packaging.py (+9/-5) data/templates/ubuntu-application/internal/quicklyutils.py (+30/-40) data/templates/ubuntu-application/save.py (+7/-12) data/templates/ubuntu-application/upgrade.py (+11/-9) quickly/bzrbinding.py (+25/-37) |
To merge this branch: | bzr merge lp:~mterry/quickly/revert-bzr |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Didier Roche-Tolomelli | Approve | ||
Review via email: mp+36860@code.launchpad.net |
Commit message
Description of the change
The change to use bzr internal bindings caused some issues (bug 648496, bug 642455, perhaps others?). This close to Ubuntu 10.10, it would be nice to go back to known-working code. This branch reverts the bzr changes.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'NEWS' |
2 | --- NEWS 2010-09-25 13:27:43 +0000 |
3 | +++ NEWS 2010-09-28 13:10:59 +0000 |
4 | @@ -1,11 +1,12 @@ |
5 | Quickly 0.6.1 |
6 | ------------------------------------ |
7 | |
8 | + quickly core: |
9 | + - revert internal bzr calls to use subprocess calls again (Michael Terry) |
10 | ubuntu-application-template and derivatives: |
11 | - - fix release command crashing and revert to get back lost features from |
12 | - previous version (LP: #642455) |
13 | - don't overwrite files in add command if already exists (Tony Byrne) |
14 | (LP: #645490) |
15 | + - revert internal bzr calls to use subprocess calls again (Michael Terry) |
16 | |
17 | Quickly 0.6 |
18 | ------------------------------------ |
19 | |
20 | === modified file 'data/templates/ubuntu-application/create.py' |
21 | --- data/templates/ubuntu-application/create.py 2010-08-13 15:04:05 +0000 |
22 | +++ data/templates/ubuntu-application/create.py 2010-09-28 13:10:59 +0000 |
23 | @@ -18,6 +18,7 @@ |
24 | |
25 | import sys |
26 | import os |
27 | +import shutil |
28 | import subprocess |
29 | |
30 | from quickly import templatetools |
31 | @@ -107,11 +108,11 @@ |
32 | |
33 | # add it to revision control |
34 | print _("Creating bzr repository and commiting") |
35 | -from bzrlib.bzrdir import BzrDir |
36 | -branch = BzrDir.create_branch_convenience(".") |
37 | -wt = branch.bzrdir.open_workingtree() |
38 | -wt.smart_add(["."]) |
39 | -wt.commit("Initial project creation with Quickly!") |
40 | +bzr_instance = subprocess.Popen(["bzr", "init"], stdout=subprocess.PIPE) |
41 | +bzr_instance.wait() |
42 | +bzr_instance = subprocess.Popen(["bzr", "add"], stdout=subprocess.PIPE) |
43 | +bzr_instance.wait() |
44 | +subprocess.Popen(["bzr", "commit", "-m", "Initial project creation with Quickly!"], stderr=subprocess.PIPE) |
45 | |
46 | # run the new application if X display |
47 | if templatetools.is_X_display() and os.path.isfile(exec_file): |
48 | |
49 | === modified file 'data/templates/ubuntu-application/internal/packaging.py' |
50 | --- data/templates/ubuntu-application/internal/packaging.py 2010-08-13 15:04:05 +0000 |
51 | +++ data/templates/ubuntu-application/internal/packaging.py 2010-09-28 13:10:59 +0000 |
52 | @@ -19,8 +19,8 @@ |
53 | import re |
54 | import subprocess |
55 | import sys |
56 | +from launchpadlib.errors import HTTPError |
57 | |
58 | -from bzrlib.workingtree import WorkingTree |
59 | |
60 | from quickly import configurationhandler |
61 | from quickly import launchpadaccess |
62 | @@ -193,11 +193,15 @@ |
63 | |
64 | # check if first python-mkdebian (debian/ creation) to commit it |
65 | # that means debian/ under unknown |
66 | - wt = WorkingTree.open(".") |
67 | + bzr_instance = subprocess.Popen(["bzr", "status"], stdout=subprocess.PIPE) |
68 | + bzr_status, err = bzr_instance.communicate() |
69 | + if bzr_instance.returncode != 0: |
70 | + return(bzr_instance.returncode) |
71 | |
72 | - if any(filter(lambda x: x.startswith("debian/"), wt.unknowns())): |
73 | - wt.smart_add(["."]) |
74 | - wt.commit('Creating ubuntu package') |
75 | + if re.match('(.|\n)*unknown:\n.*debian/(.|\n)*', bzr_status): |
76 | + return_code = filter_exec_command(["bzr", "add"]) |
77 | + if return_code == 0: |
78 | + return_code = filter_exec_command(["bzr", "commit", "-m", 'Creating ubuntu package']) |
79 | |
80 | return(return_code) |
81 | |
82 | |
83 | === modified file 'data/templates/ubuntu-application/internal/quicklyutils.py' |
84 | --- data/templates/ubuntu-application/internal/quicklyutils.py 2010-09-25 13:26:58 +0000 |
85 | +++ data/templates/ubuntu-application/internal/quicklyutils.py 2010-09-28 13:10:59 +0000 |
86 | @@ -15,15 +15,8 @@ |
87 | #You should have received a copy of the GNU General Public License along |
88 | #with this program. If not, see <http://www.gnu.org/licenses/>. |
89 | |
90 | -from bzrlib.config import ( |
91 | - GlobalConfig, |
92 | - extract_email_address, |
93 | - ) |
94 | -from bzrlib.errors import ( |
95 | - NoEmailInUsername, |
96 | - ) |
97 | - |
98 | import os |
99 | +import re |
100 | import sys |
101 | import subprocess |
102 | from xml.etree import ElementTree as etree |
103 | @@ -216,6 +209,7 @@ |
104 | buffered_message +=' %s' % line |
105 | return(changelog) |
106 | |
107 | + |
108 | def get_quickly_editors(): |
109 | '''Return prefered editor for ubuntu-application template''' |
110 | |
111 | @@ -227,30 +221,32 @@ |
112 | editor = default_editor |
113 | return editor |
114 | |
115 | -def append_email_address(email_list, name): |
116 | - '''Append email adress if something to append''' |
117 | - |
118 | - email = None |
119 | - if name: |
120 | - email = extract_email_address(name) |
121 | - if email: |
122 | - email_list.append(email) |
123 | - return email_list |
124 | + |
125 | +def take_email_from_string(value): |
126 | + '''Try to take an email from a string''' |
127 | + |
128 | + if value is not None: |
129 | + result = re.match("(.*[< ]|^)(.+@[^ >]+\.[^ >]+).*", value) |
130 | + if result: |
131 | + return result.groups()[1] |
132 | + return value |
133 | |
134 | def get_all_emails(launchpad=None): |
135 | '''Return a list with all available email in preference order''' |
136 | |
137 | email_list = [] |
138 | - email_list = append_email_address(email_list, os.getenv("DEBEMAIL")) |
139 | + email_list.append(take_email_from_string(os.getenv("DEBEMAIL"))) |
140 | |
141 | - bzr_config = GlobalConfig() |
142 | - email_list.append(bzr_config.user_email()) |
143 | - email_list = append_email_address(email_list, os.getenv("EMAIL")) |
144 | + bzr_instance = subprocess.Popen(["bzr", "whoami"], stdout=subprocess.PIPE) |
145 | + bzr_user, err = bzr_instance.communicate() |
146 | + if bzr_instance.returncode == 0: |
147 | + email_list.append(take_email_from_string(bzr_user)) |
148 | + email_list.append(take_email_from_string(os.getenv("EMAIL"))) |
149 | |
150 | # those information can be missing if there were no packaging or license |
151 | # command before |
152 | try: |
153 | - email_list = append_email_address(email_list, get_setup_value('author_email')) |
154 | + email_list.append(take_email_from_string(get_setup_value('author_email'))) |
155 | except cant_deal_with_setup_value: |
156 | pass |
157 | |
158 | @@ -258,7 +254,7 @@ |
159 | fauthors_name = 'AUTHORS' |
160 | for line in file(fauthors_name, 'r'): |
161 | if not "<Your E-mail>" in line: |
162 | - email_list = append_email_address(email_list, line) |
163 | + email_list.append(take_email_from_string(line)) |
164 | |
165 | # LP adresses |
166 | if launchpad: |
167 | @@ -271,7 +267,7 @@ |
168 | raise gpg_error(err) |
169 | for line in result.splitlines(): |
170 | if 'sec' in line or 'uid' in line: |
171 | - email_list = append_email_address(email_list, line.split(':')[9]) |
172 | + email_list.append(take_email_from_string(line.split(':')[9])) |
173 | |
174 | # return email list without None elem |
175 | return [email for email in email_list if email] |
176 | @@ -343,22 +339,16 @@ |
177 | secret_key_id = line.split(':')[4][-8:] |
178 | if verbose: |
179 | print "found secret gpg key. id: %s" % secret_key_id |
180 | - try: |
181 | - candidate_string = line.split(':')[9] |
182 | - if candidate_string: |
183 | - candidate_email = extract_email_address(candidate_string) |
184 | - except NoEmailInUsername: |
185 | - pass |
186 | - else: |
187 | - if verbose: |
188 | - print "candidate email: %s" % candidate_email |
189 | - if candidate_email in prefered_emails: |
190 | - # create candidate_key_ids[candidate_email] if needed |
191 | - try: |
192 | - candidate_key_ids[candidate_email] |
193 | - except KeyError: |
194 | - candidate_key_ids[candidate_email] = [] |
195 | - candidate_key_ids[candidate_email].append(secret_key_id) |
196 | + candidate_email = take_email_from_string(line.split(':')[9]) |
197 | + if verbose: |
198 | + print "candidate email: %s" % candidate_email |
199 | + if candidate_email and candidate_email in prefered_emails: |
200 | + # create candidate_key_ids[candidate_email] if needed |
201 | + try: |
202 | + candidate_key_ids[candidate_email] |
203 | + except KeyError: |
204 | + candidate_key_ids[candidate_email] = [] |
205 | + candidate_key_ids[candidate_email].append(secret_key_id) |
206 | if not candidate_key_ids: |
207 | candidate_key_ids[prefered_emails[0]] = [create_gpg_key( |
208 | launchpad.me.display_name, prefered_emails[0])] |
209 | |
210 | === modified file 'data/templates/ubuntu-application/save.py' |
211 | --- data/templates/ubuntu-application/save.py 2010-08-13 15:04:05 +0000 |
212 | +++ data/templates/ubuntu-application/save.py 2010-09-28 13:10:59 +0000 |
213 | @@ -18,6 +18,7 @@ |
214 | |
215 | |
216 | import sys |
217 | +import subprocess |
218 | |
219 | import gettext |
220 | from gettext import gettext as _ |
221 | @@ -25,9 +26,6 @@ |
222 | |
223 | from quickly import templatetools |
224 | |
225 | -from bzrlib.errors import PointlessCommit |
226 | -from bzrlib.workingtree import WorkingTree |
227 | - |
228 | def help(): |
229 | print _("""Usage: |
230 | $quickly save notes about changes |
231 | @@ -46,14 +44,11 @@ |
232 | if commit_msg == "": |
233 | commit_msg = _('quickly saved') |
234 | |
235 | -wt = WorkingTree.open(".") |
236 | - |
237 | #save away |
238 | -wt.smart_add(["."]) |
239 | -try: |
240 | - wt.commit(commit_msg) |
241 | -except PointlessCommit: |
242 | +subprocess.call(["bzr", "add"]) |
243 | +return_code = subprocess.call(["bzr", "commit", "-m" + commit_msg]) |
244 | +if return_code == 3: |
245 | print _("It seems that you have no change to record.") |
246 | - sys.exit(1) |
247 | - |
248 | -sys.exit(0) |
249 | + |
250 | +sys.exit(return_code) |
251 | + |
252 | |
253 | === modified file 'data/templates/ubuntu-application/upgrade.py' |
254 | --- data/templates/ubuntu-application/upgrade.py 2010-08-13 18:59:56 +0000 |
255 | +++ data/templates/ubuntu-application/upgrade.py 2010-09-28 13:10:59 +0000 |
256 | @@ -17,12 +17,12 @@ |
257 | #with this program. If not, see <http://www.gnu.org/licenses/>. |
258 | |
259 | import os |
260 | +import shutil |
261 | +import subprocess |
262 | import sys |
263 | |
264 | import internal.apportutils |
265 | |
266 | -from bzrlib.workingtree import WorkingTree |
267 | - |
268 | from internal import quicklyutils |
269 | from quickly import configurationhandler, templatetools |
270 | |
271 | @@ -53,15 +53,17 @@ |
272 | |
273 | ##### 0.4 update |
274 | if project_version < '0.4': |
275 | - wt = WorkingTree.open('.') |
276 | ## new licensing format |
277 | if os.path.isfile("LICENSE"): |
278 | - try: |
279 | - wt.rename_one("LICENSE", "COPYING") |
280 | - except OSError, e: |
281 | - if e.errno == 13: |
282 | - sys.stderr.write(_("Can't rename LICENSE file, check your file permission\n")) |
283 | - sys.exit(1) |
284 | + bzr_instance = subprocess.Popen(["bzr", "mv", "LICENSE", "COPYING"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
285 | + # if file not versionned, try traditional move, (bzr returncode is None if dir not writable) |
286 | + if bzr_instance.returncode == 3 or bzr_instance.returncode is None: |
287 | + try: |
288 | + os.rename('LICENSE', 'COPYING') |
289 | + except OSError, e: |
290 | + if e.errno == 13: |
291 | + sys.stderr.write(_("Can't rename LICENSE file, check your file permission\n")) |
292 | + sys.exit(1) |
293 | # transition Copyright -> AUTHORS |
294 | if os.path.isfile('AUTHORS'): |
295 | source_file = 'AUTHORS' |
296 | |
297 | === modified file 'quickly/bzrbinding.py' |
298 | --- quickly/bzrbinding.py 2010-08-13 15:50:57 +0000 |
299 | +++ quickly/bzrbinding.py 2010-09-28 13:10:59 +0000 |
300 | @@ -15,7 +15,8 @@ |
301 | #You should have received a copy of the GNU General Public License along |
302 | #with this program. If not, see <http://www.gnu.org/licenses/>. |
303 | |
304 | -from gettext import gettext as _ |
305 | +import socket |
306 | +import subprocess |
307 | |
308 | def bzr_set_login(display_name, preferred_email_adress, launchpad_name=None): |
309 | ''' try to setup bzr whoami for commit and sshing and bzr launchpad_login if provided |
310 | @@ -23,44 +24,31 @@ |
311 | launchpadname is optional if you don't want user to use launchpad in your template |
312 | if already setup, it will not overwrite existing data |
313 | ''' |
314 | - try: |
315 | - import bzrlib.config |
316 | - from bzrlib.errors import ( |
317 | - BzrError, |
318 | - ) |
319 | - except ImportError, e: |
320 | - return (1, _("Bzr not properly installed %s" % e)) |
321 | - |
322 | - config = bzrlib.config.GlobalConfig() |
323 | - |
324 | - # retrieve the current bzr login |
325 | - try: |
326 | - bzr_user = config.username() |
327 | - except BzrError, err: |
328 | - try: |
329 | - from bzrlib.errors import NoWhoami |
330 | - except ImportError: |
331 | + |
332 | + try: |
333 | + |
334 | + # retreive the current bzr login |
335 | + bzr_instance = subprocess.Popen(["bzr", "whoami"], stdout=subprocess.PIPE) |
336 | + bzr_user, err = bzr_instance.communicate() |
337 | + if bzr_instance.returncode != 0: |
338 | return (1, err) |
339 | - else: |
340 | - if isinstance(err, NoWhoami): |
341 | - # no bzr whoami set |
342 | - identifier = display_name + ' <' + preferred_email_adress + '>' |
343 | - config.set_user_option("email", identifier) |
344 | - else: |
345 | + |
346 | + # if no bzr whoami set, the default contain the @hostname string |
347 | + if '@' + socket.gethostname() in bzr_user: |
348 | + identifier = display_name + ' <' + preferred_email_adress + '>' |
349 | + subprocess.call(["bzr", "whoami", identifier]) |
350 | + |
351 | + # if no bzr launchpad-login set, set it now ! |
352 | + if launchpad_name: |
353 | + bzr_instance = subprocess.Popen(["bzr", "launchpad-login"], stdout=subprocess.PIPE) |
354 | + bzr_id, err = bzr_instance.communicate() |
355 | + if bzr_instance.returncode == 1: # no user configured |
356 | + subprocess.call(["bzr", "launchpad-login", launchpad_name]) |
357 | + elif bzr_instance.returncode != 0: # other errors |
358 | return (1, err) |
359 | |
360 | - # if no bzr launchpad-login set, set it now ! |
361 | - if launchpad_name: |
362 | - from bzrlib.plugins.launchpad import account |
363 | - stored_username = account.get_lp_login() |
364 | - if stored_username is not None: |
365 | - # No account set yet |
366 | - launchpad_name = launchpad_name.lower() |
367 | - account.check_lp_login(launchpad_name) |
368 | - account.set_lp_login(launchpad_name) |
369 | - elif stored_username != launchpad_name: |
370 | - return (1, |
371 | - _("Stored username %s and specified username %s mismatch." % ( |
372 | - stored_username, launchpad_name))) |
373 | + except OSError: |
374 | + return (1, _("Bzr not properly installed")) |
375 | + |
376 | return (0, "") |
377 |
looks good. Will give extend testing before releasing 0.6.1