Rev 5523: (vila) Respect --directory when path parameters are also used for shelve and in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri Nov 5 08:35:41 GMT 2010


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 5523 [merge]
revision-id: pqm at pqm.ubuntu.com-20101105083539-urkk2to9qakthagn
parent: pqm at pqm.ubuntu.com-20101104172234-6yoirc0trqsgcj8m
parent: v.ladeuil+lp at free.fr-20101104175202-udkowo59u042bxqk
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2010-11-05 08:35:39 +0000
message:
  (vila) Respect --directory when path parameters are also used for shelve and
   restore (Vincent Ladeuil)
modified:
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/conflicts.py            conflicts.py-20051001061850-78ef952ba63d2b42
  bzrlib/shelf_ui.py             shelver.py-20081005210102-33worgzwrtdw0yrm-1
  bzrlib/tests/blackbox/test_conflicts.py test_conflicts.py-20060228151432-9723ebb925b999cf
  bzrlib/tests/blackbox/test_shelve.py test_ls_shelf.py-20081202053526-thlo8yt0pi1cgor1-1
  bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
  doc/en/release-notes/bzr-2.3.txt NEWS-20050323055033-4e00b5db738777ff
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2010-10-20 12:06:13 +0000
+++ b/bzrlib/builtins.py	2010-11-04 17:48:47 +0000
@@ -5894,7 +5894,7 @@
             location = "."
         branch = Branch.open_containing(location)[0]
         branch.bzrdir.destroy_branch()
-        
+
 
 class cmd_shelve(Command):
     __doc__ = """Temporarily set aside some changes from the current tree.
@@ -5951,9 +5951,9 @@
     _see_also = ['unshelve', 'configuration']
 
     def run(self, revision=None, all=False, file_list=None, message=None,
-            writer=None, list=False, destroy=False, directory=u'.'):
+            writer=None, list=False, destroy=False, directory=None):
         if list:
-            return self.run_for_list()
+            return self.run_for_list(directory=directory)
         from bzrlib.shelf_ui import Shelver
         if writer is None:
             writer = bzrlib.option.diff_writer_registry.get()
@@ -5967,8 +5967,10 @@
         except errors.UserAbort:
             return 0
 
-    def run_for_list(self):
-        tree = WorkingTree.open_containing('.')[0]
+    def run_for_list(self, directory=None):
+        if directory is None:
+            directory = u'.'
+        tree = WorkingTree.open_containing(directory)[0]
         self.add_cleanup(tree.lock_read().unlock)
         manager = tree.get_shelf_manager()
         shelves = manager.active_shelves()

=== modified file 'bzrlib/conflicts.py'
--- a/bzrlib/conflicts.py	2010-07-16 15:35:43 +0000
+++ b/bzrlib/conflicts.py	2010-11-04 17:48:47 +0000
@@ -117,17 +117,19 @@
             ResolveActionOption(),
             ]
     _see_also = ['conflicts']
-    def run(self, file_list=None, all=False, action=None, directory=u'.'):
+    def run(self, file_list=None, all=False, action=None, directory=None):
         if all:
             if file_list:
                 raise errors.BzrCommandError("If --all is specified,"
                                              " no FILE may be provided")
+            if directory is None:
+                directory = u'.'
             tree = workingtree.WorkingTree.open_containing(directory)[0]
             if action is None:
                 action = 'done'
         else:
             tree, file_list = workingtree.WorkingTree.open_containing_paths(
-                file_list)
+                file_list, directory)
             if file_list is None:
                 if action is None:
                     # FIXME: There is a special case here related to the option

=== modified file 'bzrlib/shelf_ui.py'
--- a/bzrlib/shelf_ui.py	2010-09-20 23:15:01 +0000
+++ b/bzrlib/shelf_ui.py	2010-11-04 17:48:47 +0000
@@ -154,7 +154,7 @@
 
     @classmethod
     def from_args(klass, diff_writer, revision=None, all=False, file_list=None,
-                  message=None, directory='.', destroy=False):
+                  message=None, directory=None, destroy=False):
         """Create a shelver from commandline arguments.
 
         The returned shelver wil have a work_tree that is locked and should
@@ -168,6 +168,10 @@
         :param destroy: Change the working tree without storing the shelved
             changes.
         """
+        if directory is None:
+            directory = u'.'
+        elif file_list:
+            file_list = [osutils.pathjoin(directory, f) for f in file_list]
         tree, path = workingtree.WorkingTree.open_containing(directory)
         # Ensure that tree is locked for the lifetime of target_tree, as
         # target tree may be reading from the same dirstate.

=== modified file 'bzrlib/tests/blackbox/test_conflicts.py'
--- a/bzrlib/tests/blackbox/test_conflicts.py	2010-05-28 14:15:28 +0000
+++ b/bzrlib/tests/blackbox/test_conflicts.py	2010-11-04 17:48:47 +0000
@@ -103,6 +103,11 @@
         self.assertEqual(True, conflicts.is_empty(),
                          "tree still contains conflicts: %r" % conflicts)
 
+    def test_resolve_via_directory(self):
+        """resolve when run from subdirectory should handle relative paths"""
+        self.build_tree(["a/subdir/"])
+        self.run_bzr("resolve -d a/subdir ../myfile")
+
     def test_auto_resolve(self):
         """Text conflicts can be resolved automatically"""
         tree = self.make_branch_and_tree('tree')

=== modified file 'bzrlib/tests/blackbox/test_shelve.py'
--- a/bzrlib/tests/blackbox/test_shelve.py	2010-10-07 07:51:54 +0000
+++ b/bzrlib/tests/blackbox/test_shelve.py	2010-11-04 17:48:47 +0000
@@ -41,6 +41,14 @@
         self.assertEqual('', err)
         self.assertEqual('  1: Foo\n', out)
 
+    def test_shelve_list_via_directory(self):
+        tree = self.make_branch_and_tree('tree')
+        creator = self.make_creator(tree)
+        shelf_id = tree.get_shelf_manager().shelve_changes(creator, 'Foo')
+        out, err = self.run_bzr('shelve -d tree --list', retcode=1)
+        self.assertEqual('', err)
+        self.assertEqual('  1: Foo\n', out)
+
     def test_shelve_no_message(self):
         tree = self.make_branch_and_tree('.')
         creator = self.make_creator(tree)
@@ -125,6 +133,12 @@
         os.chdir('tree/dir')
         self.run_bzr('shelve --all ../file')
 
+    def test_shelve_via_directory(self):
+        tree = self.make_branch_and_tree('tree')
+        self.build_tree(['tree/file', 'tree/dir/'])
+        tree.add('file')
+        self.run_bzr('shelve -d tree/dir --all ../file')
+
 
 class TestShelveUnshelve(TestCaseWithTransport):
 

=== modified file 'bzrlib/workingtree.py'
--- a/bzrlib/workingtree.py	2010-10-15 09:53:27 +0000
+++ b/bzrlib/workingtree.py	2010-11-04 17:48:47 +0000
@@ -353,8 +353,8 @@
         return control.open_workingtree(), relpath
 
     @staticmethod
-    def open_containing_paths(file_list, default_directory='.',
-        canonicalize=True, apply_view=True):
+    def open_containing_paths(file_list, default_directory=None,
+                              canonicalize=True, apply_view=True):
         """Open the WorkingTree that contains a set of paths.
 
         Fail if the paths given are not all in a single tree.
@@ -362,6 +362,8 @@
         This is used for the many command-line interfaces that take a list of
         any number of files and that require they all be in the same tree.
         """
+        if default_directory is None:
+            default_directory = u'.'
         # recommended replacement for builtins.internal_tree_files
         if file_list is None or len(file_list) == 0:
             tree = WorkingTree.open_containing(default_directory)[0]
@@ -375,9 +377,15 @@
                     view_str = views.view_display_str(view_files)
                     note("Ignoring files outside view. View is %s" % view_str)
             return tree, file_list
-        tree = WorkingTree.open_containing(file_list[0])[0]
+        if default_directory == u'.':
+            seed = file_list[0]
+        else:
+            seed = default_directory
+            file_list = [osutils.pathjoin(default_directory, f)
+                         for f in file_list]
+        tree = WorkingTree.open_containing(seed)[0]
         return tree, tree.safe_relpath_files(file_list, canonicalize,
-            apply_view=apply_view)
+                                             apply_view=apply_view)
 
     def safe_relpath_files(self, file_list, canonicalize=True, apply_view=True):
         """Convert file_list into a list of relpaths in tree.

=== modified file 'doc/en/release-notes/bzr-2.3.txt'
--- a/doc/en/release-notes/bzr-2.3.txt	2010-11-02 22:23:40 +0000
+++ b/doc/en/release-notes/bzr-2.3.txt	2010-11-04 17:52:02 +0000
@@ -53,6 +53,11 @@
   normal file, rather than throwing ``AttributeError: children`` during
   smart_add. (Martin [gz], #251864)
 
+* Correctly handle the ``--directory`` option for all code paths of
+  ``resolve`` and ``shelve``, this was previously ignored when paths were
+  provided as parameters. When both are provided, ``--directory`` becomes
+  the base directory for the other paths. (Vincent Ladeuil, #670851)
+
 * Correctly set the Content-Type  header when http POSTing to comply
   with stricter web frameworks. (Vincent Ladeuil, #655100)
 




More information about the bazaar-commits mailing list