/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/log.py

  • Committer: Martin Pool
  • Date: 2005-05-05 08:26:20 UTC
  • Revision ID: mbp@sourcefrog.net-20050505082620-3c5b7d3a87e909d7
- New usage bzr log FILENAME

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
    TODO: Perhaps some way to limit this to only particular revisions,
31
31
    or to traverse a non-branch set of revisions?
 
32
 
 
33
    TODO: If a directory is given, then by default look for all
 
34
    changes under that directory.
32
35
    """
33
36
    last_ie = None
34
37
    last_path = None
63
66
        revno += 1
64
67
 
65
68
 
66
 
def show_log(branch, show_timezone='original', verbose=False,
 
69
def show_log(branch,
 
70
             filename=None,
 
71
             show_timezone='original',
 
72
             verbose=False,
67
73
             show_ids=False,
68
74
             to_file=None):
69
75
    """Write out human-readable log of commits to this branch.
70
76
 
 
77
    filename
 
78
        If true, list only the commits affecting the specified
 
79
        file, rather than all commits.
 
80
 
71
81
    show_timezone
72
82
        'original' (committer's timezone),
73
83
        'utc' (universal time), or
90
100
    if to_file == None:
91
101
        import sys
92
102
        to_file = sys.stdout
 
103
 
 
104
    if filename:
 
105
        file_id = branch.read_working_inventory().path2id(filename)
 
106
        def which_revs():
 
107
            for revno, revid, why in find_touching_revisions(branch, file_id):
 
108
                yield revno, revid
 
109
    else:
 
110
        def which_revs():
 
111
            for i, revid in enumerate(branch.revision_history()):
 
112
                yield i+1, revid
93
113
        
94
114
    branch._need_readlock()
95
 
    revno = 1
96
115
    precursor = None
97
 
    for revision_id in branch.revision_history():
 
116
    for revno, revision_id in which_revs():
98
117
        print >>to_file,  '-' * 60
99
118
        print >>to_file,  'revno:', revno
100
119
        rev = branch.get_revision(revision_id)
108
127
            raise BzrCheckError("retrieved wrong revision: %r"
109
128
                                % (revision_id, rev.revision_id))
110
129
 
111
 
        ## opportunistic consistency check, same as check_patch_chaining
112
 
        if rev.precursor != precursor:
113
 
            raise BzrCheckError("mismatched precursor!")
114
 
 
115
130
        print >>to_file,  'message:'
116
131
        if not rev.message:
117
132
            print >>to_file,  '  (no message)'
119
134
            for l in rev.message.split('\n'):
120
135
                print >>to_file,  '  ' + l
121
136
 
122
 
        if verbose and precursor:
 
137
        # Don't show a list of changed files if we were asked about
 
138
        # one specific file.
 
139
 
 
140
        if verbose and precursor and not filename:
123
141
            # TODO: Group as added/deleted/renamed instead
124
142
            # TODO: Show file ids
125
143
            print >>to_file, 'changed files:'
136
154
                    show_status(file_state, kind,
137
155
                        old_name + ' => ' + new_name)
138
156
 
139
 
        revno += 1
140
157
        precursor = revision_id
 
158