~landscape/charms/trusty/nova-cloud-controller-leadership-election/trunk

« back to all changes in this revision

Viewing changes to hooks/charmhelpers/fetch/bzrurl.py

  • Committer: Liam Young
  • Date: 2015-01-26 09:44:11 UTC
  • Revision ID: liam.young@canonical.com-20150126094411-4dg7t1zxrv1uu0xx
[gnuoy,trivial] Pre-release charmhelper sync

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2014-2015 Canonical Limited.
 
2
#
 
3
# This file is part of charm-helpers.
 
4
#
 
5
# charm-helpers is free software: you can redistribute it and/or modify
 
6
# it under the terms of the GNU Lesser General Public License version 3 as
 
7
# published by the Free Software Foundation.
 
8
#
 
9
# charm-helpers is distributed in the hope that it will be useful,
 
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
# GNU Lesser General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU Lesser General Public License
 
15
# along with charm-helpers.  If not, see <http://www.gnu.org/licenses/>.
 
16
 
1
17
import os
2
18
from charmhelpers.fetch import (
3
19
    BaseFetchHandler,
11
27
 
12
28
try:
13
29
    from bzrlib.branch import Branch
 
30
    from bzrlib import bzrdir, workingtree, errors
14
31
except ImportError:
15
32
    from charmhelpers.fetch import apt_install
16
33
    apt_install("python-bzrlib")
17
34
    from bzrlib.branch import Branch
 
35
    from bzrlib import bzrdir, workingtree, errors
18
36
 
19
37
 
20
38
class BzrUrlFetchHandler(BaseFetchHandler):
35
53
            from bzrlib.plugin import load_plugins
36
54
            load_plugins()
37
55
        try:
 
56
            local_branch = bzrdir.BzrDir.create_branch_convenience(dest)
 
57
        except errors.AlreadyControlDirError:
 
58
            local_branch = Branch.open(dest)
 
59
        try:
38
60
            remote_branch = Branch.open(source)
39
 
            remote_branch.bzrdir.sprout(dest).open_branch()
 
61
            remote_branch.push(local_branch)
 
62
            tree = workingtree.WorkingTree.open(dest)
 
63
            tree.update()
40
64
        except Exception as e:
41
65
            raise e
42
66