1213
1213
# deleted files.
1215
1215
# TODO: This probably handles non-Unix newlines poorly.
1217
1217
takes_args = ['file*']
1218
takes_options = ['revision', 'diff-options', 'prefix']
1218
takes_options = ['revision', 'diff-options',
1219
Option('prefix', type=str,
1221
help='Set prefixes to added to old and new filenames, as '
1222
'two values separated by a colon.'),
1219
1224
aliases = ['di', 'dif']
1220
1225
encoding_type = 'exact'
1231
1236
elif prefix == '1':
1232
1237
old_label = 'old/'
1233
1238
new_label = 'new/'
1235
if not ':' in prefix:
1236
raise BzrCommandError(
1237
"--diff-prefix expects two values separated by a colon")
1238
1240
old_label, new_label = prefix.split(":")
1242
raise BzrCommandError(
1243
"--prefix expects two values separated by a colon")
1245
if revision and len(revision) > 2:
1246
raise errors.BzrCommandError('bzr diff --revision takes exactly'
1247
' one or two revision specifiers')
1241
1250
tree1, file_list = internal_tree_files(file_list)
1261
1270
tree1, tree2 = None, None
1264
if revision is not None:
1265
if tree2 is not None:
1266
raise errors.BzrCommandError("Can't specify -r with two branches")
1267
if (len(revision) == 1) or (revision[1].spec is None):
1268
return diff_cmd_helper(tree1, file_list, diff_options,
1270
old_label=old_label, new_label=new_label)
1271
elif len(revision) == 2:
1272
return diff_cmd_helper(tree1, file_list, diff_options,
1273
revision[0], revision[1],
1274
old_label=old_label, new_label=new_label)
1276
raise errors.BzrCommandError('bzr diff --revision takes exactly'
1277
' one or two revision identifiers')
1279
if tree2 is not None:
1280
return show_diff_trees(tree1, tree2, sys.stdout,
1281
specific_files=file_list,
1282
external_diff_options=diff_options,
1283
old_label=old_label, new_label=new_label)
1285
return diff_cmd_helper(tree1, file_list, diff_options,
1286
old_label=old_label, new_label=new_label)
1274
if tree2 is not None:
1275
if revision is not None:
1276
# FIXME: but there should be a clean way to diff between
1277
# non-default versions of two trees, it's not hard to do
1279
raise errors.BzrCommandError(
1280
"Sorry, diffing arbitrary revisions across branches "
1281
"is not implemented yet")
1282
return show_diff_trees(tree1, tree2, sys.stdout,
1283
specific_files=file_list,
1284
external_diff_options=diff_options,
1285
old_label=old_label, new_label=new_label)
1287
return diff_cmd_helper(tree1, file_list, diff_options,
1288
revision_specs=revision,
1289
old_label=old_label, new_label=new_label)
1289
1292
class cmd_deleted(Command):
1528
1533
Option('ignored', help='Print ignored files'),
1530
1535
Option('null', help='Null separate the files'),
1532
1538
@display_command
1533
1539
def run(self, revision=None, verbose=False,
1534
1540
non_recursive=False, from_root=False,
1535
1541
unknown=False, versioned=False, ignored=False,
1542
null=False, kind=None):
1544
if kind and kind not in ('file', 'directory', 'symlink'):
1545
raise errors.BzrCommandError('invalid kind specified')
1538
1547
if verbose and null:
1539
1548
raise errors.BzrCommandError('Cannot set both --verbose and --null')
1550
1559
tree = tree.branch.repository.revision_tree(
1551
1560
revision[0].in_history(tree.branch).rev_id)
1553
for fp, fc, kind, fid, entry in tree.list_files(include_root=False):
1562
for fp, fc, fkind, fid, entry in tree.list_files(include_root=False):
1554
1563
if fp.startswith(relpath):
1555
1564
fp = fp[len(relpath):]
1556
1565
if non_recursive and '/' in fp:
1558
1567
if not all and not selection[fc]:
1569
if kind is not None and fkind != kind:
1561
1572
kindch = entry.kind_character()
1562
1573
self.outf.write('%-8s %s%s\n' % (fc, fp, kindch))
2110
2123
if verbose is None:
2112
2125
# TODO: should possibly lock the history file...
2113
benchfile = open(".perf_history", "at")
2126
benchfile = open(".perf_history", "at", buffering=1)
2115
2128
test_suite_factory = None
2116
2129
if verbose is None:
2226
2239
takes_args = ['branch?']
2227
2240
takes_options = ['revision', 'force', 'merge-type', 'reprocess', 'remember',
2228
2241
Option('show-base', help="Show base revision text in "
2230
2243
Option('uncommitted', help='Apply uncommitted changes'
2231
' from a working copy, instead of branch changes')]
2244
' from a working copy, instead of branch changes'),
2245
Option('pull', help='If the destination is already'
2246
' completely merged into the source, pull from the'
2247
' source rather than merging. When this happens,'
2248
' you do not need to commit the result.'),
2233
2251
def help(self):
2234
2252
from inspect import getdoc
2237
2255
def run(self, branch=None, revision=None, force=False, merge_type=None,
2238
2256
show_base=False, reprocess=False, remember=False,
2257
uncommitted=False, pull=False):
2240
2258
if merge_type is None:
2241
2259
merge_type = _mod_merge.Merge3Merger
3020
3040
if merger.base_rev_id == merger.other_rev_id:
3021
3041
note('Nothing to do.')
3043
if file_list is None:
3044
if pull and merger.base_rev_id == merger.this_rev_id:
3045
count = merger.this_tree.pull(merger.this_branch,
3046
False, merger.other_rev_id)
3047
note('%d revision(s) pulled.' % (count,))
3023
3049
merger.backup_files = backup_files
3024
3050
merger.merge_type = merge_type
3025
3051
merger.set_interesting_files(file_list)