[patch] Make export take an optional branch url

Daniel Silverstone dsilvers at digital-scurf.org
Sat Oct 28 16:16:24 BST 2006


Hi,

I spoke with Robert Collins about getting the export command to take an
optional branch url so that I could do:

bzr export foo-1.0.tar.gz http://my-server.com/foobranch

He said "do a patch" and so here it is.

The bundle attached is also on
http://bzr.digital-scurf.org/trees/dsilvers/bzr-bits

D.

-------------- next part --------------
# Bazaar revision bundle v0.8
#
# message:
#   Add source branch support to export command
# committer: Daniel Silverstone <daniel.silverstone at canonical.com>
# date: Sat 2006-10-28 13:40:21.570173979 +0100

=== modified file bzrlib/builtins.py
--- bzrlib/builtins.py
+++ bzrlib/builtins.py
@@ -1648,6 +1648,8 @@
     Root may be the top directory for tar, tgz and tbz2 formats. If none
     is given, the top directory will be the root name of the file.
 
+    If branch is omitted then the branch containing the CWD will be used.
+
     Note: export of tree with non-ascii filenames to zip is not supported.
 
      Supported formats       Autodetected by extension
@@ -1658,12 +1660,17 @@
          tgz                      .tar.gz, .tgz
          zip                          .zip
     """
-    takes_args = ['dest']
+    takes_args = ['dest', 'branch?']
     takes_options = ['revision', 'format', 'root']
-    def run(self, dest, revision=None, format=None, root=None):
+    def run(self, dest, branch=None, revision=None, format=None, root=None):
         from bzrlib.export import export
-        tree = WorkingTree.open_containing(u'.')[0]
-        b = tree.branch
+
+        if branch is None:
+            tree = WorkingTree.open_containing(u'.')[0]
+            b = tree.branch
+        else:
+            b = Branch.open(branch)
+            
         if revision is None:
             # should be tree.last_revision  FIXME
             rev_id = b.last_revision()

=== modified file bzrlib/tests/blackbox/test_export.py
--- bzrlib/tests/blackbox/test_export.py
+++ bzrlib/tests/blackbox/test_export.py
@@ -241,3 +241,13 @@
         finally:
             zf.close()
 
+    def test_export_from_outside_branch(self):
+        self.example_branch()
+
+        # Use directory exports to test stating the branch location
+        self.run_bzr('export', 'latest', 'branch')
+        self.assertEqual(['goodbye', 'hello'], sorted(os.listdir('latest')))
+        self.check_file_contents('latest/goodbye', 'baz')
+        self.run_bzr('export', 'first', '-r', '1', 'branch')
+        self.assertEqual(['hello'], sorted(os.listdir('first')))
+        self.check_file_contents('first/hello', 'foo')

=== modified directory  // last-changed:daniel.silverstone at canonical.com-200610
... 28124021-e857aec7bf24cda3
# revision id: daniel.silverstone at canonical.com-20061028124021-e857aec7bf24cda3
# sha1: 6432aea8c7e2806b143d002ae98896c271256cf8
# inventory sha1: af78e2a87bb639e4d7a05a2afbac8e68e874be46
# parent ids:
#   pqm at pqm.ubuntu.com-20061027165927-baf73dad8985eaa7
# base id: pqm at pqm.ubuntu.com-20061027165927-baf73dad8985eaa7
# properties:
#   branch-nick: bzr.dev



More information about the bazaar mailing list