Rev 1692: Move dpush to bzr-foreign. in file:///data/jelmer/bzr-svn/trunk/
Jelmer Vernooij
jelmer at samba.org
Fri Aug 29 16:18:12 BST 2008
At file:///data/jelmer/bzr-svn/trunk/
------------------------------------------------------------
revno: 1692
revision-id: jelmer at samba.org-20080829151810-ro2uwjzpzikagqoe
parent: jelmer at samba.org-20080829150651-55maog3c0srdsrsx
parent: jelmer at samba.org-20080829151627-r3mhlflwdgtioy1c
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Fri 2008-08-29 17:18:10 +0200
message:
Move dpush to bzr-foreign.
modified:
__init__.py __init__.py-20051008155114-eae558e6cf149e1d
branch.py svnbranch.py-20051017135706-11c749eb0dab04a7
foreign/__init__.py foreign.py-20080827193306-rxeku2c2obec90c4-1
------------------------------------------------------------
revno: 0.5.7
revision-id: jelmer at samba.org-20080829151627-r3mhlflwdgtioy1c
parent: jelmer at samba.org-20080829150547-98hpxtt3k52vlwz8
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Fri 2008-08-29 17:16:27 +0200
message:
Import dpush.
modified:
__init__.py foreign.py-20080827193306-rxeku2c2obec90c4-1
=== modified file '__init__.py'
--- a/__init__.py 2008-08-28 13:34:34 +0000
+++ b/__init__.py 2008-08-29 15:18:10 +0000
@@ -427,70 +427,8 @@
register_command(cmd_svn_push)
-class cmd_dpush(Command):
- """Push diffs into Subversion without any Bazaar-specific properties set.
-
- This will afterwards rebase the local Bazaar branch on the Subversion
- branch unless the --no-rebase option is used, in which case
- the two branches will be out of sync.
- """
- takes_args = ['location?']
- takes_options = ['remember', Option('directory',
- help='Branch to push from, '
- 'rather than the one containing the working directory.',
- short_name='d',
- type=unicode,
- ),
- Option('no-rebase', help="Don't rebase after push")]
-
- def run(self, location=None, remember=False, directory=None,
- no_rebase=False):
- from bzrlib import urlutils
- from bzrlib.bzrdir import BzrDir
- from bzrlib.branch import Branch
- from bzrlib.errors import BzrCommandError, NoWorkingTree
- from bzrlib.workingtree import WorkingTree
-
- from bzrlib.plugins.svn.commit import dpush
-
- if directory is None:
- directory = "."
- try:
- source_wt = WorkingTree.open_containing(directory)[0]
- source_branch = source_wt.branch
- except NoWorkingTree:
- source_branch = Branch.open_containing(directory)[0]
- source_wt = None
- stored_loc = source_branch.get_push_location()
- if location is None:
- if stored_loc is None:
- raise BzrCommandError("No push location known or specified.")
- else:
- display_url = urlutils.unescape_for_display(stored_loc,
- self.outf.encoding)
- self.outf.write("Using saved location: %s\n" % display_url)
- location = stored_loc
-
- bzrdir = BzrDir.open(location)
- target_branch = bzrdir.open_branch()
- target_branch.lock_write()
- revid_map = dpush(target_branch, source_branch)
- # We successfully created the target, remember it
- if source_branch.get_push_location() is None or remember:
- source_branch.set_push_location(target_branch.base)
- if not no_rebase:
- _, old_last_revid = source_branch.last_revision_info()
- new_last_revid = revid_map[old_last_revid]
- if source_wt is not None:
- source_wt.pull(target_branch, overwrite=True,
- stop_revision=new_last_revid)
- else:
- source_branch.pull(target_branch, overwrite=True,
- stop_revision=new_last_revid)
-
-
-register_command(cmd_dpush)
-
+from bzrlib.plugins.svn import foreign
+register_command(foreign.cmd_dpush)
class cmd_svn_branching_scheme(Command):
"""Show or change the branching scheme for a Subversion repository.
=== modified file 'branch.py'
--- a/branch.py 2008-08-29 15:06:51 +0000
+++ b/branch.py 2008-08-29 15:18:10 +0000
@@ -338,6 +338,10 @@
# on large branches.
return self.generate_revision_id(self.get_revnum())
+ def dpush(self, target, stop_revision=None):
+ from bzrlib.plugins.svn.commit import dpush
+ return dpush(target, self, stop_revision)
+
def pull(self, source, overwrite=False, stop_revision=None,
_hook_master=None, run_hooks=True, _push_merged=None):
"""See Branch.pull()."""
=== modified file 'foreign/__init__.py'
--- a/foreign/__init__.py 2008-08-29 15:05:47 +0000
+++ b/foreign/__init__.py 2008-08-29 15:18:10 +0000
@@ -17,6 +17,7 @@
"""Foreign branch utilities."""
from bzrlib import errors, registry
+from bzrlib.commands import Command, Option
class VcsMapping(object):
@@ -68,3 +69,64 @@
def break_lock(self):
pass
+
+class cmd_dpush(Command):
+ """Push diffs into Subversion without any Bazaar-specific properties set.
+
+ This will afterwards rebase the local Bazaar branch on the Subversion
+ branch unless the --no-rebase option is used, in which case
+ the two branches will be out of sync.
+ """
+ takes_args = ['location?']
+ takes_options = ['remember', Option('directory',
+ help='Branch to push from, '
+ 'rather than the one containing the working directory.',
+ short_name='d',
+ type=unicode,
+ ),
+ Option('no-rebase', help="Don't rebase after push")]
+
+ def run(self, location=None, remember=False, directory=None,
+ no_rebase=False):
+ from bzrlib import urlutils
+ from bzrlib.bzrdir import BzrDir
+ from bzrlib.branch import Branch
+ from bzrlib.errors import BzrCommandError, NoWorkingTree
+ from bzrlib.workingtree import WorkingTree
+
+ if directory is None:
+ directory = "."
+ try:
+ source_wt = WorkingTree.open_containing(directory)[0]
+ source_branch = source_wt.branch
+ except NoWorkingTree:
+ source_branch = Branch.open_containing(directory)[0]
+ source_wt = None
+ stored_loc = source_branch.get_push_location()
+ if location is None:
+ if stored_loc is None:
+ raise BzrCommandError("No push location known or specified.")
+ else:
+ display_url = urlutils.unescape_for_display(stored_loc,
+ self.outf.encoding)
+ self.outf.write("Using saved location: %s\n" % display_url)
+ location = stored_loc
+
+ bzrdir = BzrDir.open(location)
+ target_branch = bzrdir.open_branch()
+ target_branch.lock_write()
+ revid_map = source_branch.dpush(target_branch)
+ # We successfully created the target, remember it
+ if source_branch.get_push_location() is None or remember:
+ source_branch.set_push_location(target_branch.base)
+ if not no_rebase:
+ _, old_last_revid = source_branch.last_revision_info()
+ new_last_revid = revid_map[old_last_revid]
+ if source_wt is not None:
+ source_wt.pull(target_branch, overwrite=True,
+ stop_revision=new_last_revid)
+ else:
+ source_branch.pull(target_branch, overwrite=True,
+ stop_revision=new_last_revid)
+
+
More information about the bazaar-commits
mailing list