Rev 4306: (gbache) Handle symlinks better in bzr add in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Mon Apr 27 23:07:13 BST 2009


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

------------------------------------------------------------
revno: 4306
revision-id: pqm at pqm.ubuntu.com-20090427220703-oy9b0mxobrksvuyq
parent: pqm at pqm.ubuntu.com-20090427204403-xt52x89oi017ad2e
parent: aaron at aaronbentley.com-20090427203006-ex6w9vvd15zbtp85
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2009-04-27 23:07:03 +0100
message:
  (gbache) Handle symlinks better in bzr add
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/tests/blackbox/test_add.py test_add.py-20060518072250-857e4f86f54a30b2
    ------------------------------------------------------------
    revno: 4301.2.5
    revision-id: aaron at aaronbentley.com-20090427203006-ex6w9vvd15zbtp85
    parent: aaron at aaronbentley.com-20090423213209-42p1s1p4p1unvvwi
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: bzr.ab.integration
    timestamp: Mon 2009-04-27 16:30:06 -0400
    message:
      Move file_list updates after view_files check.
    modified:
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
    ------------------------------------------------------------
    revno: 4301.2.4
    revision-id: aaron at aaronbentley.com-20090423213209-42p1s1p4p1unvvwi
    parent: aaron at aaronbentley.com-20090423211556-o42rh8sgejp830uw
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: bzr.ab.integration
    timestamp: Thu 2009-04-23 17:32:09 -0400
    message:
      Further cleanups
    modified:
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/tests/blackbox/test_add.py test_add.py-20060518072250-857e4f86f54a30b2
    ------------------------------------------------------------
    revno: 4301.2.3
    revision-id: aaron at aaronbentley.com-20090423211556-o42rh8sgejp830uw
    parent: aaron at aaronbentley.com-20090423202724-efnx0yuj6eaj6859
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: bzr.ab.integration
    timestamp: Thu 2009-04-23 17:15:56 -0400
    message:
      Clean up tree_add_files
    modified:
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
    ------------------------------------------------------------
    revno: 4301.2.2
    revision-id: aaron at aaronbentley.com-20090423202724-efnx0yuj6eaj6859
    parent: aaron at aaronbentley.com-20090423201418-aluo26hrvq26k2n3
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: bzr.ab.integration
    timestamp: Thu 2009-04-23 16:27:24 -0400
    message:
      Update style
    modified:
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
    ------------------------------------------------------------
    revno: 4301.2.1
    revision-id: aaron at aaronbentley.com-20090423201418-aluo26hrvq26k2n3
    parent: pqm at pqm.ubuntu.com-20090423015537-xfgqsbjj9ctpcd3o
    parent: geoff.bache at jeppesen.com-20090423194434-vhu3mjxmwjjspqr1
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: bzr.ab.integration
    timestamp: Thu 2009-04-23 16:14:18 -0400
    message:
      Merge updates for tree_files_for_add
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/tests/blackbox/test_add.py test_add.py-20060518072250-857e4f86f54a30b2
    ------------------------------------------------------------
    revno: 4301.1.1
    revision-id: geoff.bache at jeppesen.com-20090423194434-vhu3mjxmwjjspqr1
    parent: pqm at pqm.ubuntu.com-20090423015537-xfgqsbjj9ctpcd3o
    committer: Geoff Bache <geoff.bache at jeppesen.com>
    branch nick: bzr.dev.orig
    timestamp: Thu 2009-04-23 21:44:34 +0200
    message:
      Fixing bug 183831, where 'bzr add' fails with a python stack if the path contains a symbolic link
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/tests/blackbox/test_add.py test_add.py-20060518072250-857e4f86f54a30b2
=== modified file 'NEWS'
--- a/NEWS	2009-04-27 03:47:55 +0000
+++ b/NEWS	2009-04-27 22:07:03 +0000
@@ -50,6 +50,9 @@
 * Fix a bug in the pure-python ``GroupCompress`` code when handling copies
   longer than 64KiB. (John Arbash Meinel, #364900)
 
+* Adding now works properly when path contains a symbolic link.
+  (Geoff Bache, #183831)
+
 Documentation
 *************
 

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2009-04-27 03:47:55 +0000
+++ b/bzrlib/builtins.py	2009-04-27 22:07:03 +0000
@@ -79,15 +79,26 @@
 
 
 def tree_files_for_add(file_list):
-    """Add handles files a bit differently so it a custom implementation."""
+    """
+    Return a tree and list of absolute paths from a file list.
+
+    Similar to tree_files, but add handles files a bit differently, so it a
+    custom implementation.  In particular, MutableTreeTree.smart_add expects
+    absolute paths, which it immediately converts to relative paths.
+    """
+    # FIXME Would be nice to just return the relative paths like
+    # internal_tree_files does, but there are a large number of unit tests
+    # that assume the current interface to mutabletree.smart_add
     if file_list:
-        tree = WorkingTree.open_containing(file_list[0])[0]
+        tree, relpath = WorkingTree.open_containing(file_list[0])
         if tree.supports_views():
             view_files = tree.views.lookup_view()
             if view_files:
                 for filename in file_list:
                     if not osutils.is_inside_any(view_files, filename):
                         raise errors.FileOutsideView(filename, view_files)
+        file_list = file_list[:]
+        file_list[0] = tree.abspath(relpath)
     else:
         tree = WorkingTree.open_containing(u'.')[0]
         if tree.supports_views():

=== modified file 'bzrlib/tests/blackbox/test_add.py'
--- a/bzrlib/tests/blackbox/test_add.py	2009-04-08 03:34:31 +0000
+++ b/bzrlib/tests/blackbox/test_add.py	2009-04-23 21:32:09 +0000
@@ -19,10 +19,12 @@
 
 import os
 
+from bzrlib import osutils
 from bzrlib.tests import (
     condition_isinstance,
     split_suite_by_condition,
     multiply_tests,
+    SymlinkFeature
     )
 from bzrlib.tests.blackbox import ExternalBase
 from bzrlib.tests.test_win32utils import NeedsGlobExpansionFeature
@@ -227,3 +229,18 @@
         self.build_tree([u'\u1234A', u'\u1235A', u'\u1235AA', 'cc'])
         self.run_bzr(['add', u'\u1234?', u'\u1235*'])
         self.assertEquals(self.run_bzr('unknowns')[0], 'cc\n')
+
+    def test_add_via_symlink(self):
+        self.requireFeature(SymlinkFeature)
+        self.make_branch_and_tree('source')
+        self.build_tree(['source/top.txt'])
+        os.symlink('source', 'link')
+        out = self.run_bzr(['add', 'link/top.txt'])[0]
+        self.assertEquals(out, 'adding top.txt\n')
+
+    def test_add_symlink_to_abspath(self):
+        self.requireFeature(SymlinkFeature)
+        self.make_branch_and_tree('tree')
+        os.symlink(osutils.abspath('target'), 'tree/link')
+        out = self.run_bzr(['add', 'tree/link'])[0]
+        self.assertEquals(out, 'adding link\n')




More information about the bazaar-commits mailing list