~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/add.py

  • Committer: John Arbash Meinel
  • Date: 2005-11-08 18:36:26 UTC
  • mto: This revision was merged to the branch mainline in revision 1727.
  • Revision ID: john@arbash-meinel.com-20051108183626-71f8414338043265
Updating unified_diff to take a factory, using the new diff algorithm in the code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
 
17
from os.path import dirname
 
18
 
 
19
import bzrlib.errors as errors
 
20
from bzrlib.inventory import InventoryEntry
17
21
from bzrlib.trace import mutter, note, warning
18
22
from bzrlib.errors import NotBranchError
19
23
from bzrlib.branch import Branch
20
24
from bzrlib.osutils import quotefn
21
 
from os.path import dirname
22
25
 
23
26
def glob_expand_for_win32(file_list):
 
27
    if not file_list:
 
28
        return
24
29
    import glob
25
 
    
26
30
    expanded_file_list = []
27
31
    for possible_glob in file_list:
28
32
        glob_files = glob.glob(possible_glob)
64
68
    Returns the number of files added.
65
69
    """
66
70
    file_list = _prepare_file_list(file_list)
67
 
    b = Branch(file_list[0], find_root=True)
 
71
    b = Branch.open_containing(file_list[0])[0]
68
72
    return smart_add_branch(b, file_list, recurse, reporter)
69
73
 
70
74
        
86
90
 
87
91
    file_list = _prepare_file_list(file_list)
88
92
    user_list = file_list[:]
89
 
    inv = branch.read_working_inventory()
90
93
    tree = branch.working_tree()
 
94
    inv = tree.read_working_inventory()
91
95
    count = 0
92
96
 
93
97
    for f in file_list:
94
 
        rf = branch.relpath(f)
 
98
        rf = tree.relpath(f)
95
99
        af = branch.abspath(rf)
96
100
 
97
101
        kind = bzrlib.osutils.file_kind(af)
98
102
 
99
 
        if kind != 'file' and kind != 'directory':
 
103
        if not InventoryEntry.versionable_kind(kind):
100
104
            if f in user_list:
101
105
                raise BadFileKindError("cannot add %s of type %s" % (f, kind))
102
106
            else:
112
116
 
113
117
        if kind == 'directory':
114
118
            try:
115
 
                sub_branch = Branch(af, find_root=False)
 
119
                sub_branch = Branch.open(af)
116
120
                sub_tree = True
117
121
            except NotBranchError:
118
122
                sub_tree = False
 
123
            except errors.UnsupportedFormatError:
 
124
                sub_tree = True
119
125
        else:
120
126
            sub_tree = False
121
127