~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/add.py

  • Committer: Martin Pool
  • Date: 2005-08-29 10:57:01 UTC
  • mfrom: (1092.1.41)
  • Revision ID: mbp@sourcefrog.net-20050829105701-7aaa81ecf1bfee05
- merge in merge improvements and additional tests 
  from aaron and lifeless

robertc@robertcollins.net-20050825131100-85772edabc817481

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 trace import mutter, note
 
17
from bzrlib.trace import mutter, note, warning
18
18
from bzrlib.errors import NotBranchError
19
19
from bzrlib.branch import Branch
 
20
from bzrlib.osutils import quotefn
20
21
 
21
22
def glob_expand_for_win32(file_list):
22
23
    import glob
33
34
            expanded_file_list += glob_files
34
35
    return expanded_file_list
35
36
 
36
 
def _NullAddCallback(entry):
 
37
 
 
38
def _NullAddCallback(path, kind, entry):
37
39
    pass
38
40
 
39
 
def _PrintAddCallback(entry):
40
 
    from bzrlib.osutils import quotefn
41
 
    print "added", quotefn(entry.name)
 
41
def _PrintAddCallback(path, kind, entry):
 
42
    print "added", quotefn(path)
42
43
    
43
44
def _prepare_file_list(file_list):
44
45
    """Prepare a file list for use by smart_add_*."""
67
68
 
68
69
    This is designed more towards DWIM for humans than API simplicity.
69
70
    For the specific behaviour see the help for cmd_add().
 
71
 
 
72
    This yields a sequence of (path, kind, file_id) for added files.
70
73
    """
71
74
    import os
72
75
    import sys
91
94
            if f in user_list:
92
95
                raise BadFileKindError("cannot add %s of type %s" % (f, kind))
93
96
            else:
94
 
                print "skipping %s (can't add file of kind '%s')" % (f, kind)
 
97
                warning("skipping %s (can't add file of kind '%s')", f, kind)
95
98
                continue
96
99
 
97
100
        mutter("smart add of %r, abs=%r" % (f, af))
121
124
            entry = inv.add_path(rf, kind=kind)
122
125
            mutter("added %r kind %r file_id={%s}" % (rf, kind, entry.file_id))
123
126
            count += 1 
124
 
            callback(entry)
 
127
            callback(rf, kind, entry)
125
128
 
126
129
        if kind == 'directory' and recurse and not sub_tree:
127
130
            for subf in os.listdir(af):
134
137
                    mutter("queue to add sub-file %r" % subp)
135
138
                    file_list.append(branch.abspath(subp))
136
139
 
 
140
 
137
141
    if count > 0:
138
142
        if verbose:
139
143
            note('added %d' % count)
140
144
        branch._write_inventory(inv)
141
145
    else:
142
 
        print "nothing new to add"
 
146
        note("nothing new to add")
143
147
        # should this return 1 to the shell?