498
498
that, you can supply --revision to force the state of the tree.
501
takes_options = ['revision']
501
takes_options = ['revision', 'directory',
503
help='Reset the tree even if it doesn\'t appear to be'
504
def run(self, revision=None):
508
def run(self, revision=None, directory='.', force=False):
509
tree, _ = WorkingTree.open_containing(directory)
510
self.add_cleanup(tree.lock_tree_write().unlock)
514
except errors.BzrError:
515
pass # There seems to be a real error here, so we'll reset
518
raise errors.BzrCommandError(
519
'The tree does not appear to be corrupt. You probably'
520
' want "bzr revert" instead. Use "--force" if you are'
521
' sure you want to reset the working tree.')
525
revision_ids = [r.as_revision_id(tree.branch) for r in revision]
527
tree.reset_state(revision_ids)
528
except errors.BzrError, e:
529
if revision_ids is None:
530
extra = (', the header appears corrupt, try passing -r -1'
531
' to set the state to the last commit')
534
raise errors.BzrCommandError('failed to reset the tree state'
508
538
class cmd_revno(Command):