33
33
expanded_file_list += glob_files
34
34
return expanded_file_list
36
def _prepare_file_list(file_list):
37
"""Prepare a file list for use by smart_add_*."""
39
if sys.platform == 'win32':
40
file_list = glob_expand_for_win32(file_list)
43
file_list = list(file_list)
44
assert not isinstance(file_list, basestring)
36
47
def smart_add(file_list, verbose=True, recurse=True):
37
48
"""Add files to version, optionally recursing into directories.
39
50
This is designed more towards DWIM for humans than API simplicity.
40
51
For the specific behaviour see the help for cmd_add().
53
file_list = _prepare_file_list(file_list)
54
b = Branch(file_list[0], find_root=True)
55
return smart_add_branch(b, file_list, verbose, recurse)
57
def smart_add_branch(branch, file_list, verbose=True, recurse=True):
58
"""Add files to version, optionally recursing into directories.
60
This is designed more towards DWIM for humans than API simplicity.
61
For the specific behaviour see the help for cmd_add().
44
65
from bzrlib.osutils import quotefn
46
67
import bzrlib.branch
47
68
import bzrlib.osutils
49
if sys.platform == 'win32':
50
file_list = glob_expand_for_win32(file_list)
70
file_list = _prepare_file_list(file_list)
55
71
user_list = file_list[:]
56
file_list = list(file_list)
57
assert not isinstance(file_list, basestring)
58
b = Branch(file_list[0], find_root=True)
59
inv = b.read_working_inventory()
60
tree = b.working_tree()
72
inv = branch.read_working_inventory()
73
tree = branch.working_tree()
63
76
for f in file_list:
77
rf = branch.relpath(f)
78
af = branch.abspath(rf)
67
80
kind = bzrlib.osutils.file_kind(af)
113
126
mutter("skip ignored sub-file %r" % subp)
115
128
mutter("queue to add sub-file %r" % subp)
116
file_list.append(b.abspath(subp))
129
file_list.append(branch.abspath(subp))
120
133
note('added %d' % count)
121
b._write_inventory(inv)
134
branch._write_inventory(inv)
123
136
print "nothing new to add"
124
137
# should this return 1 to the shell?