~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commands.py

  • Committer: mbp at sourcefrog
  • Date: 2005-04-06 03:38:35 UTC
  • Revision ID: mbp@sourcefrog.net-20050406033835-0a8142f2ed51db26f3a3681c
- Use a non-null file_id for the branch root directory.  At the moment
  this is fixed; in the future it should be stored in the directory
  and perhaps be randomized at each branch init.  It is not written
  out to the inventory at all as yet.

- Various branch code cleanups to support this.

- If an exception occurs, log traceback into .bzr.log and print a
  message saying it's there.

- New file-id-path command and more help.

- Some pychecker fixups.

- InventoryEntry constructor parameters now require an entry kind and
  a parent_id.

- Fix up cat command when reading a file from a previous revision.

Show diffs side-by-side

added added

removed removed

Lines of Context:
264
264
 
265
265
 
266
266
def cmd_file_id(filename):
 
267
    """Print file_id of a particular file or directory.
 
268
 
 
269
usage: bzr file-id FILE
 
270
 
 
271
The file_id is assigned when the file is first added and remains the
 
272
same through all revisions where the file exists, even when it is
 
273
moved or renamed.
 
274
"""
267
275
    b = Branch(filename)
268
276
    i = b.inventory.path2id(b.relpath(filename))
269
 
    if i is None:
270
 
        bailout("%s is not a versioned file" % filename)
 
277
    if i == None:
 
278
        bailout("%r is not a versioned file" % filename)
271
279
    else:
272
280
        print i
273
281
 
274
282
 
 
283
def cmd_file_id_path(filename):
 
284
    """Print path of file_ids to a file or directory.
 
285
 
 
286
usage: bzr file-id-path FILE
 
287
 
 
288
This prints one line for each directory down to the target,
 
289
starting at the branch root."""
 
290
    b = Branch(filename)
 
291
    inv = b.inventory
 
292
    fid = inv.path2id(b.relpath(filename))
 
293
    if fid == None:
 
294
        bailout("%r is not a versioned file" % filename)
 
295
    for fip in inv.get_idpath(fid):
 
296
        print fip
 
297
 
 
298
 
275
299
def cmd_find_filename(fileid):
276
300
    n = find_filename(fileid)
277
301
    if n is None:
748
772
    'diff':                   [],
749
773
    'export':                 ['revno', 'dest'],
750
774
    'file-id':                ['filename'],
 
775
    'file-id-path':           ['filename'],
751
776
    'get-file-text':          ['text_id'],
752
777
    'get-inventory':          ['inventory_id'],
753
778
    'get-revision':           ['revision_id'],
971
996
        if len(e.args) > 1:
972
997
            for h in e.args[1]:
973
998
                log_error('  ' + h + '\n')
 
999
        traceback.print_exc(None, bzrlib.trace._tracefile)
 
1000
        log_error('see ~/.bzr.log for more information\n')
974
1001
        return 1
975
1002
    except Exception, e:
976
1003
        log_error('bzr: exception: %s\n' % e)