1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
import os
import subprocess
import pytest
from buildstream.plugintestutils import Repo
from .. import site
BZR_ENV = {
"BZR_EMAIL": "Testy McTesterson <testy.mctesterson@example.com>"
}
class Bzr(Repo):
def __init__(self, directory, subdir):
if not site.HAVE_BZR:
pytest.skip("bzr is not available")
super(Bzr, self).__init__(directory, subdir)
self.bzr = site.BZR
def create(self, directory):
branch_dir = os.path.join(self.repo, 'trunk')
subprocess.call([self.bzr, 'init-repo', self.repo], env=BZR_ENV)
subprocess.call([self.bzr, 'init', branch_dir], env=BZR_ENV)
self.copy_directory(directory, branch_dir)
subprocess.call([self.bzr, 'add', '.'], env=BZR_ENV, cwd=branch_dir)
subprocess.call([self.bzr, 'commit', '--message="Initial commit"'],
env=BZR_ENV, cwd=branch_dir)
return self.latest_commit()
def source_config(self, ref=None):
config = {
'kind': 'bzr',
'url': 'file://' + self.repo,
'track': 'trunk'
}
if ref is not None:
config['ref'] = ref
return config
def latest_commit(self):
return subprocess.check_output([
self.bzr, 'version-info',
'--custom', '--template={revno}',
os.path.join(self.repo, 'trunk')
], env=BZR_ENV, universal_newlines=True).strip()
|