54
54
from bzrlib.revisionspec import RevisionSpec
55
55
from bzrlib.trace import mutter, note, log_error, warning, is_quiet, info
56
56
from bzrlib.transport.local import LocalTransport
57
58
from bzrlib.workingtree import WorkingTree
361
362
"""Show inventory of the current working copy or a revision.
363
364
It is possible to limit the output to a particular entry
364
type using the --kind option. For example; --kind file.
365
type using the --kind option. For example: --kind file.
367
It is also possible to restrict the list of files to a specific
368
set. For example: bzr inventory --show-ids this/file
367
371
takes_options = ['revision', 'show-ids', 'kind']
372
takes_args = ['file*']
370
def run(self, revision=None, show_ids=False, kind=None):
375
def run(self, revision=None, show_ids=False, kind=None, file_list=None):
371
376
if kind and kind not in ['file', 'directory', 'symlink']:
372
377
raise BzrCommandError('invalid kind specified')
373
tree = WorkingTree.open_containing(u'.')[0]
375
inv = tree.read_working_inventory()
379
work_tree, file_list = tree_files(file_list)
381
if revision is not None:
377
382
if len(revision) > 1:
378
383
raise BzrCommandError('bzr inventory --revision takes'
379
' exactly one revision identifier')
380
inv = tree.branch.repository.get_revision_inventory(
381
revision[0].in_history(tree.branch).rev_id)
383
for path, entry in inv.entries():
384
' exactly one revision identifier')
385
revision_id = revision[0].in_history(work_tree.branch).rev_id
386
tree = work_tree.branch.repository.revision_tree(revision_id)
388
# We include work_tree as well as 'tree' here
389
# So that doing '-r 10 path/foo' will lookup whatever file
390
# exists now at 'path/foo' even if it has been renamed, as
391
# well as whatever files existed in revision 10 at path/foo
392
trees = [tree, work_tree]
397
if file_list is not None:
398
file_ids = bzrlib.tree.find_ids_across_trees(file_list, trees,
399
require_versioned=True)
400
# find_ids_across_trees may include some paths that don't
402
entries = sorted((tree.id2path(file_id), tree.inventory[file_id])
403
for file_id in file_ids if file_id in tree)
405
entries = tree.inventory.entries()
407
for path, entry in entries:
384
408
if kind and kind != entry.kind:
2327
2352
class cmd_revert(Command):
2328
"""Reverse all changes since the last commit.
2330
Only versioned files are affected. Specify filenames to revert only
2331
those files. By default, any files that are changed will be backed up
2332
first. Backup files have a '~' appended to their name.
2353
"""Revert files to a previous revision.
2355
Giving a list of files will revert only those files. Otherwise, all files
2356
will be reverted. If the revision is not specified with '--revision', the
2357
last committed revision is used.
2359
To remove only some changes, without reverting to a prior version, use
2360
merge instead. For example, "merge . --r-2..-3" will remove the changes
2361
introduced by -2, without affecting the changes introduced by -1. Or
2362
to remove certain changes on a hunk-by-hunk basis, see the Shelf plugin.
2364
By default, any files that have been manually changed will be backed up
2365
first. (Files changed only by merge are not backed up.) Backup files have
2366
'.~#~' appended to their name, where # is a number.
2368
When you provide files, you can use their current pathname or the pathname
2369
from the target revision. So you can use revert to "undelete" a file by
2370
name. If you name a directory, all the contents of that directory will be
2334
2373
takes_options = ['revision', 'no-backup']
2335
2374
takes_args = ['file*']
2902
2941
# we do need to load at least some information about them to know of
2903
2942
# aliases. ideally we would avoid loading the implementation until the
2904
2943
# details were needed.
2944
from bzrlib.cmd_version_info import cmd_version_info
2905
2945
from bzrlib.conflicts import cmd_resolve, cmd_conflicts, restore
2906
2946
from bzrlib.bundle.commands import cmd_bundle_revisions
2907
2947
from bzrlib.sign_my_commits import cmd_sign_my_commits