~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
from bzrlib.revision import common_ancestor
30
30
from bzrlib.errors import (BzrError, BzrCheckError, BzrCommandError, 
31
31
                           NotBranchError, DivergedBranches, NotConflicted,
32
 
                           NoSuchFile, NoWorkingTree)
 
32
                           NoSuchFile, NoWorkingTree, FileInWrongBranch)
33
33
from bzrlib.option import Option
34
34
from bzrlib.revisionspec import RevisionSpec
35
35
import bzrlib.trace
40
40
def branch_files(file_list, default_branch='.'):
41
41
    try:
42
42
        return inner_branch_files(file_list, default_branch)
43
 
    except NotBranchError:
 
43
    except FileInWrongBranch, e:
 
44
        print file_list
44
45
        raise BzrCommandError("%s is not in the same branch as %s" %
45
 
                             (filename, file_list[0]))
 
46
                             (e.path, file_list[0]))
46
47
 
47
48
def inner_branch_files(file_list, default_branch='.'):
48
49
    """\
61
62
    tree = WorkingTree(b.base, b)
62
63
    new_list = []
63
64
    for filename in file_list:
64
 
        new_list.append(tree.relpath(filename))
 
65
        try:
 
66
            new_list.append(tree.relpath(filename))
 
67
        except NotBranchError:
 
68
            raise FileInWrongBranch(b, filename)
65
69
    return b, new_list
66
70
 
67
71
 
743
747
        try:
744
748
            b, file_list = inner_branch_files(file_list)
745
749
            b2 = None
746
 
        except NotBranchError:
 
750
        except FileInWrongBranch:
747
751
            if len(file_list) != 2:
748
752
                raise BzrCommandError("Files are in different branches")
749
753