/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: John Arbash Meinel
  • Date: 2006-12-21 19:28:45 UTC
  • mfrom: (2211 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2212.
  • Revision ID: john@arbash-meinel.com-20061221192845-fmv60t3k5t0xxks4
[merge] bzr.dev 2211

Show diffs side-by-side

added added

removed removed

Lines of Context:
1213
1213
    #       deleted files.
1214
1214
 
1215
1215
    # TODO: This probably handles non-Unix newlines poorly.
1216
 
    
 
1216
 
1217
1217
    takes_args = ['file*']
1218
 
    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
        ]
1219
1224
    aliases = ['di', 'dif']
1220
1225
    encoding_type = 'exact'
1221
1226
 
1231
1236
        elif prefix == '1':
1232
1237
            old_label = 'old/'
1233
1238
            new_label = 'new/'
1234
 
        else:
1235
 
            if not ':' in prefix:
1236
 
                 raise BzrCommandError(
1237
 
                     "--diff-prefix expects two values separated by a colon")
 
1239
        elif ':' in prefix:
1238
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')
1239
1248
        
1240
1249
        try:
1241
1250
            tree1, file_list = internal_tree_files(file_list)
1261
1270
                tree1, tree2 = None, None
1262
1271
            else:
1263
1272
                raise
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,
1269
 
                                       revision[0], 
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)
1275
 
            else:
1276
 
                raise errors.BzrCommandError('bzr diff --revision takes exactly'
1277
 
                                             ' one or two revision identifiers')
1278
 
        else:
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)
1284
 
            else:
1285
 
                return diff_cmd_helper(tree1, file_list, diff_options,
1286
 
                                       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)
1287
1290
 
1288
1291
 
1289
1292
class cmd_deleted(Command):
1375
1378
                            help='show from oldest to newest'),
1376
1379
                     'timezone', 
1377
1380
                     Option('verbose', 
 
1381
                             short_name='v',
1378
1382
                             help='show files changed in each revision'),
1379
1383
                     'show-ids', 'revision',
1380
1384
                     'log-format',
1381
1385
                     'line', 'long', 
1382
1386
                     Option('message',
 
1387
                            short_name='m',
1383
1388
                            help='show revisions whose message matches this regexp',
1384
1389
                            type=str),
1385
1390
                     'short',
1516
1521
class cmd_ls(Command):
1517
1522
    """List files in a tree.
1518
1523
    """
 
1524
 
1519
1525
    # TODO: Take a revision or remote path and list that tree instead.
1520
 
    hidden = True
1521
1526
    takes_options = ['verbose', 'revision',
1522
1527
                     Option('non-recursive',
1523
1528
                            help='don\'t recurse into sub-directories'),
1528
1533
                     Option('ignored', help='Print ignored files'),
1529
1534
 
1530
1535
                     Option('null', help='Null separate the files'),
 
1536
                     'kind',
1531
1537
                    ]
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,
1536
 
            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')
1537
1546
 
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)
1552
1561
 
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:
1557
1566
                    continue
1558
1567
                if not all and not selection[fc]:
1559
1568
                    continue
 
1569
                if kind is not None and fkind != kind:
 
1570
                    continue
1560
1571
                if verbose:
1561
1572
                    kindch = entry.kind_character()
1562
1573
                    self.outf.write('%-8s %s%s\n' % (fc, fp, kindch))
1750
1761
 
1751
1762
    takes_options = ['revision', 'name-from-revision']
1752
1763
    takes_args = ['filename']
 
1764
    encoding_type = 'exact'
1753
1765
 
1754
1766
    @display_command
1755
1767
    def run(self, filename, revision=None, name_from_revision=False):
1829
1841
                     Option('unchanged',
1830
1842
                            help='commit even if nothing has changed'),
1831
1843
                     Option('file', type=str, 
 
1844
                            short_name='F',
1832
1845
                            argname='msgfile',
1833
1846
                            help='file containing commit message'),
1834
1847
                     Option('strict',
2110
2123
            if verbose is None:
2111
2124
                verbose = True
2112
2125
            # TODO: should possibly lock the history file...
2113
 
            benchfile = open(".perf_history", "at")
 
2126
            benchfile = open(".perf_history", "at", buffering=1)
2114
2127
        else:
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 "
2229
 
                            "conflicts"), 
 
2242
                            "conflicts"),
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.'),
 
2249
                     ]
2232
2250
 
2233
2251
    def help(self):
2234
2252
        from inspect import getdoc
2236
2254
 
2237
2255
    def run(self, branch=None, revision=None, force=False, merge_type=None,
2238
2256
            show_base=False, reprocess=False, remember=False, 
2239
 
            uncommitted=False):
 
2257
            uncommitted=False, pull=False):
2240
2258
        if merge_type is None:
2241
2259
            merge_type = _mod_merge.Merge3Merger
2242
2260
 
2307
2325
                    merge_type=merge_type,
2308
2326
                    reprocess=reprocess,
2309
2327
                    show_base=show_base,
 
2328
                    pull=pull,
2310
2329
                    pb=pb, file_list=interesting_files)
2311
2330
            finally:
2312
2331
                pb.finished()
2966
2985
                  this_dir=None, backup_files=False,
2967
2986
                  merge_type=None,
2968
2987
                  file_list=None, show_base=False, reprocess=False,
 
2988
                  pull=False,
2969
2989
                  pb=DummyProgress()):
2970
2990
    """Merge changes into a tree.
2971
2991
 
3020
3040
        if merger.base_rev_id == merger.other_rev_id:
3021
3041
            note('Nothing to do.')
3022
3042
            return 0
 
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,))
 
3048
                return 0
3023
3049
        merger.backup_files = backup_files
3024
3050
        merger.merge_type = merge_type 
3025
3051
        merger.set_interesting_files(file_list)