25
28
* Metadata format is not stable yet -- you may need to
26
29
discard history in the future.
31
* No handling of subdirectories, symlinks or any non-text files.
28
33
* Insufficient error handling.
30
35
* Many commands unimplemented or partially implemented.
55
60
Show summary of pending changes.
57
62
Make a file not versioned.
59
Show statistics about this branch.
65
# not currently working:
67
# Show some information about this branch.
71
__copyright__ = "Copyright 2005 Canonical Development Ltd."
72
__author__ = "Martin Pool <mbp@canonical.com>"
73
__docformat__ = "restructuredtext en"
65
77
import sys, os, random, time, sha, sets, types, re, shutil, tempfile
172
184
Therefore simply saying 'bzr add .' will version all files that
173
185
are currently unknown.
175
bzrlib.add.smart_add(file_list, verbose)
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)
178
197
def cmd_relpath(filename):
179
"""Show path of file relative to root"""
180
198
print Branch(filename).relpath(filename)
199
"""info: Show statistical information for this branch
203
info.show_info(Branch('.'))
218
print 'branch format:', b.controlfile('branch-format', 'r').readline().rstrip('\n')
220
def plural(n, base='', pl=None):
228
count_version_dirs = 0
230
count_status = {'A': 0, 'D': 0, 'M': 0, 'R': 0, '?': 0, 'I': 0, '.': 0}
231
for st_tup in bzrlib.diff_trees(b.basis_tree(), b.working_tree()):
233
count_status[fs] += 1
234
if fs not in ['I', '?'] and st_tup[4] == 'directory':
235
count_version_dirs += 1
238
print 'in the working tree:'
239
for name, fs in (('unchanged', '.'),
240
('modified', 'M'), ('added', 'A'), ('removed', 'D'),
241
('renamed', 'R'), ('unknown', '?'), ('ignored', 'I'),
243
print ' %5d %s' % (count_status[fs], name)
244
print ' %5d versioned subdirector%s' % (count_version_dirs,
245
plural(count_version_dirs, 'y', 'ies'))
248
print 'branch history:'
249
history = b.revision_history()
251
print ' %5d revision%s' % (revno, plural(revno))
254
committers.add(b.get_revision(rev).committer)
255
print ' %5d committer%s' % (len(committers), plural(len(committers)))
257
firstrev = b.get_revision(history[0])
258
age = int((time.time() - firstrev.timestamp) / 3600 / 24)
259
print ' %5d day%s old' % (age, plural(age))
260
print ' first revision: %s' % format_date(firstrev.timestamp,
263
lastrev = b.get_revision(history[-1])
264
print ' latest revision: %s' % format_date(lastrev.timestamp,
249
312
def cmd_diff(revision=None):
250
"""bzr diff: Show differences in working tree.
252
usage: bzr diff [-r REV]
255
Show changes since REV, rather than predecessor.
257
TODO: Given two revision arguments, show the difference between them.
259
TODO: Allow diff across branches.
261
TODO: Option to use external diff command; could be GNU diff, wdiff,
264
TODO: Diff selected files.
267
## TODO: Shouldn't be in the cmd function.
313
"""Show diff from basis to working copy.
315
:todo: Take one or two revision arguments, look up those trees,
318
:todo: Allow diff across branches.
320
:todo: Mangle filenames in diff to be more relevant.
322
:todo: Shouldn't be in the cmd function.
422
478
def cmd_commit(message=None, verbose=False):
423
"""Commit changes to a new revision.
426
Description of changes in this revision; free form text.
427
It is recommended that the first line be a single-sentence
430
Show status of changed files,
432
TODO: Commit only selected files.
434
TODO: Run hooks on tree to-be-committed, and after commit.
436
TODO: Strict commit that fails if there are unknown or deleted files.
440
480
bailout("please specify a commit message")
441
481
Branch('.').commit(message, verbose=verbose)
444
def cmd_check(dir='.'):
445
"""check: Consistency check of branch history.
447
usage: bzr check [-v] [BRANCH]
450
--verbose, -v Show progress of checking.
452
This command checks various invariants about the branch storage to
453
detect data corruption or bzr bugs.
456
bzrlib.check.check(Branch(dir, find_root=False))
485
"""Check consistency of the branch."""
459
489
def cmd_is(pred, *rest):
526
def cmd_help(topic=None):
531
# otherwise, maybe the name of a command?
533
cmdfn = globals()['cmd_' + topic.replace('-', '_')]
535
bailout("no help for %r" % topic)
539
bailout("sorry, no detailed help yet for %r" % topic)
557
# TODO: Specific help for particular commands
546
561
def cmd_version():
547
print "bzr (bazaar-ng) %s" % bzrlib.__version__
548
print bzrlib.__copyright__
562
print "bzr (bazaar-ng) %s" % __version__
549
564
print "http://bazaar-ng.org/"
602
618
'add': ['file+'],
605
'export': ['revno', 'dest'],
606
621
'file-id': ['filename'],
622
'root': ['filename?'],
623
'relpath': ['filename'],
607
624
'get-file-text': ['text_id'],
608
625
'get-inventory': ['inventory_id'],
609
626
'get-revision': ['revision_id'],
610
627
'get-revision-inventory': ['revision_id'],
614
629
'lookup-revision': ['revno'],
615
'relpath': ['filename'],
630
'export': ['revno', 'dest'],
616
631
'remove': ['file+'],
617
'root': ['filename?'],