Rev 6335: (jelmer) Add --uncommitted option to 'bzr export'. (Jelmer Vernooij) in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/

Patch Queue Manager pqm at pqm.ubuntu.com
Thu Dec 1 12:18:55 UTC 2011


At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 6335 [merge]
revision-id: pqm at pqm.ubuntu.com-20111201121855-olnxam3ku2tvu3a2
parent: pqm at pqm.ubuntu.com-20111201115302-ca9t4zzn13swv0p1
parent: jelmer at samba.org-20111130200659-4qyguxucxxprs0lp
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2011-12-01 12:18:55 +0000
message:
  (jelmer) Add --uncommitted option to 'bzr export'. (Jelmer Vernooij)
modified:
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/tests/blackbox/test_export.py test_export.py-20051229024010-e6c26658e460fb1c
  doc/en/release-notes/bzr-2.5.txt bzr2.5.txt-20110708125756-587p0hpw7oke4h05-1
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2011-11-27 17:50:41 +0000
+++ b/bzrlib/builtins.py	2011-11-30 20:06:59 +0000
@@ -3148,25 +3148,36 @@
         Option('per-file-timestamps',
                help='Set modification time of files to that of the last '
                     'revision in which it was changed.'),
+        Option('uncommitted',
+               help='Export the working tree contents rather than that of the '
+                    'last revision.'),
         ]
     def run(self, dest, branch_or_subdir=None, revision=None, format=None,
-        root=None, filters=False, per_file_timestamps=False, directory=u'.'):
+        root=None, filters=False, per_file_timestamps=False, uncommitted=False,
+        directory=u'.'):
         from bzrlib.export import export
 
         if branch_or_subdir is None:
-            tree = WorkingTree.open_containing(directory)[0]
-            b = tree.branch
-            subdir = None
+            branch_or_subdir = directory
+
+        (tree, b, subdir) = controldir.ControlDir.open_containing_tree_or_branch(
+            branch_or_subdir)
+        if tree is not None:
+            self.add_cleanup(tree.lock_read().unlock)
+
+        if uncommitted:
+            if tree is None:
+                raise errors.BzrCommandError(
+                    gettext("--uncommitted requires a working tree"))
+            export_tree = tree
         else:
-            b, subdir = Branch.open_containing(branch_or_subdir)
-            tree = None
-
-        rev_tree = _get_one_revision_tree('export', revision, branch=b, tree=tree)
+            export_tree = _get_one_revision_tree('export', revision, branch=b, tree=tree)
         try:
-            export(rev_tree, dest, format, root, subdir, filtered=filters,
+            export(export_tree, dest, format, root, subdir, filtered=filters,
                    per_file_timestamps=per_file_timestamps)
         except errors.NoSuchExportFormat, e:
-            raise errors.BzrCommandError(gettext('Unsupported export format: %s') % e.format)
+            raise errors.BzrCommandError(
+                gettext('Unsupported export format: %s') % e.format)
 
 
 class cmd_cat(Command):

=== modified file 'bzrlib/tests/blackbox/test_export.py'
--- a/bzrlib/tests/blackbox/test_export.py	2011-11-23 12:02:26 +0000
+++ b/bzrlib/tests/blackbox/test_export.py	2011-11-30 20:06:59 +0000
@@ -402,6 +402,23 @@
         self.assertEqual(['goodbye', 'hello'], sorted(os.listdir('latest')))
         self.check_file_contents('latest/goodbye', 'baz')
 
+    def test_export_uncommitted(self):
+        """Test --uncommitted option"""
+        self.example_branch()
+        os.chdir('branch')
+        self.build_tree_contents([('goodbye', 'uncommitted data')])
+        self.run_bzr(['export', '--uncommitted', 'latest'])
+        self.check_file_contents('latest/goodbye', 'uncommitted data')
+
+    def test_export_uncommitted_no_tree(self):
+        """Test --uncommitted option only works with a working tree."""
+        tree = self.example_branch()
+        tree.bzrdir.destroy_workingtree()
+        os.chdir('branch')
+        self.run_bzr_error(
+            ['bzr: ERROR: --uncommitted requires a working tree'],
+            'export --uncommitted latest')
+
     def test_zip_export_per_file_timestamps(self):
         tree = self.example_branch()
         self.build_tree_contents([('branch/har', 'foo')])

=== modified file 'doc/en/release-notes/bzr-2.5.txt'
--- a/doc/en/release-notes/bzr-2.5.txt	2011-12-01 01:44:49 +0000
+++ b/doc/en/release-notes/bzr-2.5.txt	2011-12-01 12:18:55 +0000
@@ -34,6 +34,9 @@
   branch, the relative branch name should no longer be url-encoded.
   (Jelmer Vernooij)
 
+* ``bzr export --uncommitted`` will export the uncommitted tree.
+  (Jelmer Vernooij, #555613)
+
 * ``bzr rmbranch`` can now remove colocated branches.
   (Jelmer Vernooij, #831464)
 




More information about the bazaar-commits mailing list