Rev 5350: (jameinel) Give a better traceback when a user tries to add files to in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Mon Jul 19 14:08:54 BST 2010
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5350 [merge]
revision-id: pqm at pqm.ubuntu.com-20100719130851-igs92yvcf0y7j964
parent: pqm at pqm.ubuntu.com-20100716205254-j0m65wckb90rj54w
parent: mbp at canonical.com-20100716135326-a3d5bh29w64ylh5p
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2010-07-19 14:08:51 +0100
message:
(jameinel) Give a better traceback when a user tries to add files to
different trees. (Martin Pool)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/diff.py diff.py-20050309040759-26944fbbf2ebbf36
bzrlib/errors.py errors.py-20050309040759-20512168c4e14fbd
bzrlib/tests/blackbox/test_add.py test_add.py-20060518072250-857e4f86f54a30b2
=== modified file 'NEWS'
--- a/NEWS 2010-07-13 21:25:03 +0000
+++ b/NEWS 2010-07-16 13:53:26 +0000
@@ -14,12 +14,19 @@
Compatibility Breaks
********************
+* `FileInWrongBranch` is deprecated in favour of `PathNotChild` and no
+ longer raised.
+ (Martin Pool)
+
New Features
************
Bug Fixes
*********
+* `PathNotChild` should not give a traceback.
+ (Martin Pool, #98735)
+
Improvements
************
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2010-06-30 12:13:14 +0000
+++ b/bzrlib/builtins.py 2010-07-16 13:53:26 +0000
@@ -77,12 +77,8 @@
def tree_files(file_list, default_branch=u'.', canonicalize=True,
apply_view=True):
- try:
- return internal_tree_files(file_list, default_branch, canonicalize,
- apply_view)
- except errors.FileInWrongBranch, e:
- raise errors.BzrCommandError("%s is not in the same branch as %s" %
- (e.path, file_list[0]))
+ return internal_tree_files(file_list, default_branch, canonicalize,
+ apply_view)
def tree_files_for_add(file_list):
@@ -210,13 +206,10 @@
else:
fixer = tree.relpath
for filename in file_list:
- try:
- relpath = fixer(osutils.dereference_path(filename))
- if view_files and not osutils.is_inside_any(view_files, relpath):
- raise errors.FileOutsideView(filename, view_files)
- new_list.append(relpath)
- except errors.PathNotChild:
- raise errors.FileInWrongBranch(tree.branch, filename)
+ relpath = fixer(osutils.dereference_path(filename))
+ if view_files and not osutils.is_inside_any(view_files, relpath):
+ raise errors.FileOutsideView(filename, view_files)
+ new_list.append(relpath)
return new_list
=== modified file 'bzrlib/diff.py'
--- a/bzrlib/diff.py 2010-05-26 15:58:08 +0000
+++ b/bzrlib/diff.py 2010-07-16 13:53:26 +0000
@@ -420,12 +420,9 @@
# Get the specific files (all files is None, no files is [])
if make_paths_wt_relative and working_tree is not None:
- try:
- from bzrlib.builtins import safe_relpath_files
- other_paths = safe_relpath_files(working_tree, other_paths,
- apply_view=apply_view)
- except errors.FileInWrongBranch:
- raise errors.BzrCommandError("Files are in different branches")
+ from bzrlib.builtins import safe_relpath_files
+ other_paths = safe_relpath_files(working_tree, other_paths,
+ apply_view=apply_view)
specific_files.extend(other_paths)
if len(specific_files) == 0:
specific_files = None
=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py 2010-07-09 16:16:11 +0000
+++ b/bzrlib/errors.py 2010-07-16 13:53:26 +0000
@@ -680,7 +680,7 @@
_fmt = 'Path "%(path)s" is not a child of path "%(base)s"%(extra)s'
- internal_error = True
+ internal_error = False
def __init__(self, path, base, extra=None):
BzrError.__init__(self)
@@ -782,6 +782,8 @@
_fmt = 'File "%(path)s" is not in branch %(branch_base)s.'
+ # use PathNotChild instead
+ @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((2, 3, 0)))
def __init__(self, branch, path):
BzrError.__init__(self)
self.branch = branch
=== modified file 'bzrlib/tests/blackbox/test_add.py'
--- a/bzrlib/tests/blackbox/test_add.py 2010-02-23 07:43:11 +0000
+++ b/bzrlib/tests/blackbox/test_add.py 2010-07-16 13:53:26 +0000
@@ -23,6 +23,9 @@
osutils,
tests,
)
+from bzrlib.tests import (
+ script,
+ )
def load_tests(standard_tests, module, loader):
@@ -217,3 +220,14 @@
os.symlink(osutils.abspath('target'), 'tree/link')
out = self.run_bzr(['add', 'tree/link'])[0]
self.assertEquals(out, 'adding link\n')
+
+ def test_add_not_child(self):
+ # https://bugs.launchpad.net/bzr/+bug/98735
+ sr = script.ScriptRunner()
+ self.make_branch_and_tree('tree1')
+ self.make_branch_and_tree('tree2')
+ self.build_tree(['tree1/a', 'tree2/b'])
+ sr.run_script(self, '''
+ $ bzr add tree1/a tree2/b
+ 2>bzr: ERROR: Path "...tree2/b" is not a child of path "...tree1"
+ ''')
More information about the bazaar-commits
mailing list