Rev 2: Hook up the rest of the code in http://bzr.arbash-meinel.com/plugins/push_and_update
John Arbash Meinel
john at arbash-meinel.com
Mon Feb 12 21:48:53 GMT 2007
At http://bzr.arbash-meinel.com/plugins/push_and_update
------------------------------------------------------------
revno: 2
revision-id: john at arbash-meinel.com-20070212214850-mqhmsw85adrwhqlc
parent: john at arbash-meinel.com-20070212212954-webb6mimejfcq7ug
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: push_and_update
timestamp: Mon 2007-02-12 15:48:50 -0600
message:
Hook up the rest of the code
modified:
push_and_update.py push_and_update.py-20070212212941-xifrmnv3jrbcv28z-2
-------------- next part --------------
=== modified file 'push_and_update.py'
--- a/push_and_update.py 2007-02-12 21:29:54 +0000
+++ b/push_and_update.py 2007-02-12 21:48:50 +0000
@@ -35,14 +35,20 @@
if stored_loc is None:
raise errors.BzrCommandError('no push location known or specified.')
else:
- print 'Using saved location: %s\n' % (stored_loc,)
+ print 'Using saved location: %s' % (stored_loc,)
location = stored_loc
try:
target_branch = branch.Branch.open(location)
except errors.NotBranchError:
- target_bzrdir = bzrdir.BzrDir.create(location)
- target_branch = local_branch.sprout(target_bzrdir)
+ to_transport = transport.get_transport(location)
+ try:
+ to_transport.mkdir('.')
+ except errors.FileExists:
+ pass
+ target_bzrdir = local_branch.bzrdir.clone(to_transport.base,
+ revision_id=local_branch.last_revision())
+ target_branch = target_bzrdir.open_branch()
push_func = getattr(local_branch, 'push', None)
if push_func is not None:
@@ -55,7 +61,8 @@
try:
target_wt = target_branch.bzrdir.open_workingtree()
except errors.NoWorkingTree:
- pass #No remote working tree to update
+ # TODO: we could do "cd path; bzr checkout" if we wanted to
+ print 'No working tree to update at %s' % (target_branch.base,)
except errors.NotLocalUrl:
# we have something to update
update_remote_branch(target_branch)
@@ -67,15 +74,19 @@
def update_remote_branch(target_branch):
"""Run 'bzr update' in a remote branch."""
(scheme, user, password, host,
- port, path) = transport.split_url(branch.base)
+ port, path) = transport.split_url(target_branch.base)
- if username:
- user = '%s@' % (username,)
+ if user:
+ user = '%s@' % (user,)
else:
user = ''
if port:
port = ':%s' % (port,)
+ else:
+ port = ''
+
cmd = ['ssh', user+host+port, 'bzr', 'update', path]
+ print 'running "%s"' % (' '.join(cmd))
subprocess.call(cmd)
More information about the bazaar-commits
mailing list