/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Aaron Bentley
  • Date: 2006-12-22 02:00:06 UTC
  • mfrom: (2212 +trunk)
  • mto: (2255.6.1 dirstate)
  • mto: This revision was merged to the branch mainline in revision 2322.
  • Revision ID: aaron.bentley@utoronto.ca-20061222020006-8h1kgh4iax3c90ju
merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
128
128
    This reports on versioned and unknown files, reporting them
129
129
    grouped by state.  Possible states are:
130
130
 
131
 
    added
 
131
    added / A
132
132
        Versioned in the working copy but not in the previous revision.
133
133
 
134
 
    removed
 
134
    removed / D
135
135
        Versioned in the previous revision but removed or deleted
136
136
        in the working copy.
137
137
 
138
 
    renamed
 
138
    renamed / R
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.
142
142
 
143
 
    modified
 
143
    modified / M
144
144
        Text has changed since the previous revision.
145
145
 
146
 
    unknown
 
146
    unknown / ?
147
147
        Not versioned and not matching an ignore pattern.
148
148
 
149
149
    To see ignored files use 'bzr ignored'.  For details in the
150
150
    changes to file texts, use 'bzr diff'.
 
151
    
 
152
    --short gives a one character status flag for each item, similar
 
153
    to the SVN's status command.
151
154
 
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
162
165
    
163
166
    takes_args = ['file*']
164
 
    takes_options = ['show-ids', 'revision']
 
167
    takes_options = ['show-ids', 'revision', 'short']
165
168
    aliases = ['st', 'stat']
166
169
 
167
170
    encoding_type = 'replace'
168
171
    
169
172
    @display_command
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
172
175
 
173
176
        tree, file_list = tree_files(file_list)
174
177
            
175
178
        show_tree_status(tree, show_ids=show_ids,
176
179
                         specific_files=file_list, revision=revision,
177
 
                         to_file=self.outf)
 
180
                         to_file=self.outf,
 
181
                         short=short)
178
182
 
179
183
 
180
184
class cmd_cat_revision(Command):
1209
1213
    #       deleted files.
1210
1214
 
1211
1215
    # TODO: This probably handles non-Unix newlines poorly.
1212
 
    
 
1216
 
1213
1217
    takes_args = ['file*']
1214
 
    takes_options = ['revision', 'diff-options', 'prefix']
 
1218
    takes_options = ['revision', 'diff-options',
 
1219
        Option('prefix', type=str,
 
1220
               short_name='p',
 
1221
               help='Set prefixes to added to old and new filenames, as '
 
1222
                    'two values separated by a colon.'),
 
1223
        ]
1215
1224
    aliases = ['di', 'dif']
1216
1225
    encoding_type = 'exact'
1217
1226
 
1227
1236
        elif prefix == '1':
1228
1237
            old_label = 'old/'
1229
1238
            new_label = 'new/'
1230
 
        else:
1231
 
            if not ':' in prefix:
1232
 
                 raise BzrCommandError(
1233
 
                     "--diff-prefix expects two values separated by a colon")
 
1239
        elif ':' in prefix:
1234
1240
            old_label, new_label = prefix.split(":")
 
1241
        else:
 
1242
            raise BzrCommandError(
 
1243
                "--prefix expects two values separated by a colon")
 
1244
 
 
1245
        if revision and len(revision) > 2:
 
1246
            raise errors.BzrCommandError('bzr diff --revision takes exactly'
 
1247
                                         ' one or two revision specifiers')
1235
1248
        
1236
1249
        try:
1237
1250
            tree1, file_list = internal_tree_files(file_list)
1257
1270
                tree1, tree2 = None, None
1258
1271
            else:
1259
1272
                raise
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,
1265
 
                                       revision[0], 
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)
1271
 
            else:
1272
 
                raise errors.BzrCommandError('bzr diff --revision takes exactly'
1273
 
                                             ' one or two revision identifiers')
1274
 
        else:
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)
1280
 
            else:
1281
 
                return diff_cmd_helper(tree1, file_list, diff_options,
1282
 
                                       old_label=old_label, new_label=new_label)
 
1273
 
 
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
 
1278
                # internally...
 
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)
 
1286
 
 
1287
        return diff_cmd_helper(tree1, file_list, diff_options,
 
1288
                               revision_specs=revision,
 
1289
                               old_label=old_label, new_label=new_label)
1283
1290
 
1284
1291
 
1285
1292
class cmd_deleted(Command):
1371
1378
                            help='show from oldest to newest'),
1372
1379
                     'timezone', 
1373
1380
                     Option('verbose', 
 
1381
                             short_name='v',
1374
1382
                             help='show files changed in each revision'),
1375
1383
                     'show-ids', 'revision',
1376
1384
                     'log-format',
1377
1385
                     'line', 'long', 
1378
1386
                     Option('message',
 
1387
                            short_name='m',
1379
1388
                            help='show revisions whose message matches this regexp',
1380
1389
                            type=str),
1381
1390
                     'short',
1512
1521
class cmd_ls(Command):
1513
1522
    """List files in a tree.
1514
1523
    """
 
1524
 
1515
1525
    # TODO: Take a revision or remote path and list that tree instead.
1516
 
    hidden = True
1517
1526
    takes_options = ['verbose', 'revision',
1518
1527
                     Option('non-recursive',
1519
1528
                            help='don\'t recurse into sub-directories'),
1524
1533
                     Option('ignored', help='Print ignored files'),
1525
1534
 
1526
1535
                     Option('null', help='Null separate the files'),
 
1536
                     'kind',
1527
1537
                    ]
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,
1532
 
            null=False):
 
1542
            null=False, kind=None):
 
1543
 
 
1544
        if kind and kind not in ('file', 'directory', 'symlink'):
 
1545
            raise errors.BzrCommandError('invalid kind specified')
1533
1546
 
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)
1548
1561
 
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:
1553
1566
                    continue
1554
1567
                if not all and not selection[fc]:
1555
1568
                    continue
 
1569
                if kind is not None and fkind != kind:
 
1570
                    continue
1556
1571
                if verbose:
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.
1578
1593
 
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,
1583
 
    prepend './'.
 
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 './'.
1584
1599
 
1585
1600
    Ignore patterns specifying absolute paths are not allowed.
1586
1601
 
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
 
1607
 
 
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.
1588
1612
 
1589
 
    Note: wildcards must be quoted from the shell on Unix.
 
1613
    Note: ignore patterns containing shell wildcards must be quoted from 
 
1614
    the shell on Unix.
1590
1615
 
1591
1616
    examples:
1592
1617
        bzr ignore ./Makefile
1593
1618
        bzr ignore '*.class'
 
1619
        bzr ignore 'lib/**/*.o'
 
1620
        bzr ignore 'RE:lib/.*\.o'
1594
1621
    """
1595
1622
    takes_args = ['name_pattern*']
1596
1623
    takes_options = [
1734
1761
 
1735
1762
    takes_options = ['revision', 'name-from-revision']
1736
1763
    takes_args = ['filename']
 
1764
    encoding_type = 'exact'
1737
1765
 
1738
1766
    @display_command
1739
1767
    def run(self, filename, revision=None, name_from_revision=False):
1745
1773
        try:
1746
1774
            tree, relpath = WorkingTree.open_containing(filename)
1747
1775
            b = tree.branch
1748
 
        except errors.NotBranchError:
 
1776
        except (errors.NotBranchError, errors.NotLocalUrl):
1749
1777
            pass
1750
1778
 
 
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()
1757
1786
        else:
1812
1841
                     Option('unchanged',
1813
1842
                            help='commit even if nothing has changed'),
1814
1843
                     Option('file', type=str, 
 
1844
                            short_name='F',
1815
1845
                            argname='msgfile',
1816
1846
                            help='file containing commit message'),
1817
1847
                     Option('strict',
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'),
2064
2097
                     ]
2065
2098
 
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
2073
2106
 
 
2107
        if clean_output:
 
2108
            from bzrlib.tests import clean_selftest_output
 
2109
            clean_selftest_output()
 
2110
            return 0
 
2111
 
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:
2086
2124
                verbose = True
2087
2125
            # TODO: should possibly lock the history file...
2088
 
            benchfile = open(".perf_history", "at")
 
2126
            benchfile = open(".perf_history", "at", buffering=1)
2089
2127
        else:
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 "
2204
 
                            "conflicts"), 
 
2242
                            "conflicts"),
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.'),
 
2249
                     ]
2207
2250
 
2208
2251
    def help(self):
2209
2252
        from inspect import getdoc
2211
2254
 
2212
2255
    def run(self, branch=None, revision=None, force=False, merge_type=None,
2213
2256
            show_base=False, reprocess=False, remember=False, 
2214
 
            uncommitted=False):
 
2257
            uncommitted=False, pull=False):
2215
2258
        if merge_type is None:
2216
2259
            merge_type = _mod_merge.Merge3Merger
2217
2260
 
2282
2325
                    merge_type=merge_type,
2283
2326
                    reprocess=reprocess,
2284
2327
                    show_base=show_base,
 
2328
                    pull=pull,
2285
2329
                    pb=pb, file_list=interesting_files)
2286
2330
            finally:
2287
2331
                pb.finished()
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'),
2669
 
                     'revision'
 
2713
                     'revision',
 
2714
                     'show-ids',
2670
2715
                     ]
2671
2716
 
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,
 
2719
            show_ids=False):
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,
 
2735
                          show_ids=show_ids)
2689
2736
        finally:
2690
2737
            branch.unlock()
2691
2738
 
2983
3030
                  this_dir=None, backup_files=False,
2984
3031
                  merge_type=None,
2985
3032
                  file_list=None, show_base=False, reprocess=False,
 
3033
                  pull=False,
2986
3034
                  pb=DummyProgress()):
2987
3035
    """Merge changes into a tree.
2988
3036
 
3037
3085
        if merger.base_rev_id == merger.other_rev_id:
3038
3086
            note('Nothing to do.')
3039
3087
            return 0
 
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,))
 
3093
                return 0
3040
3094
        merger.backup_files = backup_files
3041
3095
        merger.merge_type = merge_type 
3042
3096
        merger.set_interesting_files(file_list)