165
165
print Branch('.').revno()
168
169
def cmd_add(file_list, verbose=False):
169
"""Add specified files.
170
"""Add specified files or directories.
172
In non-recursive mode, all the named items are added, regardless
173
of whether they were previously ignored. A warning is given if
174
any of the named files are already versioned.
176
In recursive mode (the default), files are treated the same way
177
but the behaviour for directories is different. Directories that
178
are already versioned do not give a warning. All directories,
179
whether already versioned or not, are searched for files or
180
subdirectories that are neither versioned or ignored, and these
181
are added. This search proceeds recursively into versioned
184
Therefore simply saying 'bzr add .' will version all files that
185
are currently unknown.
188
bzrlib.add.smart_add(file_list, verbose)
192
b = Branch(file_list[0], find_root=True)
193
b.add([b.relpath(f) for f in file_list], verbose=verbose)
171
Fails if the files are already added.
173
Branch('.').add(file_list, verbose=verbose)
197
def cmd_relpath(filename):
198
print Branch(filename).relpath(filename)
176
201
def cmd_inventory(revision=None):
245
270
def cmd_remove(file_list, verbose=False):
246
Branch('.').remove(file_list, verbose=verbose)
271
b = Branch(file_list[0])
272
b.remove([b.relpath(f) for f in file_list], verbose=verbose)
250
276
def cmd_file_id(filename):
251
i = Branch('.').read_working_inventory().path2id(filename)
278
i = b.inventory.path2id(b.relpath(filename))
253
280
bailout("%s is not a versioned file" % filename)
398
def cmd_root(filename=None):
399
"""Print the branch root."""
400
print bzrlib.branch.find_branch_root(filename)
371
403
def cmd_log(timezone='original'):
372
404
"""Show log of this branch.
446
def cmd_commit(message, verbose=False):
478
def cmd_commit(message=None, verbose=False):
480
bailout("please specify a commit message")
447
481
Branch('.').commit(message, verbose=verbose)
480
514
print bzrlib.branch._gen_revision_id(time.time())
484
"""Run internal doctest suite"""
517
def cmd_selftest(verbose=False):
518
"""Run internal test suite"""
485
519
## -v, if present, is seen by doctest; the argument is just here
486
520
## so our parser doesn't complain
488
522
## TODO: --verbose option
524
failures, tests = 0, 0
490
import doctest, bzrlib.store
526
import doctest, bzrlib.store, bzrlib.tests
491
527
bzrlib.trace.verbose = False
492
doctest.testmod(bzrlib.store)
493
doctest.testmod(bzrlib.inventory)
494
doctest.testmod(bzrlib.branch)
495
doctest.testmod(bzrlib.osutils)
496
doctest.testmod(bzrlib.tree)
498
# more strenuous tests;
500
doctest.testmod(bzrlib.tests)
503
cmd_selftest = cmd_doctest
529
for m in bzrlib.store, bzrlib.inventory, bzrlib.branch, bzrlib.osutils, \
530
bzrlib.tree, bzrlib.tests, bzrlib.commands, bzrlib.add:
531
mf, mt = doctest.testmod(m)
534
print '%-40s %3d tests' % (m.__name__, mt),
536
print '%3d FAILED!' % mf
540
print '%-40s %3d tests' % ('total', tests),
542
print '%3d FAILED!' % failures
549
cmd_doctest = cmd_selftest
506
552
######################################################################
747
797
## TODO: If the arguments are wrong, give a usage message rather
748
798
## than just a backtrace.
800
bzrlib.trace.create_tracefile(argv)
751
# TODO: Lift into separate function in trace.py
752
# TODO: Also show contents of /etc/lsb-release, if it can be parsed.
753
# Perhaps that should eventually go into the platform library?
754
# TODO: If the file doesn't exist, add a note describing it.
755
t = bzrlib.trace._tracefile
756
t.write('-' * 60 + '\n')
757
t.write('bzr invoked at %s\n' % format_date(time.time()))
758
t.write(' by %s on %s\n' % (bzrlib.osutils.username(), socket.getfqdn()))
759
t.write(' arguments: %r\n' % argv)
761
starttime = os.times()[4]
764
t.write(' platform: %s\n' % platform.platform())
765
t.write(' python: %s\n' % platform.python_version())
767
803
ret = run_bzr(argv)
770
mutter("finished, %.3fu/%.3fs cpu, %.3fu/%.3fs cum"
772
mutter(" %.3f elapsed" % (times[4] - starttime))
775
805
except BzrError, e:
776
806
log_error('bzr: error: ' + e.args[0] + '\n')