[Pkg-bazaar-commits] ./bzr/unstable r87: - clean up smart_add code, and make it commit the inventory
mbp at sourcefrog.net
mbp at sourcefrog.net
Fri Apr 10 07:51:06 UTC 2009
------------------------------------------------------------
revno: 87
committer: mbp at sourcefrog.net
timestamp: Fri 2005-03-25 14:09:43 +1100
message:
- clean up smart_add code, and make it commit the inventory
when done.
still not perfect handling of already-versioned files.
modified:
bzrlib/add.py
bzrlib/commands.py
-------------- next part --------------
=== modified file 'bzrlib/add.py'
--- a/bzrlib/add.py 2005-03-25 02:58:34 +0000
+++ b/bzrlib/add.py 2005-03-25 03:09:43 +0000
@@ -32,55 +32,45 @@
b = bzrlib.branch.Branch(file_list[0], find_root=True)
inv = b.read_working_inventory()
tree = b.working_tree()
- dirty = False
-
- def add_one(rf, kind):
- file_id = bzrlib.branch.gen_file_id(rf)
- inv.add_path(rf, kind=kind, file_id=file_id)
- bzrlib.mutter("added %r kind %r file_id={%s}" % (rf, kind, file_id))
- dirty = True
- if verbose:
- bzrlib.textui.show_status('A', kind, quotefn(f))
-
+ count = 0
for f in file_list:
rf = b.relpath(f)
af = b.abspath(rf)
+ ## TODO: It's OK to add root but only in recursive mode
+
bzrlib.mutter("smart add of %r" % f)
if bzrlib.branch.is_control_file(af):
bailout("cannot add control file %r" % af)
kind = bzrlib.osutils.file_kind(f)
+
+ if kind != 'file' and kind != 'directory':
+ bailout("can't add file of kind %r" % kind)
+
versioned = (inv.path2id(rf) != None)
- ## TODO: It's OK to add '.' but only in recursive mode
-
- if kind == 'file':
- if versioned:
- bzrlib.warning("%r is already versioned" % f)
- continue
- else:
- add_one(rf, kind)
- elif kind == 'directory':
- if versioned and not recurse:
- bzrlib.warning("%r is already versioned" % f)
- continue
-
- if not versioned:
- add_one(rf, kind)
-
- if recurse:
- for subf in os.listdir(af):
- subp = appendpath(rf, subf)
- if tree.is_ignored(subp):
- mutter("skip ignored sub-file %r" % subp)
- else:
- mutter("queue to add sub-file %r" % (subp))
- file_list.append(subp)
+ if versioned:
+ bzrlib.warning("%r is already versioned" % f)
else:
- bailout("can't smart_add file kind %r" % kind)
-
- if dirty:
+ file_id = bzrlib.branch.gen_file_id(rf)
+ inv.add_path(rf, kind=kind, file_id=file_id)
+ bzrlib.mutter("added %r kind %r file_id={%s}" % (rf, kind, file_id))
+ count += 1
+ if verbose:
+ bzrlib.textui.show_status('A', kind, quotefn(f))
+
+ if kind == 'directory' and recurse:
+ for subf in os.listdir(af):
+ subp = appendpath(rf, subf)
+ if tree.is_ignored(subp):
+ mutter("skip ignored sub-file %r" % subp)
+ else:
+ mutter("queue to add sub-file %r" % (subp))
+ file_list.append(subp)
+
+ if count > 0:
+ print '* added %d' % count
b._write_inventory(inv)
=== modified file 'bzrlib/commands.py'
--- a/bzrlib/commands.py 2005-03-25 01:17:55 +0000
+++ b/bzrlib/commands.py 2005-03-25 03:09:43 +0000
@@ -172,17 +172,11 @@
Therefore simply saying 'bzr add .' will version all files that
are currently unknown.
"""
- if True:
- bzrlib.add.smart_add(file_list, verbose)
- else:
- # old way
- assert file_list
- b = Branch(file_list[0], find_root=True)
- b.add([b.relpath(f) for f in file_list], verbose=verbose)
-
+ bzrlib.add.smart_add(file_list, verbose)
def cmd_relpath(filename):
+ """Show path of file relative to root"""
print Branch(filename).relpath(filename)
More information about the Pkg-bazaar-commits
mailing list