6
from bzrlib.branch import Branch
7
from bzrlib.bzrdir import BzrDir
8
from bzrlib.plugin import load_plugins
13
class BzrBranch(object):
14
"Simplified bazaar branch API"
15
def __init__(self, location):
16
if location.startswith("file://"):
17
location = location[7:]
18
self.location = location
19
if urlutils.is_url(self.location):
22
if not os.path.isabs(self.location):
24
self.location = os.path.normpath(os.path.join(cwd, self.location))
32
self._branch = Branch.open(self.location)
33
except errors.NotBranchError:
39
return not self.is_local
43
if self.bzr_branch is None:
50
return self.bzr_branch.revno()
54
if self.is_remote or self.bzr_branch is None:
56
return self.bzr_branch.get_parent()
58
def clone(self, dest_dir):
59
if not self.bzr_branch:
61
self.bzr_branch.bzrdir.sprout(dest_dir)
62
return BzrBranch(dest_dir)
73
BzrDir.create_branch_convenience(self.location)
75
def pull(self, src_location=None, overwrite=False, revno=None):
76
if not self.is_branch:
78
if src_location is None and self.is_local:
79
src_location = self.parent
80
other = BzrBranch(src_location)
82
self.bzr_branch.pull(other.bzr_branch,
89
def push(self, dest_location, overwrite=False):
90
dest_branch = BzrBranch(dest_location)
91
if not dest_branch.is_branch:
93
dest_branch.bzr_branch.push(self.bzr_branch, overwrite=overwrite)