Merge lp:~cjwatson/launchpad-buildd/bzr-command-line into lp:launchpad-buildd

Proposed by Colin Watson
Status: Merged
Merged at revision: 243
Proposed branch: lp:~cjwatson/launchpad-buildd/bzr-command-line
Merge into: lp:launchpad-buildd
Diff against target: 147 lines (+24/-45)
4 files modified
debian/changelog (+2/-0)
lpbuildd/pottery/generate_translation_templates.py (+6/-10)
lpbuildd/pottery/tests/test_generate_translation_templates.py (+16/-34)
setup.py (+0/-1)
To merge this branch: bzr merge lp:~cjwatson/launchpad-buildd/bzr-command-line
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+328177@code.launchpad.net

Commit message

Use bzr's command-line interface rather than bzrlib, to ease porting to
Python 3.

To post a comment you must log in.
Revision history for this message
Adam Collard (adam-collard) wrote :

ISTM that we need bzr as a Depends: for the package (rather than just a build-dep as it is now) ?

Revision history for this message
Colin Watson (cjwatson) wrote :

It is weird and confusing, but that code actually runs in the chroot,
and lpbuildd/translationtemplates.py ensures that bzr is installed
there.

Revision history for this message
Adam Collard (adam-collard) wrote :

Ahh, right. Thanks!

Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2017-07-27 15:38:53 +0000
3+++ debian/changelog 2017-07-27 16:13:37 +0000
4@@ -5,6 +5,8 @@
5 * Run tests at build time, now that python-txfixtures is in
6 ppa:launchpad/ubuntu/ppa (and >= zesty).
7 * Add missing dependency on intltool.
8+ * Use bzr's command-line interface rather than bzrlib, to ease porting to
9+ Python 3.
10
11 -- Colin Watson <cjwatson@ubuntu.com> Tue, 25 Jul 2017 23:07:58 +0100
12
13
14=== modified file 'lpbuildd/pottery/generate_translation_templates.py'
15--- lpbuildd/pottery/generate_translation_templates.py 2016-12-09 18:04:00 +0000
16+++ lpbuildd/pottery/generate_translation_templates.py 2017-07-27 16:13:37 +0000
17@@ -1,5 +1,5 @@
18 #! /usr/bin/python
19-# Copyright 2010 Canonical Ltd. This software is licensed under the
20+# Copyright 2010-2017 Canonical Ltd. This software is licensed under the
21 # GNU Affero General Public License version 3 (see the file LICENSE).
22
23 from __future__ import print_function
24@@ -7,14 +7,12 @@
25 __metaclass__ = type
26
27 import os.path
28+import subprocess
29 import sys
30 import tarfile
31
32 import logging
33
34-from bzrlib.branch import Branch
35-from bzrlib.export import export
36-
37 from lpbuildd.pottery import intltool
38
39
40@@ -68,12 +66,10 @@
41 The branch is checked out to the location specified by
42 `self.branch_dir`.
43 """
44- self.logger.info("Opening branch %s..." % branch_url)
45- branch = Branch.open(branch_url)
46- self.logger.info("Getting branch revision tree...")
47- rev_tree = branch.basis_tree()
48- self.logger.info("Exporting branch to %s..." % self.branch_dir)
49- export(rev_tree, self.branch_dir)
50+ self.logger.info(
51+ "Exporting branch %s to %s..." % (branch_url, self.branch_dir))
52+ subprocess.check_call(
53+ ["bzr", "export", "-q", "-d", branch_url, self.branch_dir])
54 self.logger.info("Exporting branch done.")
55
56 def _makeTarball(self, files):
57
58=== modified file 'lpbuildd/pottery/tests/test_generate_translation_templates.py'
59--- lpbuildd/pottery/tests/test_generate_translation_templates.py 2017-05-10 11:26:30 +0000
60+++ lpbuildd/pottery/tests/test_generate_translation_templates.py 2017-07-27 16:13:37 +0000
61@@ -9,15 +9,6 @@
62 import sys
63 import tarfile
64
65-from bzrlib.bzrdir import BzrDir
66-from bzrlib.generate_ids import (
67- gen_file_id,
68- gen_root_id,
69- )
70-from bzrlib.transform import (
71- ROOT_PARENT,
72- TransformPreview,
73- )
74 from fixtures import (
75 EnvironmentVariable,
76 TempDir,
77@@ -76,34 +67,25 @@
78 written to the branch. Currently only supports writing files at
79 the root directory of the branch.
80
81- :return: a tuple of a fresh bzr branch and its URL.
82+ :return: the URL of a fresh bzr branch.
83 """
84- branch_url = 'file://' + self.useFixture(TempDir()).path
85- branch = BzrDir.create_branch_convenience(branch_url)
86+ branch_path = self.useFixture(TempDir()).path
87+ branch_url = 'file://' + branch_path
88+ subprocess.check_call(['bzr', 'init', '-q'], cwd=branch_path)
89
90 if content_map is not None:
91- branch.lock_write()
92- try:
93- revision_tree = branch.basis_tree()
94- transform_preview = TransformPreview(revision_tree)
95- try:
96- root_id = transform_preview.new_directory(
97- '', ROOT_PARENT, gen_root_id())
98- for name, contents in content_map.iteritems():
99- file_id = gen_file_id(name)
100- transform_preview.new_file(
101- name, root_id, [contents], file_id=file_id)
102- committer_id = 'Committer <committer@example.com>'
103- with EnvironmentVariable('BZR_EMAIL', committer_id):
104- transform_preview.commit(
105- branch, 'Populating branch.',
106- committer=committer_id)
107- finally:
108- transform_preview.finalize()
109- finally:
110- branch.unlock()
111+ for name, contents in content_map.iteritems():
112+ with open(os.path.join(branch_path, name), 'wb') as f:
113+ f.write(contents)
114+ subprocess.check_call(
115+ ['bzr', 'add', '-q'] + list(content_map), cwd=branch_path)
116+ committer_id = 'Committer <committer@example.com>'
117+ with EnvironmentVariable('BZR_EMAIL', committer_id):
118+ subprocess.check_call(
119+ ['bzr', 'commit', '-q', '-m', 'Populating branch.'],
120+ cwd=branch_path)
121
122- return branch, branch_url
123+ return branch_url
124
125 def test_getBranch_bzr(self):
126 # _getBranch can retrieve branch contents from a branch URL.
127@@ -113,7 +95,7 @@
128 self.useFixture(EnvironmentVariable('EMAIL'))
129
130 marker_text = "Ceci n'est pas cet branch."
131- branch, branch_url = self._createBranch({'marker.txt': marker_text})
132+ branch_url = self._createBranch({'marker.txt': marker_text})
133
134 generator = GenerateTranslationTemplates(
135 branch_url, self.result_name, self.useFixture(TempDir()).path,
136
137=== modified file 'setup.py'
138--- setup.py 2015-11-11 08:57:21 +0000
139+++ setup.py 2017-07-27 16:13:37 +0000
140@@ -58,7 +58,6 @@
141 maintainer_email='launchpad-dev@lists.launchpad.net',
142 license='Affero GPL v3',
143 install_requires=[
144- 'bzr',
145 # XXX cjwatson 2015-11-04: This does in fact require python-apt, but
146 # that's normally shipped as a system package and specifying it here
147 # causes problems for Launchpad's build system.

Subscribers

People subscribed via source and target branches

to all changes: