summaryrefslogtreecommitdiff
path: root/lorry
diff options
context:
space:
mode:
authorBen Hutchings <ben.hutchings@codethink.co.uk>2020-07-09 19:49:36 +0100
committerBen Hutchings <ben.hutchings@codethink.co.uk>2020-07-09 23:20:25 +0100
commit4fe8ec373ec8005fe34eb584e53fc8215e9bb995 (patch)
treec218e446b011baa637c068a4bd2f7d3042079b0d /lorry
parent63ecde7b965ccb19c5cbec15a2bae2e54a0de9d5 (diff)
downloadlorry-4fe8ec373ec8005fe34eb584e53fc8215e9bb995.tar.gz
Add support for Breezy (brz) as alternative Bazaar implementation
The original Bazaar implementation (bzr) only runs on Python 2, but there is a fork known as Breezy (brz) that has been ported to Python 3. To support environments without Python 2, allow using Breezy: * Add a setting 'bazaar-command' that specifies which command to run * Set the default based on a path search, preferring 'bzr' but using 'brz' if only 'brz' is found * Implement a similar fallback in the test setup for Bazaar import * Update README to mention Breezy as an alternative. The 'fastimport' extension is included in it rather than being a separate package. Closes #3.
Diffstat (limited to 'lorry')
-rwxr-xr-xlorry31
1 files changed, 27 insertions, 4 deletions
diff --git a/lorry b/lorry
index 90257b1..0318ef8 100755
--- a/lorry
+++ b/lorry
@@ -26,6 +26,7 @@ from datetime import datetime
import shutil
import traceback
import functools
+import stat
import yaml
@@ -52,6 +53,22 @@ def quote_url(url):
return ''.join([transl(x) for x in url])
+def find_exec_in_path(name):
+ for dir_name in os.environ['PATH'].split(os.pathsep):
+ file_name = os.path.join(dir_name, name)
+ try:
+ file_stat = os.stat(file_name)
+ except OSError:
+ continue
+ if stat.S_ISREG(file_stat.st_mode) and file_stat.st_mode & 0o111:
+ return file_name
+ return None
+
+
+def find_bazaar_command():
+ return find_exec_in_path('bzr') or find_exec_in_path('brz')
+
+
class Lorry(cliapp.Application):
def add_settings(self):
@@ -101,6 +118,10 @@ class Lorry(cliapp.Application):
self.settings.string_list(['push-option'],
"option for 'git push' to pass to the "
'remote server')
+ self.settings.string(['bazaar-command'],
+ 'command used to access Bazaar repositories',
+ metavar='COMMAND',
+ default=find_bazaar_command())
def process_args(self, args):
status = 0
@@ -334,11 +355,13 @@ class Lorry(cliapp.Application):
self.run_program(argv, cwd=gitdir, env=env)
def gitify_bzr(self, project_name, dirname, gitdir, spec):
+ bzr = self.settings['bazaar-command']
+
bzrdir = os.path.join(dirname, 'bzr')
# check if repo exists
if not os.path.exists(bzrdir):
self.progress('.. creating bzr repository')
- self.run_program(['bzr', 'init-repo', '--no-trees', bzrdir])
+ self.run_program([bzr, 'init-repo', '--no-trees', bzrdir])
if not os.path.exists(gitdir):
self.progress('.. creating git repo')
@@ -360,12 +383,12 @@ class Lorry(cliapp.Application):
if not os.path.exists(branchdir):
self.progress('.. doing initial bzr branch')
self.run_program(
- ['bzr', 'branch', '--quiet', '-Ossl.cert_reqs=none',
+ [bzr, 'branch', '--quiet', '-Ossl.cert_reqs=none',
address, branchdir])
else:
self.progress('.. updating bzr branch')
self.run_program(
- ['bzr', 'pull', '--quiet', '-Ossl.cert_reqs=none',
+ [bzr, 'pull', '--quiet', '-Ossl.cert_reqs=none',
address],
cwd=branchdir)
@@ -375,7 +398,7 @@ class Lorry(cliapp.Application):
branchdir = os.path.join(bzrdir, branch)
self.progress('.. fast-exporting branch %s from bzr' % branch)
exports[branch] = os.path.join(dirname, 'fast-export' + branch)
- cmdline = ['bzr', 'fast-export', '--git-branch=' + branch,
+ cmdline = [bzr, 'fast-export', '--git-branch=' + branch,
branchdir, exports[branch]]
if os.path.exists(bzrmarks):
cmdline.append('--marks=' + bzrmarks)