217
212
implicitly add the parent, and so on up to the root. This means
218
213
you should never need to explictly add a directory, they'll just
219
214
get added when you add a file in the directory.
221
--dry-run will show which files would be added, but not actually
224
216
takes_args = ['file*']
225
takes_options = ['no-recurse', 'dry-run', 'verbose']
227
def run(self, file_list, no_recurse=False, dry_run=False, verbose=False):
232
# This is pointless, but I'd rather not raise an error
233
action = bzrlib.add.add_action_null
235
action = bzrlib.add.add_action_print
237
action = bzrlib.add.add_action_add
217
takes_options = ['no-recurse']
219
def run(self, file_list, no_recurse=False):
220
from bzrlib.add import smart_add, add_reporter_print, add_reporter_null
222
reporter = add_reporter_null
239
action = bzrlib.add.add_action_add_and_print
241
added, ignored = bzrlib.add.smart_add(file_list, not no_recurse,
244
for glob in sorted(ignored.keys()):
245
match_len = len(ignored[glob])
247
for path in ignored[glob]:
248
print "ignored %s matching \"%s\"" % (path, glob)
250
print "ignored %d file(s) matching \"%s\"" % (match_len,
252
print "If you wish to add some of these files, please add them"\
224
reporter = add_reporter_print
225
smart_add(file_list, not no_recurse, reporter)
256
228
class cmd_mkdir(Command):
412
384
print "Using saved location: %s" % stored_loc
413
385
location = stored_loc
415
386
br_from = Branch.open(location)
416
387
br_to = tree_to.branch
418
old_rh = br_to.revision_history()
419
count = tree_to.pull(br_from, overwrite)
389
old_rh = br_to.revision_history()
390
count = tree_to.pull(br_from, overwrite)
391
except DivergedBranches:
392
# FIXME: Just make DivergedBranches display the right message
394
raise BzrCommandError("These branches have diverged."
421
396
if br_to.get_parent() is None or remember:
422
397
br_to.set_parent(location)
423
note('%d revision(s) pulled.' % (count,))
398
note('%d revision(s) pulled.', count)
426
400
new_rh = tree_to.branch.revision_history()
427
401
if old_rh != new_rh:
503
477
raise BzrCommandError("Could not creeate "
505
479
br_to = Branch.initialize(location)
506
old_rh = br_to.revision_history()
509
tree_to = br_to.working_tree()
510
except NoWorkingTree:
511
# TODO: This should be updated for branches which don't have a
512
# working tree, as opposed to ones where we just couldn't
514
warning('Unable to update the working tree of: %s' % (br_to.base,))
515
count = br_to.pull(br_from, overwrite)
517
count = tree_to.pull(br_from, overwrite)
481
old_rh = br_to.revision_history()
482
count = br_to.pull(br_from, overwrite)
518
483
except DivergedBranches:
519
484
raise BzrCommandError("These branches have diverged."
520
485
" Try a merge then push with overwrite.")
521
486
if br_from.get_push_location() is None or remember:
522
487
br_from.set_push_location(location)
523
488
note('%d revision(s) pushed.' % (count,))
526
490
new_rh = br_to.revision_history()
527
491
if old_rh != new_rh:
1275
1232
unchanged=False, strict=False):
1276
1233
from bzrlib.errors import (PointlessCommit, ConflictsInTree,
1277
1234
StrictCommitFailed)
1278
from bzrlib.msgeditor import edit_commit_message, \
1279
make_commit_message_template
1235
from bzrlib.msgeditor import edit_commit_message
1280
1236
from bzrlib.status import show_status
1281
from tempfile import TemporaryFile
1284
# TODO: Need a blackbox test for invoking the external editor; may be
1285
# slightly problematic to run this cross-platform.
1287
# TODO: do more checks that the commit will succeed before
1288
# spending the user's valuable time typing a commit message.
1290
# TODO: if the commit *does* happen to fail, then save the commit
1291
# message to a temporary file where it can be recovered
1237
from cStringIO import StringIO
1292
1239
tree, selected_list = tree_files(selected_list)
1293
1240
if message is None and not file:
1294
template = make_commit_message_template(tree, selected_list)
1295
message = edit_commit_message(template)
1241
catcher = StringIO()
1242
show_status(tree.branch, specific_files=selected_list,
1244
message = edit_commit_message(catcher.getvalue())
1296
1246
if message is None:
1297
1247
raise BzrCommandError("please specify a commit message"
1298
1248
" with either --message or --file")
1461
1411
bzrlib.ui.ui_factory = save_ui
1464
def _get_bzr_branch():
1465
"""If bzr is run from a branch, return Branch or None"""
1466
import bzrlib.errors
1467
from bzrlib.branch import Branch
1468
from bzrlib.osutils import abspath
1469
from os.path import dirname
1472
branch = Branch.open(dirname(abspath(dirname(__file__))))
1474
except bzrlib.errors.BzrError:
1478
1414
def show_version():
1479
1415
print "bzr (bazaar-ng) %s" % bzrlib.__version__
1480
1416
# is bzrlib itself in a branch?
1481
branch = _get_bzr_branch()
1483
rh = branch.revision_history()
1485
print " bzr checkout, revision %d" % (revno,)
1486
print " nick: %s" % (branch.nick,)
1488
print " revid: %s" % (rh[-1],)
1417
bzrrev = bzrlib.get_bzr_revision()
1419
print " (bzr checkout, revision %d {%s})" % bzrrev
1489
1420
print bzrlib.__copyright__
1490
1421
print "http://bazaar-ng.org/"
1784
1715
class cmd_missing(Command):
1785
"""Show unmerged/unpulled revisions between two branches.
1787
OTHER_BRANCH may be local or remote."""
1788
takes_args = ['other_branch?']
1789
takes_options = [Option('reverse', 'Reverse the order of revisions'),
1791
'Display changes in the local branch only'),
1792
Option('theirs-only',
1793
'Display changes in the remote branch only'),
1801
def run(self, other_branch=None, reverse=False, mine_only=False,
1802
theirs_only=False, long=True, short=False, line=False,
1803
show_ids=False, verbose=False):
1804
from bzrlib.missing import find_unmerged, iter_log_data
1805
from bzrlib.log import log_formatter
1806
local_branch = bzrlib.branch.Branch.open_containing(u".")[0]
1807
parent = local_branch.get_parent()
1808
if other_branch is None:
1809
other_branch = parent
1810
if other_branch is None:
1716
"""What is missing in this branch relative to other branch.
1718
# TODO: rewrite this in terms of ancestry so that it shows only
1721
takes_args = ['remote?']
1722
aliases = ['mis', 'miss']
1723
takes_options = ['verbose']
1726
def run(self, remote=None, verbose=False):
1727
from bzrlib.errors import BzrCommandError
1728
from bzrlib.missing import show_missing
1730
if verbose and is_quiet():
1731
raise BzrCommandError('Cannot pass both quiet and verbose')
1733
tree = WorkingTree.open_containing(u'.')[0]
1734
parent = tree.branch.get_parent()
1811
1737
raise BzrCommandError("No missing location known or specified.")
1812
print "Using last location: " + local_branch.get_parent()
1813
remote_branch = bzrlib.branch.Branch.open(other_branch)
1814
local_extra, remote_extra = find_unmerged(local_branch, remote_branch)
1815
log_format = get_log_format(long=long, short=short, line=line)
1816
lf = log_formatter(log_format, sys.stdout,
1818
show_timezone='original')
1819
if reverse is False:
1820
local_extra.reverse()
1821
remote_extra.reverse()
1822
if local_extra and not theirs_only:
1823
print "You have %d extra revision(s):" % len(local_extra)
1824
for data in iter_log_data(local_extra, local_branch, verbose):
1826
printed_local = True
1828
printed_local = False
1829
if remote_extra and not mine_only:
1830
if printed_local is True:
1832
print "You are missing %d revision(s):" % len(remote_extra)
1833
for data in iter_log_data(remote_extra, remote_branch, verbose):
1835
if not remote_extra and not local_extra:
1837
print "Branches are up to date."
1840
if parent is None and other_branch is not None:
1841
local_branch.set_parent(other_branch)
1740
print "Using last location: %s" % parent
1742
elif parent is None:
1743
# We only update parent if it did not exist, missing
1744
# should not change the parent
1745
tree.branch.set_parent(remote)
1746
br_remote = Branch.open_containing(remote)[0]
1747
return show_missing(tree.branch, br_remote, verbose=verbose,
1845
1751
class cmd_plugins(Command):