~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/diff.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-02-28 04:35:06 UTC
  • mfrom: (1551.2.15 Aaron's small fixes)
  • Revision ID: pqm@pqm.ubuntu.com-20060228043506-6627101e946abb2d
Fix diff support of checkouts

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
from bzrlib.delta import compare_trees
18
18
from bzrlib.errors import BzrError
 
19
from bzrlib.symbol_versioning import *
19
20
from bzrlib.trace import mutter
20
21
 
21
22
# TODO: Rather than building a changeset object, we should probably
141
142
        oldtmpf.close()                 # and delete
142
143
        newtmpf.close()
143
144
 
 
145
 
 
146
@deprecated_function(zero_eight)
144
147
def show_diff(b, from_spec, specific_files, external_diff_options=None,
145
148
              revision2=None, output=None, b2=None):
146
149
    """Shortcut for showing the diff to the working tree.
147
150
 
 
151
    Please use show_diff_trees instead.
 
152
 
148
153
    b
149
154
        Branch.
150
155
 
177
182
                           external_diff_options)
178
183
 
179
184
 
 
185
def diff_cmd_helper(tree, specific_files, external_diff_options, 
 
186
                    old_revision_spec=None, new_revision_spec=None):
 
187
    """Helper for cmd_diff.
 
188
 
 
189
   tree 
 
190
        A WorkingTree
 
191
 
 
192
    specific_files
 
193
        The specific files to compare, or None
 
194
 
 
195
    external_diff_options
 
196
        If non-None, run an external diff, and pass it these options
 
197
 
 
198
    old_revision_spec
 
199
        If None, use basis tree as old revision, otherwise use the tree for
 
200
        the specified revision. 
 
201
 
 
202
    new_revision_spec
 
203
        If None, use working tree as new revision, otherwise use the tree for
 
204
        the specified revision.
 
205
    
 
206
    The more general form is show_diff_trees(), where the caller
 
207
    supplies any two trees.
 
208
    """
 
209
    import sys
 
210
    output = sys.stdout
 
211
    def spec_tree(spec):
 
212
        revision_id = spec.in_store(tree.branch).rev_id
 
213
        return tree.branch.repository.revision_tree(revision_id)
 
214
    if old_revision_spec is None:
 
215
        old_tree = tree.basis_tree()
 
216
    else:
 
217
        old_tree = spec_tree(old_revision_spec)
 
218
 
 
219
    if new_revision_spec is None:
 
220
        new_tree = tree
 
221
    else:
 
222
        new_tree = spec_tree(new_revision_spec)
 
223
 
 
224
    return show_diff_trees(old_tree, new_tree, sys.stdout, specific_files,
 
225
                           external_diff_options)
 
226
 
180
227
 
181
228
def show_diff_trees(old_tree, new_tree, to_file, specific_files=None,
182
229
                    external_diff_options=None):