329
class cmd_move(Command):
330
"""Move files to a different directory.
335
The destination must be a versioned directory in the same branch.
337
takes_args = ['source$', 'dest']
338
def run(self, source_list, dest):
339
tree, source_list = tree_files(source_list)
340
# TODO: glob expansion on windows?
341
tree.move(source_list, tree.relpath(dest))
344
class cmd_rename(Command):
345
"""Change the name of an entry.
348
bzr rename frob.c frobber.c
349
bzr rename src/frob.c lib/frob.c
351
It is an error if the destination name exists.
353
See also the 'move' command, which moves files into a different
354
directory without changing their name.
356
# TODO: Some way to rename multiple files without invoking
357
# bzr for each one?"""
358
takes_args = ['from_name', 'to_name']
360
def run(self, from_name, to_name):
361
tree, (from_name, to_name) = tree_files((from_name, to_name))
362
tree.rename_one(from_name, to_name)
365
329
class cmd_mv(Command):
366
330
"""Move or rename a file.
376
340
Files cannot be moved between branches.
378
342
takes_args = ['names*']
343
aliases = ['move', 'rename']
379
345
def run(self, names_list):
380
346
if len(names_list) < 2:
381
347
raise BzrCommandError("missing file argument")
415
381
takes_args = ['location?']
417
383
def run(self, location=None, remember=False, overwrite=False, revision=None, verbose=False):
418
# FIXME: too much stuff is in the command class
419
tree_to = WorkingTree.open_containing(u'.')[0]
420
stored_loc = tree_to.branch.get_parent()
384
# FIXME: too much stuff is in the command class
386
tree_to = WorkingTree.open_containing(u'.')[0]
387
branch_to = tree_to.branch
388
except NoWorkingTree:
390
branch_to = Branch.open_containing(u'.')[0]
391
stored_loc = branch_to.get_parent()
421
392
if location is None:
422
393
if stored_loc is None:
423
394
raise BzrCommandError("No pull location known or specified.")
436
406
raise BzrCommandError('bzr pull --revision takes one value.')
438
old_rh = br_to.revision_history()
439
count = tree_to.pull(br_from, overwrite, rev_id)
408
old_rh = branch_to.revision_history()
409
if tree_to is not None:
410
count = tree_to.pull(br_from, overwrite, rev_id)
412
count = branch_to.pull(br_from, overwrite, rev_id)
441
if br_to.get_parent() is None or remember:
442
br_to.set_parent(location)
414
if branch_to.get_parent() is None or remember:
415
branch_to.set_parent(location)
443
416
note('%d revision(s) pulled.' % (count,))
446
new_rh = tree_to.branch.revision_history()
419
new_rh = branch_to.revision_history()
447
420
if old_rh != new_rh:
448
421
# Something changed
449
422
from bzrlib.log import show_changed_revisions
450
show_changed_revisions(tree_to.branch, old_rh, new_rh)
423
show_changed_revisions(branch_to, old_rh, new_rh)
453
426
class cmd_push(Command):
519
492
needed.append((new_transport,
520
493
new_transport.relpath(transport.base)))
521
494
if new_transport.base == transport.base:
522
raise BzrCommandError("Could not creeate "
495
raise BzrCommandError("Could not create "
524
497
dir_to = br_from.bzrdir.clone(location)
525
498
br_to = dir_to.open_branch()
531
504
# TODO: This should be updated for branches which don't have a
532
505
# working tree, as opposed to ones where we just couldn't
533
506
# update the tree.
534
warning('Unable to update the working tree of: %s' % (br_to.base,))
507
warning('This transport does not update the working '
508
'tree of: %s' % (br_to.base,))
535
509
count = br_to.pull(br_from, overwrite)
536
510
except NoWorkingTree:
537
511
count = br_to.pull(br_from, overwrite)
898
872
# locations if the user supplies an extended path
899
873
if not os.path.exists(location):
900
874
os.mkdir(location)
875
bzrdir.BzrDir.create_branch_convenience(location, format=format)
878
class cmd_init_repository(Command):
879
"""Create a shared repository to keep branches in."""
880
takes_args = ["location"]
881
takes_options = [Option('format',
882
help='Use a specific format rather than the'
883
' current default format. Currently this'
884
' option only accepts "metadir" and "knit"'
885
' WARNING: the knit format is currently unstable'
886
' and only for experimental use.',
887
type=get_format_type)]
888
aliases = ["init-repo"]
889
def run(self, location, format=None):
890
from bzrlib.bzrdir import BzrDirMetaFormat1
891
from bzrlib.transport import get_transport
901
892
if format is None:
903
bzrdir.BzrDir.create_standalone_workingtree(location)
905
new_dir = format.initialize(location)
906
new_dir.create_repository()
907
new_dir.create_branch()
908
# TODO: ask the bzrdir format for the right classs
909
import bzrlib.workingtree
910
bzrlib.workingtree.WorkingTreeFormat3().initialize(new_dir)
893
format = BzrDirMetaFormat1()
894
get_transport(location).mkdir('')
895
newdir = format.initialize(location)
896
repo = newdir.create_repository(shared=True)
897
repo.set_make_working_trees(False)
913
900
class cmd_diff(Command):
1460
1447
def run(self, message=None, file=None, verbose=True, selected_list=None,
1461
1448
unchanged=False, strict=False, local=False):
1449
from bzrlib.commit import (NullCommitReporter, ReportCommitToLog)
1462
1450
from bzrlib.errors import (PointlessCommit, ConflictsInTree,
1463
1451
StrictCommitFailed)
1464
1452
from bzrlib.msgeditor import edit_commit_message, \
1493
1481
if message == "":
1494
1482
raise BzrCommandError("empty commit message specified")
1485
reporter = ReportCommitToLog()
1487
reporter = NullCommitReporter()
1497
1490
tree.commit(message, specific_files=selected_list,
1498
allow_pointless=unchanged, strict=strict, local=local)
1491
allow_pointless=unchanged, strict=strict, local=local,
1499
1493
except PointlessCommit:
1500
1494
# FIXME: This should really happen before the file is read in;
1501
1495
# perhaps prepare the commit; get the message; then actually commit
1512
1506
+ ' Either unbind, update, or'
1513
1507
' pass --local to commit.')
1515
note('Committed revision %d.' % (tree.branch.revno(),))
1518
1510
class cmd_check(Command):
1519
1511
"""Validate consistency of branch history.
1564
1556
takes_options = [
1565
1557
Option('format',
1566
1558
help='Upgrade to a specific format rather than the'
1567
' current default format. Currently this '
1568
' option only accepts =metadir',
1559
' current default format. Currently this'
1560
' option only accepts -metadir and -knit'
1561
' WARNING: the knit format is currently'
1562
' unstable and only for experimental use.',
1569
1563
type=get_format_type),
1980
1974
For a list of all available commands, say 'bzr help commands'."""
1981
1975
takes_options = [Option('long', 'show help on all commands')]
1982
1976
takes_args = ['topic?']
1977
aliases = ['?', '--help', '-?', '-h']
1985
1979
@display_command
1986
1980
def run(self, topic=None, long=False):
2049
2043
raise BzrCommandError("No missing location known or specified.")
2050
2044
print "Using last location: " + local_branch.get_parent()
2051
2045
remote_branch = bzrlib.branch.Branch.open(other_branch)
2052
remote_branch.lock_read()
2046
local_branch.lock_write()
2047
if remote_branch.base == local_branch.base:
2048
remote_branch = local_branch
2054
local_branch.lock_write()
2050
remote_branch.lock_read()
2056
2052
local_extra, remote_extra = find_unmerged(local_branch, remote_branch)
2057
2053
if (log_format == None):
2281
2277
if location is None:
2282
2278
location = u'.'
2283
2279
control, relpath = bzrdir.BzrDir.open_containing(location)
2284
b = control.open_branch()
2286
2281
tree = control.open_workingtree()
2287
2283
except (errors.NoWorkingTree, errors.NotLocalUrl):
2285
b = control.open_branch()
2290
2287
if revision is None:
2291
2288
revno = b.revno()
2331
2328
"don't break it"),
2333
2330
def run(self, location, show=False):
2334
d = bzrdir.BzrDir.open(location)
2335
repo = d.open_repository()
2336
if not repo.is_locked():
2337
raise errors.ObjectNotLocked(repo)
2331
raise NotImplementedError("sorry, break-lock is not complete yet; "
2332
"you can remove the 'held' directory manually to break the lock")
2340
2335
# command-line interpretation helper for merge-related commands
2408
2403
# these get imported and then picked up by the scan for cmd_*
2409
2404
# TODO: Some more consistent way to split command definitions across files;
2410
2405
# we do need to load at least some information about them to know of
2406
# aliases. ideally we would avoid loading the implementation until the
2407
# details were needed.
2412
2408
from bzrlib.conflicts import cmd_resolve, cmd_conflicts, restore
2413
2409
from bzrlib.sign_my_commits import cmd_sign_my_commits
2410
from bzrlib.weave_commands import cmd_weave_list, cmd_weave_join, \
2411
cmd_weave_plan_merge, cmd_weave_merge_text