68
69
def break_lock(self):
73
class cmd_dpush(Command):
74
"""Push diffs into Subversion without any Bazaar-specific properties set.
76
This will afterwards rebase the local Bazaar branch on the Subversion
77
branch unless the --no-rebase option is used, in which case
78
the two branches will be out of sync.
80
takes_args = ['location?']
81
takes_options = ['remember', Option('directory',
82
help='Branch to push from, '
83
'rather than the one containing the working directory.',
87
Option('no-rebase', help="Don't rebase after push")]
89
def run(self, location=None, remember=False, directory=None,
91
from bzrlib import urlutils
92
from bzrlib.bzrdir import BzrDir
93
from bzrlib.branch import Branch
94
from bzrlib.errors import BzrCommandError, NoWorkingTree
95
from bzrlib.workingtree import WorkingTree
100
source_wt = WorkingTree.open_containing(directory)[0]
101
source_branch = source_wt.branch
102
except NoWorkingTree:
103
source_branch = Branch.open_containing(directory)[0]
105
stored_loc = source_branch.get_push_location()
107
if stored_loc is None:
108
raise BzrCommandError("No push location known or specified.")
110
display_url = urlutils.unescape_for_display(stored_loc,
112
self.outf.write("Using saved location: %s\n" % display_url)
113
location = stored_loc
115
bzrdir = BzrDir.open(location)
116
target_branch = bzrdir.open_branch()
117
target_branch.lock_write()
118
revid_map = source_branch.dpush(target_branch)
119
# We successfully created the target, remember it
120
if source_branch.get_push_location() is None or remember:
121
source_branch.set_push_location(target_branch.base)
123
_, old_last_revid = source_branch.last_revision_info()
124
new_last_revid = revid_map[old_last_revid]
125
if source_wt is not None:
126
source_wt.pull(target_branch, overwrite=True,
127
stop_revision=new_last_revid)
129
source_branch.pull(target_branch, overwrite=True,
130
stop_revision=new_last_revid)