PathNotChild traceback from 'bzr add branch1/a branch2/b'

Bug #98735 reported by John A Meinel
50
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Medium
Martin Pool

Bug Description

I don't believe we plan to support adding files to multiple branches at the same time, but we also shouldn't give an ugly traceback.

Specifically, if you do:

bzr init branch1
bzr init branch2
touch branch1/a
touch branch2/a
bzr add branch1 branch2

You get a traceback with:
bzr: ERROR: bzrlib.errors.PathNotChild: Path u'/Users/jameinel/dev/,tmp/branch2' is not a child of path u'/Users/jameinel/dev/,tmp/branch1'

Traceback (most recent call last):
  File "/Users/jameinel/dev/bzr/bzr.dev/bzrlib/commands.py", line 638, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/Users/jameinel/dev/bzr/bzr.dev/bzrlib/commands.py", line 600, in run_bzr
    ret = run(*run_argv)
  File "/Users/jameinel/dev/bzr/bzr.dev/bzrlib/commands.py", line 296, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/Users/jameinel/dev/bzr/bzr.dev/bzrlib/builtins.py", line 373, in run
    action=action, save=not dry_run)
  File "/Users/jameinel/dev/bzr/bzr.dev/bzrlib/add.py", line 148, in smart_add
    return smart_add_tree(tree, file_list, recurse, action=action, save=save)
  File "/Users/jameinel/dev/bzr/bzr.dev/bzrlib/add.py", line 175, in smart_add_tree
    action=action, save=save)
  File "/Users/jameinel/dev/bzr/bzr.dev/bzrlib/add.py", line 211, in _smart_add_tree
    rf = FastPath(tree.relpath(filepath))
  File "/Users/jameinel/dev/bzr/bzr.dev/bzrlib/workingtree.py", line 441, in relpath
    return osutils.relpath(self.basedir, path)
  File "/Users/jameinel/dev/bzr/bzr.dev/bzrlib/osutils.py", line 866, in relpath
    raise errors.PathNotChild(rp, base)
PathNotChild: Path u'/Users/jameinel/dev/,tmp/branch2' is not a child of path u'/Users/jameinel/dev/,tmp/branch1'

bzr 0.16.0dev0 on python 2.4.1.final.0 (darwin)
arguments: ['/Users/jameinel/bin/bzr', 'add', 'branch1', 'branch2']

** please send this report to <email address hidden>

Which is one of those "correct but useless" errors.

We could do a try/except PathNotChild around smart_add_tree in cmd_add.
Or we could use 'tree_files' which would give us "FileInWrongBranch".

The first problem is that it won't work with the current smart_add_tree api when you are in a subdirectory.
Because 'smart_add_tree' calls tree.relpath() which would have already been called by 'tree_files'.

On the flip side, we are currently calling "smart_add()" which does the basics of 'tree_files' including _prepare_file_list, which is then called *again* in smart_add_tree.

Using 'tree_files' gives this error:
$ bzr add branch1 branch2
bzr: ERROR: branch2 is not in the same branch as branch1

Which is at least a lot better than the traceback.

Tags: traceback add

Related branches

Changed in bzr:
status: New → Confirmed
Martin Pool (mbp)
Changed in bzr:
importance: Undecided → Medium
Martin Pool (mbp)
summary: - 'bzr add branch1 branch2' gives a traceback
+ PathNotChild traceback from 'bzr add branch1/a branch2/b'
tags: added: add traceback
Martin Pool (mbp)
Changed in bzr:
status: Confirmed → In Progress
assignee: nobody → Martin Pool (mbp)
Martin Pool (mbp)
Changed in bzr:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.