Move dpush to bzr-foreign.
authorJelmer Vernooij <jelmer@samba.org>
Fri, 29 Aug 2008 15:18:10 +0000 (17:18 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Fri, 29 Aug 2008 15:18:10 +0000 (17:18 +0200)
__init__.py
branch.py
foreign/__init__.py

index 8ab7a36846710588c0d166aa4fb37f735b27c1c3..40e6fb12bb3c37b6c7c02fdcad66bb31dcd17137 100644 (file)
@@ -427,70 +427,8 @@ class cmd_svn_push(Command):
 
 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.
index 85062ca443b56ed10af334f411634466f54cd87f..0c82b12ea516e3c6fc9bd1a74cfa2e588c5f708e 100644 (file)
--- a/branch.py
+++ b/branch.py
@@ -338,6 +338,10 @@ class SvnBranch(Branch):
         # 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()."""
index 4e079754e3157e2439d78885812cca214c5118bf..2aae47e2c10d0cdf7a9e299e937cf7fbe7452de8 100644 (file)
@@ -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 @@ class FakeControlFiles(object):
     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)
+
+