~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Vincent Ladeuil
  • Date: 2011-08-12 09:49:24 UTC
  • mfrom: (6015.9.10 2.4)
  • mto: This revision was merged to the branch mainline in revision 6066.
  • Revision ID: v.ladeuil+lp@free.fr-20110812094924-knc5s0g7vs31a2f1
Merge 2.4 into trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
2317
2317
 
2318
2318
    :Other filtering:
2319
2319
 
2320
 
      The --message option can be used for finding revisions that match a
2321
 
      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.
2322
2325
 
2323
2326
    :Tips & tricks:
2324
2327
 
2384
2387
                   argname='N',
2385
2388
                   type=_parse_levels),
2386
2389
            Option('message',
2387
 
                   short_name='m',
2388
2390
                   help='Show revisions whose message matches this '
2389
2391
                        'regular expression.',
2390
 
                   type=str),
 
2392
                   type=str,
 
2393
                   hidden=True),
2391
2394
            Option('limit',
2392
2395
                   short_name='l',
2393
2396
                   help='Limit the output to the first N revisions.',
2404
2407
                   ),
2405
2408
            Option('signatures',
2406
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)
2407
2431
            ]
2408
2432
    encoding_type = 'replace'
2409
2433
 
2423
2447
            authors=None,
2424
2448
            exclude_common_ancestry=False,
2425
2449
            signatures=False,
 
2450
            match=None,
 
2451
            match_message=None,
 
2452
            match_committer=None,
 
2453
            match_author=None,
 
2454
            match_bugs=None,
2426
2455
            ):
2427
2456
        from bzrlib.log import (
2428
2457
            Logger,
2531
2560
        match_using_deltas = (len(file_ids) != 1 or filter_by_dir
2532
2561
            or delta_type or partial_history)
2533
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
            
2534
2575
        # Build the LogRequest and execute it
2535
2576
        if len(file_ids) == 0:
2536
2577
            file_ids = None
2539
2580
            start_revision=rev1, end_revision=rev2, limit=limit,
2540
2581
            message_search=message, delta_type=delta_type,
2541
2582
            diff_type=diff_type, _match_using_deltas=match_using_deltas,
2542
 
            exclude_common_ancestry=exclude_common_ancestry,
 
2583
            exclude_common_ancestry=exclude_common_ancestry, match=match_dict,
2543
2584
            signature=signatures
2544
2585
            )
2545
2586
        Logger(b, rqst).show(lf)
3032
3073
 
3033
3074
        old_file_id = rev_tree.path2id(relpath)
3034
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.
3035
3080
        if name_from_revision:
3036
3081
            # Try in revision if requested
3037
3082
            if old_file_id is None:
3039
3084
                    "%r is not present in revision %s" % (
3040
3085
                        filename, rev_tree.get_revision_id()))
3041
3086
            else:
3042
 
                content = rev_tree.get_file_text(old_file_id)
 
3087
                actual_file_id = old_file_id
3043
3088
        else:
3044
3089
            cur_file_id = tree.path2id(relpath)
3045
 
            found = False
3046
 
            if cur_file_id is not None:
3047
 
                # Then try with the actual file id
3048
 
                try:
3049
 
                    content = rev_tree.get_file_text(cur_file_id)
3050
 
                    found = True
3051
 
                except errors.NoSuchId:
3052
 
                    # The actual file id didn't exist at that time
3053
 
                    pass
3054
 
            if not found and old_file_id is not None:
3055
 
                # Finally try with the old file id
3056
 
                content = rev_tree.get_file_text(old_file_id)
3057
 
                found = True
3058
 
            if not found:
3059
 
                # 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:
3060
3095
                raise errors.BzrCommandError(
3061
3096
                    "%r is not present in revision %s" % (
3062
3097
                        filename, rev_tree.get_revision_id()))
3063
3098
        if filtered:
3064
 
            from bzrlib.filters import (
3065
 
                ContentFilterContext,
3066
 
                filtered_output_bytes,
3067
 
                )
3068
 
            filters = rev_tree._content_filter_stack(relpath)
3069
 
            chunks = content.splitlines(True)
3070
 
            content = filtered_output_bytes(chunks, filters,
3071
 
                ContentFilterContext(relpath, rev_tree))
3072
 
            self.cleanup_now()
3073
 
            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)
3074
3103
        else:
3075
 
            self.cleanup_now()
3076
 
            self.outf.write(content)
 
3104
            content = rev_tree.get_file_text(actual_file_id)
 
3105
        self.cleanup_now()
 
3106
        self.outf.write(content)
3077
3107
 
3078
3108
 
3079
3109
class cmd_local_time_offset(Command):