~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-08-15 13:49:38 UTC
  • mfrom: (6060.3.1 fix-last-revno-args)
  • Revision ID: pqm@pqm.ubuntu.com-20110815134938-4fuo63g4v2hj8jdt
(jelmer) Cope with the localhost having the name 'localhost' when running
 the test suite. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
232
232
    unknown
233
233
        Not versioned and not matching an ignore pattern.
234
234
 
235
 
    Additionally for directories, symlinks and files with an executable
236
 
    bit, Bazaar indicates their type using a trailing character: '/', '@'
237
 
    or '*' respectively.
 
235
    Additionally for directories, symlinks and files with a changed
 
236
    executable bit, Bazaar indicates their type using a trailing
 
237
    character: '/', '@' or '*' respectively. These decorations can be
 
238
    disabled using the '--no-classify' option.
238
239
 
239
240
    To see ignored files use 'bzr ignored'.  For details on the
240
241
    changes to file texts, use 'bzr diff'.
271
272
                            short_name='V'),
272
273
                     Option('no-pending', help='Don\'t show pending merges.',
273
274
                           ),
 
275
                     Option('no-classify',
 
276
                            help='Do not mark object type using indicator.',
 
277
                           ),
274
278
                     ]
275
279
    aliases = ['st', 'stat']
276
280
 
279
283
 
280
284
    @display_command
281
285
    def run(self, show_ids=False, file_list=None, revision=None, short=False,
282
 
            versioned=False, no_pending=False, verbose=False):
 
286
            versioned=False, no_pending=False, verbose=False,
 
287
            no_classify=False):
283
288
        from bzrlib.status import show_tree_status
284
289
 
285
290
        if revision and len(revision) > 2:
299
304
        show_tree_status(tree, show_ids=show_ids,
300
305
                         specific_files=relfile_list, revision=revision,
301
306
                         to_file=self.outf, short=short, versioned=versioned,
302
 
                         show_pending=(not no_pending), verbose=verbose)
 
307
                         show_pending=(not no_pending), verbose=verbose,
 
308
                         classify=not no_classify)
303
309
 
304
310
 
305
311
class cmd_cat_revision(Command):
797
803
                                      require_versioned=True)
798
804
            # find_ids_across_trees may include some paths that don't
799
805
            # exist in 'tree'.
800
 
            entries = sorted((tree.id2path(file_id), tree.inventory[file_id])
801
 
                             for file_id in file_ids if file_id in tree)
 
806
            entries = sorted(
 
807
                (tree.id2path(file_id), tree.inventory[file_id])
 
808
                for file_id in file_ids if tree.has_id(file_id))
802
809
        else:
803
810
            entries = tree.inventory.entries()
804
811
 
2155
2162
        basis_inv = basis.inventory
2156
2163
        inv = wt.inventory
2157
2164
        for file_id in inv:
2158
 
            if file_id in basis_inv:
 
2165
            if basis_inv.has_id(file_id):
2159
2166
                continue
2160
2167
            if inv.is_root(file_id) and len(basis_inv) == 0:
2161
2168
                continue
2310
2317
 
2311
2318
    :Other filtering:
2312
2319
 
2313
 
      The --message option can be used for finding revisions that match a
2314
 
      regular expression in a commit message.
 
2320
      The --match option can be used for finding revisions that match a
 
2321
      regular expression in a commit message, committer, author or bug.
 
2322
      Specifying the option several times will match any of the supplied
 
2323
      expressions. --match-author, --match-bugs, --match-committer and
 
2324
      --match-message can be used to only match a specific field.
2315
2325
 
2316
2326
    :Tips & tricks:
2317
2327
 
2377
2387
                   argname='N',
2378
2388
                   type=_parse_levels),
2379
2389
            Option('message',
2380
 
                   short_name='m',
2381
2390
                   help='Show revisions whose message matches this '
2382
2391
                        'regular expression.',
2383
 
                   type=str),
 
2392
                   type=str,
 
2393
                   hidden=True),
2384
2394
            Option('limit',
2385
2395
                   short_name='l',
2386
2396
                   help='Limit the output to the first N revisions.',
2397
2407
                   ),
2398
2408
            Option('signatures',
2399
2409
                   help='Show digital signature validity'),
 
2410
            ListOption('match',
 
2411
                short_name='m',
 
2412
                help='Show revisions whose properties match this '
 
2413
                'expression.',
 
2414
                type=str),
 
2415
            ListOption('match-message',
 
2416
                   help='Show revisions whose message matches this '
 
2417
                   'expression.',
 
2418
                type=str),
 
2419
            ListOption('match-committer',
 
2420
                   help='Show revisions whose committer matches this '
 
2421
                   'expression.',
 
2422
                type=str),
 
2423
            ListOption('match-author',
 
2424
                   help='Show revisions whose authors match this '
 
2425
                   'expression.',
 
2426
                type=str),
 
2427
            ListOption('match-bugs',
 
2428
                   help='Show revisions whose bugs match this '
 
2429
                   'expression.',
 
2430
                type=str)
2400
2431
            ]
2401
2432
    encoding_type = 'replace'
2402
2433
 
2416
2447
            authors=None,
2417
2448
            exclude_common_ancestry=False,
2418
2449
            signatures=False,
 
2450
            match=None,
 
2451
            match_message=None,
 
2452
            match_committer=None,
 
2453
            match_author=None,
 
2454
            match_bugs=None,
2419
2455
            ):
2420
2456
        from bzrlib.log import (
2421
2457
            Logger,
2524
2560
        match_using_deltas = (len(file_ids) != 1 or filter_by_dir
2525
2561
            or delta_type or partial_history)
2526
2562
 
 
2563
        match_dict = {}
 
2564
        if match:
 
2565
            match_dict[''] = match
 
2566
        if match_message:
 
2567
            match_dict['message'] = match_message
 
2568
        if match_committer:
 
2569
            match_dict['committer'] = match_committer
 
2570
        if match_author:
 
2571
            match_dict['author'] = match_author
 
2572
        if match_bugs:
 
2573
            match_dict['bugs'] = match_bugs
 
2574
            
2527
2575
        # Build the LogRequest and execute it
2528
2576
        if len(file_ids) == 0:
2529
2577
            file_ids = None
2532
2580
            start_revision=rev1, end_revision=rev2, limit=limit,
2533
2581
            message_search=message, delta_type=delta_type,
2534
2582
            diff_type=diff_type, _match_using_deltas=match_using_deltas,
2535
 
            exclude_common_ancestry=exclude_common_ancestry,
 
2583
            exclude_common_ancestry=exclude_common_ancestry, match=match_dict,
2536
2584
            signature=signatures
2537
2585
            )
2538
2586
        Logger(b, rqst).show(lf)
3025
3073
 
3026
3074
        old_file_id = rev_tree.path2id(relpath)
3027
3075
 
 
3076
        # TODO: Split out this code to something that generically finds the
 
3077
        # best id for a path across one or more trees; it's like
 
3078
        # find_ids_across_trees but restricted to find just one. -- mbp
 
3079
        # 20110705.
3028
3080
        if name_from_revision:
3029
3081
            # Try in revision if requested
3030
3082
            if old_file_id is None:
3032
3084
                    "%r is not present in revision %s" % (
3033
3085
                        filename, rev_tree.get_revision_id()))
3034
3086
            else:
3035
 
                content = rev_tree.get_file_text(old_file_id)
 
3087
                actual_file_id = old_file_id
3036
3088
        else:
3037
3089
            cur_file_id = tree.path2id(relpath)
3038
 
            found = False
3039
 
            if cur_file_id is not None:
3040
 
                # Then try with the actual file id
3041
 
                try:
3042
 
                    content = rev_tree.get_file_text(cur_file_id)
3043
 
                    found = True
3044
 
                except errors.NoSuchId:
3045
 
                    # The actual file id didn't exist at that time
3046
 
                    pass
3047
 
            if not found and old_file_id is not None:
3048
 
                # Finally try with the old file id
3049
 
                content = rev_tree.get_file_text(old_file_id)
3050
 
                found = True
3051
 
            if not found:
3052
 
                # Can't be found anywhere
 
3090
            if cur_file_id is not None and rev_tree.has_id(cur_file_id):
 
3091
                actual_file_id = cur_file_id
 
3092
            elif old_file_id is not None:
 
3093
                actual_file_id = old_file_id
 
3094
            else:
3053
3095
                raise errors.BzrCommandError(
3054
3096
                    "%r is not present in revision %s" % (
3055
3097
                        filename, rev_tree.get_revision_id()))
3056
3098
        if filtered:
3057
 
            from bzrlib.filters import (
3058
 
                ContentFilterContext,
3059
 
                filtered_output_bytes,
3060
 
                )
3061
 
            filters = rev_tree._content_filter_stack(relpath)
3062
 
            chunks = content.splitlines(True)
3063
 
            content = filtered_output_bytes(chunks, filters,
3064
 
                ContentFilterContext(relpath, rev_tree))
3065
 
            self.cleanup_now()
3066
 
            self.outf.writelines(content)
 
3099
            from bzrlib.filter_tree import ContentFilterTree
 
3100
            filter_tree = ContentFilterTree(rev_tree,
 
3101
                rev_tree._content_filter_stack)
 
3102
            content = filter_tree.get_file_text(actual_file_id)
3067
3103
        else:
3068
 
            self.cleanup_now()
3069
 
            self.outf.write(content)
 
3104
            content = rev_tree.get_file_text(actual_file_id)
 
3105
        self.cleanup_now()
 
3106
        self.outf.write(content)
3070
3107
 
3071
3108
 
3072
3109
class cmd_local_time_offset(Command):
3291
3328
                    raise errors.BzrCommandError("please specify a commit"
3292
3329
                        " message with either --message or --file")
3293
3330
            if my_message == "":
3294
 
                raise errors.BzrCommandError("empty commit message specified")
 
3331
                raise errors.BzrCommandError("Empty commit message specified."
 
3332
                        " Please specify a commit message with either"
 
3333
                        " --message or --file or leave a blank message"
 
3334
                        " with --message \"\".")
3295
3335
            return my_message
3296
3336
 
3297
3337
        # The API permits a commit with a filter of [] to mean 'select nothing'