199
def cmd_mv(source_list, dest):
202
b.rename([b.relpath(s) for s in source_list], b.relpath(dest))
206
def cmd_rename(from_name, to_name):
207
"""Change the name of an entry.
209
usage: bzr rename FROM_NAME TO_NAME
212
bzr rename frob.c frobber.c
213
bzr rename src/frob.c lib/frob.c
215
It is an error if the destination name exists.
217
See also the 'move' command, which moves files into a different
218
directory without changing their name.
220
TODO: Some way to rename multiple files without invoking bzr for each
223
b.rename_one(b.relpath(from_name), b.relpath(to_name))
228
def cmd_renames(dir='.'):
229
"""Show list of renamed files.
231
usage: bzr renames [BRANCH]
233
TODO: Option to show renames between two historical versions.
235
TODO: Only show renames under dir, rather than in the whole branch.
238
old_inv = b.basis_tree().inventory
239
new_inv = b.read_working_inventory()
241
renames = list(bzrlib.tree.find_renames(old_inv, new_inv))
243
for old_name, new_name in renames:
244
print "%s => %s" % (old_name, new_name)
249
199
"""info: Show statistical information for this branch
363
301
# FIXME: Something about the diff format makes patch unhappy
364
302
# with newly-added files.
366
def diffit(oldlines, newlines, **kw):
367
# FIXME: difflib is wrong if there is no trailing newline.
369
# Special workaround for Python2.3, where difflib fails if
370
# both sequences are empty.
371
if oldlines or newlines:
372
sys.stdout.writelines(difflib.unified_diff(oldlines, newlines, **kw))
304
def diffit(*a, **kw):
305
sys.stdout.writelines(difflib.unified_diff(*a, **kw))
375
308
if file_state in ['.', '?', 'I']:
409
def cmd_deleted(show_ids=False):
410
"""List files deleted in the working tree.
412
TODO: Show files deleted since a previous revision, or between two revisions.
416
new = b.working_tree()
418
## TODO: Much more efficient way to do this: read in new
419
## directories with readdir, rather than stating each one. Same
420
## level of effort but possibly much less IO. (Or possibly not,
421
## if the directories are very large...)
423
for path, ie in old.inventory.iter_entries():
424
if not new.has_id(ie.file_id):
426
print '%-50s %s' % (path, ie.file_id)
432
def cmd_parse_inventory():
435
cElementTree.ElementTree().parse(file('.bzr/inventory'))
439
def cmd_load_inventory():
440
inv = Branch('.').basis_tree().inventory
444
def cmd_dump_new_inventory():
445
import bzrlib.newinventory
446
inv = Branch('.').basis_tree().inventory
447
bzrlib.newinventory.write_inventory(inv, sys.stdout)
450
def cmd_load_new_inventory():
451
import bzrlib.newinventory
452
bzrlib.newinventory.read_new_inventory(sys.stdin)
455
def cmd_dump_slacker_inventory():
456
import bzrlib.newinventory
457
inv = Branch('.').basis_tree().inventory
458
bzrlib.newinventory.write_slacker_inventory(inv, sys.stdout)
462
342
def cmd_root(filename=None):
463
343
"""Print the branch root."""
464
344
print bzrlib.branch.find_branch_root(filename)
508
def cmd_ignored(verbose=True):
509
"""List ignored files and the patterns that matched them.
511
tree = Branch('.').working_tree()
512
for path, file_class, kind, id in tree.list_files():
513
if file_class != 'I':
515
## XXX: Slightly inefficient since this was already calculated
516
pat = tree.is_ignored(path)
517
print '%-50s %s' % (path, pat)
520
387
def cmd_lookup_revision(revno):
522
389
revno = int(revno)
724
590
'add': ['verbose'],
725
591
'commit': ['message', 'verbose'],
726
'deleted': ['show-ids'],
727
592
'diff': ['revision'],
728
593
'inventory': ['revision'],
594
'log': ['show-ids', 'timezone'],
730
595
'ls': ['revision', 'verbose'],
731
596
'remove': ['verbose'],
732
597
'status': ['all'],
749
614
'lookup-revision': ['revno'],
750
'mv': ['source$', 'dest'],
751
615
'relpath': ['filename'],
752
616
'remove': ['file+'],
753
'rename': ['from_name', 'to_name'],
755
617
'root': ['filename?'],
854
717
argdict[argname + '_list'] = args[:]
856
elif ap[-1] == '$': # all but one
858
bailout("command %r needs one or more %s"
859
% (cmd, argname.upper()))
860
argdict[argname + '_list'] = args[:-1]
863
720
# just a plain arg
907
761
bailout("unknown command " + `cmd`)
910
if 'profile' in opts:
763
# TODO: special --profile option to turn on the Python profiler
916
765
# check options are reasonable
917
766
allowed = cmd_options.get(cmd, [])
920
769
bailout("option %r is not allowed for command %r"
923
# mix arguments and options into one dictionary
924
772
cmdargs = _match_args(cmd, args)
925
for k, v in opts.items():
926
cmdargs[k.replace('-', '_')] = v
930
prof = hotshot.Profile('.bzr.profile')
931
ret = prof.runcall(cmd_handler, **cmdargs) or 0
935
stats = hotshot.stats.load('.bzr.profile')
937
stats.sort_stats('time')
938
stats.print_stats(20)
940
return cmd_handler(**cmdargs) or 0
775
ret = cmd_handler(**cmdargs) or 0