~verterok/ols-jenkaas/dd-siab-dependencies

« back to all changes in this revision

Viewing changes to olsjenkaas/tests/branches/bzr.py

  • Committer: Vincent Ladeuil
  • Date: 2017-02-09 16:12:35 UTC
  • mfrom: (323.2.109 lander)
  • Revision ID: vila+ols@canonical.com-20170209161235-8igi05uo09s638fv
Unify lander with tests and jobs tags for validation without service interruption

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# This file is part of Online Services Jenkaas.
2
2
#
3
 
# Copyright 2016 Canonical Ltd.
 
3
# Copyright 2016, 2017 Canonical Ltd.
4
4
#
5
5
# This program is free software: you can redistribute it and/or modify it under
6
6
# the terms of the GNU General Public License version 3, as published by the
23
23
from olsvms import subprocesses
24
24
 
25
25
 
26
 
from olsjenkaas.tests import fixtures
 
26
import olsjenkaas
27
27
 
28
28
 
29
29
class Branch(object):
38
38
    def _run(self, args):
39
39
        return subprocesses.run(['bzr'] + args)
40
40
 
 
41
    def tip_commit_id(self):
 
42
        with olsjenkaas.working_directory(self.location):
 
43
            return self._run(['revision-info'])[1].split()[1].strip()
 
44
 
41
45
    def create(self):
42
46
        return self._run(['init', self.location])
43
47
 
44
 
    def create_from(self, url):
45
 
        # FIXME: Handle lp transient failures ? -- vila 2016-12-07
46
 
        import pdb; pdb.set_trace()
47
 
        return self._run(['branch', url, self.location])
 
48
    def create_from(self, existing):
 
49
        return self._run(['branch', existing, self.location])
48
50
 
49
51
    def update(self, description, tree_update):
50
 
        with fixtures.ThatDir(self.location):
 
52
        from olsjenkaas.tests import fixtures
 
53
        with olsjenkaas.working_directory(self.location):
51
54
            fixtures.build_tree(tree_update)
52
55
            self._run(['add'])
53
56
            return self._run(['commit', '-m', description])
54
57
 
 
58
    def push(self, url):
 
59
        with olsjenkaas.working_directory(self.location):
 
60
            return self._run(['push', url])
 
61
 
55
62
    def delete(self):
56
 
        with fixtures.ThatDir(self.location):
57
 
            return subprocesses.run(['rm', '-r', self.location])
 
63
        with olsjenkaas.working_directory(self.location):
 
64
            return subprocesses.run(['rm', '-fr', self.location])
58
65
 
59
66
    def status(self):
60
 
        with fixtures.ThatDir(self.location):
 
67
        with olsjenkaas.working_directory(self.location):
61
68
            ret, out, err = self._run(['status'])
62
69
            return out