17
17
"""builtin bzr commands"""
22
from shutil import rmtree
26
import bzrlib.branch as branch
24
27
import bzrlib.bzrdir as bzrdir
25
28
from bzrlib._merge_core import ApplyMerge3
26
29
from bzrlib.commands import Command, display_command
396
399
takes_args = ['location?']
398
401
def run(self, location=None, remember=False, overwrite=False, verbose=False):
399
from shutil import rmtree
401
402
# FIXME: too much stuff is in the command class
402
403
tree_to = WorkingTree.open_containing(u'.')[0]
403
404
stored_loc = tree_to.branch.get_parent()
459
460
create_prefix=False, verbose=False):
460
461
# FIXME: Way too big! Put this into a function called from the
463
from shutil import rmtree
464
463
from bzrlib.transport import get_transport
466
465
tree_from = WorkingTree.open_containing(u'.')[0]
547
546
aliases = ['get', 'clone']
549
548
def run(self, from_location, to_location=None, revision=None, basis=None):
551
from shutil import rmtree
552
549
if revision is None:
553
550
revision = [None]
554
551
elif len(revision) > 1:
611
class cmd_checkout(Command):
612
"""Create a new checkout of an existing branch.
614
If the TO_LOCATION is omitted, the last component of the BRANCH_LOCATION will
615
be used. In other words, "checkout ../foo/bar" will attempt to create ./bar.
617
To retrieve the branch as of a particular revision, supply the --revision
618
parameter, as in "checkout foo/bar -r 5". Note that this will be immediately
619
out of date [so you cannot commit] but it may be useful (i.e. to examine old
622
--basis is to speed up checking out from remote branches. When specified, it
623
uses the inventory and file contents from the basis branch in preference to the
624
branch being checked out. [Not implemented yet.]
626
takes_args = ['branch_location', 'to_location?']
627
# takes_options = ['revision', 'basis']
629
def run(self, branch_location, to_location=None, revision=None, basis=None):
632
elif len(revision) > 1:
633
raise BzrCommandError(
634
'bzr checkout --revision takes exactly 1 revision value')
635
source = Branch.open(branch_location)
636
if len(revision) == 1 and revision[0] is not None:
637
revision_id = revision[0].in_history(source)[1]
640
if to_location is None:
641
to_location = os.path.basename(branch_location.rstrip("/\\"))
643
os.mkdir(to_location)
645
if e.errno == errno.EEXIST:
646
raise BzrCommandError('Target directory "%s" already'
647
' exists.' % to_location)
648
if e.errno == errno.ENOENT:
649
raise BzrCommandError('Parent of "%s" does not exist.' %
653
checkout = bzrdir.BzrDirMetaFormat1().initialize(to_location)
654
branch.BranchReferenceFormat().initialize(checkout, source)
655
checkout.create_workingtree()
614
658
class cmd_renames(Command):
615
659
"""Show list of renamed files.