/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/add.py

  • Committer: Martin Pool
  • Date: 2005-08-29 07:13:09 UTC
  • Revision ID: mbp@sourcefrog.net-20050829071309-2c62f851915b9825
- bzr log --show-ids includes parent ids

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
 
19
19
def glob_expand_for_win32(file_list):
20
20
    import glob
31
31
            expanded_file_list += glob_files
32
32
    return expanded_file_list
33
33
 
 
34
 
34
35
def smart_add(file_list, verbose=True, recurse=True):
35
36
    """Add files to version, optionally recursing into directories.
36
37
 
37
38
    This is designed more towards DWIM for humans than API simplicity.
38
39
    For the specific behaviour see the help for cmd_add().
 
40
 
 
41
    This yields a sequence of (path, kind, file_id) for added files.
39
42
    """
40
43
    import os
41
44
    import sys
42
 
    from bzrlib.osutils import quotefn, kind_marker
 
45
    from bzrlib.osutils import quotefn
43
46
    from bzrlib.errors import BadFileKindError, ForbiddenFileError
44
47
    import bzrlib.branch
45
48
    import bzrlib.osutils
67
70
            if f in user_list:
68
71
                raise BadFileKindError("cannot add %s of type %s" % (f, kind))
69
72
            else:
70
 
                print "skipping %s (can't add file of kind '%s')" % (f, kind)
 
73
                warning("skipping %s (can't add file of kind '%s')", f, kind)
71
74
                continue
72
75
 
73
76
        mutter("smart add of %r, abs=%r" % (f, af))
87
90
            mutter("added %r kind %r file_id={%s}" % (rf, kind, file_id))
88
91
            count += 1 
89
92
 
90
 
            print 'added', quotefn(f)
 
93
            yield f, kind, file_id
 
94
 
91
95
 
92
96
        if kind == 'directory' and recurse:
93
97
            for subf in os.listdir(af):
100
104
                    mutter("queue to add sub-file %r" % subp)
101
105
                    file_list.append(b.abspath(subp))
102
106
 
 
107
 
103
108
    if count > 0:
104
109
        if verbose:
105
 
            note('added %d' % count)
 
110
            note('added %d entries', count)
106
111
        b._write_inventory(inv)
107
 
    else:
108
 
        print "nothing new to add"
109
 
        # should this return 1 to the shell?
 
112