/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to tests/__init__.py

Avoid invoking git directly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
TestCaseWithTransport = tests.TestCaseWithTransport
36
36
TestCaseWithMemoryTransport = tests.TestCaseWithMemoryTransport
37
37
 
38
 
class _GitCommandFeature(tests.Feature):
39
 
 
40
 
    def _probe(self):
41
 
        try:
42
 
            p = subprocess.Popen(['git', '--version'], stdout=subprocess.PIPE)
43
 
        except IOError:
44
 
            return False
45
 
        out, err = p.communicate()
46
 
        trace.mutter('Using: %s', out.rstrip('\n'))
47
 
        return True
48
 
 
49
 
    def feature_name(self):
50
 
        return 'git'
51
 
 
52
38
class _DulwichFeature(tests.Feature):
53
39
 
54
40
    def _probe(self):
62
48
        return 'dulwich'
63
49
 
64
50
 
65
 
GitCommandFeature = _GitCommandFeature()
66
51
DulwichFeature = _DulwichFeature()
67
52
 
68
53
 
69
 
def run_git(*args):
70
 
    cmd = ['git'] + list(args)
71
 
    p = subprocess.Popen(cmd,
72
 
                         stdout=subprocess.PIPE,
73
 
                         stderr=subprocess.PIPE)
74
 
    out, err = p.communicate()
75
 
    if p.returncode != 0:
76
 
        raise AssertionError('Bad return code: %d for %s:\n%s'
77
 
                             % (p.returncode, ' '.join(cmd), err))
78
 
    return out
79
 
 
80
 
 
81
54
class GitBranchBuilder(object):
82
55
 
83
56
    def __init__(self, stream=None):