1
# Copyright (C) 2005-2010 Canonical Ltd
1
# Copyright (C) 2004-2010 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
55
55
from bzrlib.branch import Branch
56
56
from bzrlib.conflicts import ConflictList
57
from bzrlib.transport import memory
58
57
from bzrlib.revisionspec import RevisionSpec, RevisionInfo
59
58
from bzrlib.smtp_connection import SMTPConnection
60
59
from bzrlib.workingtree import WorkingTree
453
452
To re-create the working tree, use "bzr checkout".
455
454
_see_also = ['checkout', 'working-trees']
456
takes_args = ['location*']
455
takes_args = ['location?']
457
456
takes_options = [
459
458
help='Remove the working tree even if it has '
460
459
'uncommitted changes.'),
463
def run(self, location_list, force=False):
464
if not location_list:
467
for location in location_list:
468
d = bzrdir.BzrDir.open(location)
471
working = d.open_workingtree()
472
except errors.NoWorkingTree:
473
raise errors.BzrCommandError("No working tree to remove")
474
except errors.NotLocalUrl:
475
raise errors.BzrCommandError("You cannot remove the working tree"
478
if (working.has_changes()):
479
raise errors.UncommittedChanges(working)
481
working_path = working.bzrdir.root_transport.base
482
branch_path = working.branch.bzrdir.root_transport.base
483
if working_path != branch_path:
484
raise errors.BzrCommandError("You cannot remove the working tree"
485
" from a lightweight checkout")
487
d.destroy_workingtree()
462
def run(self, location='.', force=False):
463
d = bzrdir.BzrDir.open(location)
466
working = d.open_workingtree()
467
except errors.NoWorkingTree:
468
raise errors.BzrCommandError("No working tree to remove")
469
except errors.NotLocalUrl:
470
raise errors.BzrCommandError("You cannot remove the working tree"
473
if (working.has_changes()):
474
raise errors.UncommittedChanges(working)
476
working_path = working.bzrdir.root_transport.base
477
branch_path = working.branch.bzrdir.root_transport.base
478
if working_path != branch_path:
479
raise errors.BzrCommandError("You cannot remove the working tree"
480
" from a lightweight checkout")
482
d.destroy_workingtree()
490
485
class cmd_revno(Command):
3446
3441
def get_transport_type(typestring):
3447
3442
"""Parse and return a transport specifier."""
3448
3443
if typestring == "sftp":
3449
from bzrlib.tests import stub_sftp
3450
return stub_sftp.SFTPAbsoluteServer
3444
from bzrlib.transport.sftp import SFTPAbsoluteServer
3445
return SFTPAbsoluteServer
3451
3446
if typestring == "memory":
3452
from bzrlib.tests import test_server
3453
return memory.MemoryServer
3447
from bzrlib.transport.memory import MemoryServer
3454
3449
if typestring == "fakenfs":
3455
from bzrlib.tests import test_server
3456
return test_server.FakeNFSServer
3450
from bzrlib.transport.fakenfs import FakeNFSServer
3451
return FakeNFSServer
3457
3452
msg = "No known transport type %s. Supported types are: sftp\n" %\
3459
3454
raise errors.BzrCommandError(msg)
3782
3777
raise errors.BzrCommandError(
3783
3778
'Cannot use -r with merge directives or bundles')
3784
3779
merger, verified = _mod_merge.Merger.from_mergeable(tree,
3787
3782
if merger is None and uncommitted:
3788
3783
if revision is not None and len(revision) > 0:
3789
3784
raise errors.BzrCommandError('Cannot use --uncommitted and'
3790
3785
' --revision at the same time.')
3791
merger = self.get_merger_from_uncommitted(tree, location, None)
3786
merger = self.get_merger_from_uncommitted(tree, location, pb)
3792
3787
allow_pending = False
3794
3789
if merger is None:
3795
3790
merger, allow_pending = self._get_merger_from_branch(tree,
3796
location, revision, remember, possible_transports, None)
3791
location, revision, remember, possible_transports, pb)
3798
3793
merger.merge_type = merge_type
3799
3794
merger.reprocess = reprocess
4070
4065
# list, we imply that the working tree text has seen and rejected
4071
4066
# all the changes from the other tree, when in fact those changes
4072
4067
# have not yet been seen.
4068
pb = ui.ui_factory.nested_progress_bar()
4073
4069
tree.set_parent_ids(parents[:1])
4075
merger = _mod_merge.Merger.from_revision_ids(None, tree, parents[1])
4071
merger = _mod_merge.Merger.from_revision_ids(pb,
4076
4073
merger.interesting_ids = interesting_ids
4077
4074
merger.merge_type = merge_type
4078
4075
merger.show_base = show_base
4155
4153
def _revert_tree_to_revision(tree, revision, file_list, no_backup):
4156
4154
rev_tree = _get_one_revision_tree('revert', revision, tree=tree)
4157
tree.revert(file_list, rev_tree, not no_backup, None,
4158
report_changes=True)
4155
pb = ui.ui_factory.nested_progress_bar()
4157
tree.revert(file_list, rev_tree, not no_backup, pb,
4158
report_changes=True)
4161
4163
class cmd_assert_fail(Command):
4610
4612
'This format does not remember old locations.')
4612
4614
if location is None:
4613
if b.get_bound_location() is not None:
4614
raise errors.BzrCommandError('Branch is already bound')
4616
raise errors.BzrCommandError('No location supplied '
4617
'and no previous location known')
4615
raise errors.BzrCommandError('No location supplied and no '
4616
'previous location known')
4618
4617
b_other = Branch.open(location)
4620
4619
b.bind(b_other)
4717
4716
rev_id = b.get_rev_id(revno)
4719
4718
if rev_id is None or _mod_revision.is_null(rev_id):
4720
ui.ui_factory.note('No revisions to uncommit.')
4719
self.outf.write('No revisions to uncommit.\n')
4723
log_collector = ui.ui_factory.make_output_stream()
4724
4722
lf = log_formatter('short',
4725
to_file=log_collector,
4726
4724
show_timezone='original')
4733
4731
end_revision=last_revno)
4736
ui.ui_factory.note('Dry-run, pretending to remove the above revisions.')
4734
print 'Dry-run, pretending to remove the above revisions.'
4736
val = raw_input('Press <enter> to continue')
4738
ui.ui_factory.note('The above revision(s) will be removed.')
4741
if not ui.ui_factory.get_boolean('Are you sure [y/N]? '):
4742
ui.ui_factory.note('Canceled')
4738
print 'The above revision(s) will be removed.'
4740
val = raw_input('Are you sure [y/N]? ')
4741
if val.lower() not in ('y', 'yes'):
4745
4745
mutter('Uncommitting from {%s} to {%s}',
4746
4746
last_rev_id, rev_id)
4747
4747
uncommit(b, tree=tree, dry_run=dry_run, verbose=verbose,
4748
4748
revno=revno, local=local)
4749
ui.ui_factory.note('You can restore the old tip by running:\n'
4750
' bzr pull . -r revid:%s' % last_rev_id)
4749
note('You can restore the old tip by running:\n'
4750
' bzr pull . -r revid:%s', last_rev_id)
4753
4753
class cmd_break_lock(Command):
5913
5913
from bzrlib.foreign import cmd_dpush
5914
5914
from bzrlib.sign_my_commits import cmd_sign_my_commits
5915
from bzrlib.weave_commands import cmd_versionedfile_list, \
5916
cmd_weave_plan_merge, cmd_weave_merge_text