128
128
This reports on versioned and unknown files, reporting them
129
129
grouped by state. Possible states are:
132
132
Versioned in the working copy but not in the previous revision.
135
135
Versioned in the previous revision but removed or deleted
136
136
in the working copy.
139
139
Path of this file changed from the previous revision;
140
140
the text may also have changed. This includes files whose
141
141
parent directory was renamed.
144
144
Text has changed since the previous revision.
147
147
Not versioned and not matching an ignore pattern.
149
149
To see ignored files use 'bzr ignored'. For details in the
150
150
changes to file texts, use 'bzr diff'.
152
--short gives a one character status flag for each item, similar
153
to the SVN's status command.
152
155
If no arguments are specified, the status of the entire working
153
156
directory is shown. Otherwise, only the status of the specified
161
164
# TODO: --no-recurse, --recurse options
163
166
takes_args = ['file*']
164
takes_options = ['show-ids', 'revision']
167
takes_options = ['show-ids', 'revision', 'short']
165
168
aliases = ['st', 'stat']
167
170
encoding_type = 'replace'
170
def run(self, show_ids=False, file_list=None, revision=None):
173
def run(self, show_ids=False, file_list=None, revision=None, short=False):
171
174
from bzrlib.status import show_tree_status
173
176
tree, file_list = tree_files(file_list)
175
178
show_tree_status(tree, show_ids=show_ids,
176
179
specific_files=file_list, revision=revision,
180
184
class cmd_cat_revision(Command):
1209
1213
# deleted files.
1211
1215
# TODO: This probably handles non-Unix newlines poorly.
1213
1217
takes_args = ['file*']
1214
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.'),
1215
1224
aliases = ['di', 'dif']
1216
1225
encoding_type = 'exact'
1227
1236
elif prefix == '1':
1228
1237
old_label = 'old/'
1229
1238
new_label = 'new/'
1231
if not ':' in prefix:
1232
raise BzrCommandError(
1233
"--diff-prefix expects two values separated by a colon")
1234
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')
1237
1250
tree1, file_list = internal_tree_files(file_list)
1257
1270
tree1, tree2 = None, None
1260
if revision is not None:
1261
if tree2 is not None:
1262
raise errors.BzrCommandError("Can't specify -r with two branches")
1263
if (len(revision) == 1) or (revision[1].spec is None):
1264
return diff_cmd_helper(tree1, file_list, diff_options,
1266
old_label=old_label, new_label=new_label)
1267
elif len(revision) == 2:
1268
return diff_cmd_helper(tree1, file_list, diff_options,
1269
revision[0], revision[1],
1270
old_label=old_label, new_label=new_label)
1272
raise errors.BzrCommandError('bzr diff --revision takes exactly'
1273
' one or two revision identifiers')
1275
if tree2 is not None:
1276
return show_diff_trees(tree1, tree2, sys.stdout,
1277
specific_files=file_list,
1278
external_diff_options=diff_options,
1279
old_label=old_label, new_label=new_label)
1281
return diff_cmd_helper(tree1, file_list, diff_options,
1282
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)
1285
1292
class cmd_deleted(Command):
1524
1533
Option('ignored', help='Print ignored files'),
1526
1535
Option('null', help='Null separate the files'),
1528
1538
@display_command
1529
1539
def run(self, revision=None, verbose=False,
1530
1540
non_recursive=False, from_root=False,
1531
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')
1534
1547
if verbose and null:
1535
1548
raise errors.BzrCommandError('Cannot set both --verbose and --null')
1546
1559
tree = tree.branch.repository.revision_tree(
1547
1560
revision[0].in_history(tree.branch).rev_id)
1549
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):
1550
1563
if fp.startswith(relpath):
1551
1564
fp = fp[len(relpath):]
1552
1565
if non_recursive and '/' in fp:
1554
1567
if not all and not selection[fc]:
1569
if kind is not None and fkind != kind:
1557
1572
kindch = entry.kind_character()
1558
1573
self.outf.write('%-8s %s%s\n' % (fc, fp, kindch))
1577
1592
To remove patterns from the ignore list, edit the .bzrignore file.
1579
1594
Trailing slashes on patterns are ignored.
1580
If the pattern contains a slash, it is compared to the whole path
1581
from the branch root. Otherwise, it is compared to only the last
1582
component of the path. To match a file only in the root directory,
1595
If the pattern contains a slash or is a regular expression, it is compared
1596
to the whole path from the branch root. Otherwise, it is compared to only
1597
the last component of the path. To match a file only in the root
1598
directory, prepend './'.
1585
1600
Ignore patterns specifying absolute paths are not allowed.
1587
Ignore patterns are case-insensitive on case-insensitive systems.
1602
Ignore patterns may include globbing wildcards such as:
1603
? - Matches any single character except '/'
1604
* - Matches 0 or more characters except '/'
1605
/**/ - Matches 0 or more directories in a path
1606
[a-z] - Matches a single character from within a group of characters
1608
Ignore patterns may also be Python regular expressions.
1609
Regular expression ignore patterns are identified by a 'RE:' prefix
1610
followed by the regular expression. Regular expression ignore patterns
1611
may not include named or numbered groups.
1589
Note: wildcards must be quoted from the shell on Unix.
1613
Note: ignore patterns containing shell wildcards must be quoted from
1592
1617
bzr ignore ./Makefile
1593
1618
bzr ignore '*.class'
1619
bzr ignore 'lib/**/*.o'
1620
bzr ignore 'RE:lib/.*\.o'
1595
1622
takes_args = ['name_pattern*']
1596
1623
takes_options = [
1746
1774
tree, relpath = WorkingTree.open_containing(filename)
1747
1775
b = tree.branch
1748
except errors.NotBranchError:
1776
except (errors.NotBranchError, errors.NotLocalUrl):
1779
if revision is not None and revision[0].get_branch() is not None:
1780
b = Branch.open(revision[0].get_branch())
1751
1781
if tree is None:
1752
1782
b, relpath = Branch.open_containing(filename)
1753
if revision is not None and revision[0].get_branch() is not None:
1754
b = Branch.open(revision[0].get_branch())
1783
tree = b.basis_tree()
1755
1784
if revision is None:
1756
1785
revision_id = b.last_revision()
2061
2091
Option('cache-dir', type=str,
2062
2092
help='a directory to cache intermediate'
2063
2093
' benchmark steps'),
2094
Option('clean-output',
2095
help='clean temporary tests directories'
2096
' without running tests'),
2066
2099
def run(self, testspecs_list=None, verbose=None, one=False,
2067
2100
keep_output=False, transport=None, benchmark=None,
2068
lsprof_timed=None, cache_dir=None):
2101
lsprof_timed=None, cache_dir=None, clean_output=False):
2069
2102
import bzrlib.ui
2070
2103
from bzrlib.tests import selftest
2071
2104
import bzrlib.benchmarks as benchmarks
2072
2105
from bzrlib.benchmarks import tree_creator
2108
from bzrlib.tests import clean_selftest_output
2109
clean_selftest_output()
2074
2112
if cache_dir is not None:
2075
2113
tree_creator.TreeCreator.CACHE_ROOT = osutils.abspath(cache_dir)
2076
2114
print '%10s: %s' % ('bzr', osutils.realpath(sys.argv[0]))
2085
2123
if verbose is None:
2087
2125
# TODO: should possibly lock the history file...
2088
benchfile = open(".perf_history", "at")
2126
benchfile = open(".perf_history", "at", buffering=1)
2090
2128
test_suite_factory = None
2091
2129
if verbose is None:
2201
2239
takes_args = ['branch?']
2202
2240
takes_options = ['revision', 'force', 'merge-type', 'reprocess', 'remember',
2203
2241
Option('show-base', help="Show base revision text in "
2205
2243
Option('uncommitted', help='Apply uncommitted changes'
2206
' 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.'),
2208
2251
def help(self):
2209
2252
from inspect import getdoc
2212
2255
def run(self, branch=None, revision=None, force=False, merge_type=None,
2213
2256
show_base=False, reprocess=False, remember=False,
2257
uncommitted=False, pull=False):
2215
2258
if merge_type is None:
2216
2259
merge_type = _mod_merge.Merge3Merger
2666
2710
takes_args = ['filename']
2667
2711
takes_options = [Option('all', help='show annotations on all lines'),
2668
2712
Option('long', help='show date in annotations'),
2672
2717
@display_command
2673
def run(self, filename, all=False, long=False, revision=None):
2718
def run(self, filename, all=False, long=False, revision=None,
2674
2720
from bzrlib.annotate import annotate_file
2675
2721
tree, relpath = WorkingTree.open_containing(filename)
2676
2722
branch = tree.branch
2685
2731
file_id = tree.inventory.path2id(relpath)
2686
2732
tree = branch.repository.revision_tree(revision_id)
2687
2733
file_version = tree.inventory[file_id].revision
2688
annotate_file(branch, file_version, file_id, long, all, sys.stdout)
2734
annotate_file(branch, file_version, file_id, long, all, sys.stdout,
2690
2737
branch.unlock()
3037
3085
if merger.base_rev_id == merger.other_rev_id:
3038
3086
note('Nothing to do.')
3088
if file_list is None:
3089
if pull and merger.base_rev_id == merger.this_rev_id:
3090
count = merger.this_tree.pull(merger.this_branch,
3091
False, merger.other_rev_id)
3092
note('%d revision(s) pulled.' % (count,))
3040
3094
merger.backup_files = backup_files
3041
3095
merger.merge_type = merge_type
3042
3096
merger.set_interesting_files(file_list)