28
25
* Metadata format is not stable yet -- you may need to
29
26
discard history in the future.
31
* No handling of subdirectories, symlinks or any non-text files.
33
28
* Insufficient error handling.
35
30
* Many commands unimplemented or partially implemented.
60
55
Show summary of pending changes.
62
57
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"
77
65
import sys, os, random, time, sha, sets, types, re, shutil, tempfile
184
172
Therefore simply saying 'bzr add .' will version all files that
185
173
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)
175
bzrlib.add.smart_add(file_list, verbose)
197
178
def cmd_relpath(filename):
179
"""Show path of file relative to root"""
198
180
print Branch(filename).relpath(filename)
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,
200
info.show_info(Branch('.'))
312
246
def cmd_diff(revision=None):
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.
247
"""bzr diff: Show differences in working tree.
249
usage: bzr diff [-r REV]
252
Show changes since REV, rather than predecessor.
254
TODO: Given two revision arguments, show the difference between them.
256
TODO: Allow diff across branches.
258
TODO: Option to use external diff command; could be GNU diff, wdiff,
261
TODO: Diff selected files.
264
## TODO: Shouldn't be in the cmd function.
478
419
def cmd_commit(message=None, verbose=False):
420
"""Commit changes to a new revision.
423
Description of changes in this revision; free form text.
424
It is recommended that the first line be a single-sentence
427
Show status of changed files,
429
TODO: Commit only selected files.
431
TODO: Run hooks on tree to-be-committed, and after commit.
433
TODO: Strict commit that fails if there are unknown or deleted files.
480
437
bailout("please specify a commit message")
481
438
Branch('.').commit(message, verbose=verbose)
557
# TODO: Specific help for particular commands
513
def cmd_help(topic=None):
518
# otherwise, maybe the name of a command?
520
cmdfn = globals()['cmd_' + topic.replace('-', '_')]
522
bailout("no help for %r" % topic)
526
bailout("sorry, no detailed help yet for %r" % topic)
561
533
def cmd_version():
562
print "bzr (bazaar-ng) %s" % __version__
534
print "bzr (bazaar-ng) %s" % bzrlib.__version__
535
print bzrlib.__copyright__
564
536
print "http://bazaar-ng.org/"
618
589
'add': ['file+'],
592
'export': ['revno', 'dest'],
621
593
'file-id': ['filename'],
622
'root': ['filename?'],
623
'relpath': ['filename'],
624
594
'get-file-text': ['text_id'],
625
595
'get-inventory': ['inventory_id'],
626
596
'get-revision': ['revision_id'],
627
597
'get-revision-inventory': ['revision_id'],
629
601
'lookup-revision': ['revno'],
630
'export': ['revno', 'dest'],
602
'relpath': ['filename'],
631
603
'remove': ['file+'],
604
'root': ['filename?'],