32
32
b = bzrlib.branch.Branch(file_list[0], find_root=True)
33
33
inv = b.read_working_inventory()
34
34
tree = b.working_tree()
37
def add_one(rf, kind):
38
file_id = bzrlib.branch.gen_file_id(rf)
39
inv.add_path(rf, kind=kind, file_id=file_id)
40
bzrlib.mutter("added %r kind %r file_id={%s}" % (rf, kind, file_id))
43
bzrlib.textui.show_status('A', kind, quotefn(f))
46
37
for f in file_list:
41
## TODO: It's OK to add root but only in recursive mode
50
43
bzrlib.mutter("smart add of %r" % f)
52
45
if bzrlib.branch.is_control_file(af):
53
46
bailout("cannot add control file %r" % af)
55
48
kind = bzrlib.osutils.file_kind(f)
50
if kind != 'file' and kind != 'directory':
51
bailout("can't add file of kind %r" % kind)
56
53
versioned = (inv.path2id(rf) != None)
58
## TODO: It's OK to add '.' but only in recursive mode
62
bzrlib.warning("%r is already versioned" % f)
66
elif kind == 'directory':
67
if versioned and not recurse:
68
bzrlib.warning("%r is already versioned" % f)
75
for subf in os.listdir(af):
76
subp = appendpath(rf, subf)
77
if tree.is_ignored(subp):
78
mutter("skip ignored sub-file %r" % subp)
80
mutter("queue to add sub-file %r" % (subp))
81
file_list.append(subp)
56
bzrlib.warning("%r is already versioned" % f)
83
bailout("can't smart_add file kind %r" % kind)
58
file_id = bzrlib.branch.gen_file_id(rf)
59
inv.add_path(rf, kind=kind, file_id=file_id)
60
bzrlib.mutter("added %r kind %r file_id={%s}" % (rf, kind, file_id))
63
bzrlib.textui.show_status('A', kind, quotefn(f))
65
if kind == 'directory' and recurse:
66
for subf in os.listdir(af):
67
subp = appendpath(rf, subf)
68
if tree.is_ignored(subp):
69
mutter("skip ignored sub-file %r" % subp)
71
mutter("queue to add sub-file %r" % (subp))
72
file_list.append(subp)
75
print '* added %d' % count
86
76
b._write_inventory(inv)