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

MergeĀ mainline

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
 
17
from bzrlib.delta import compare_trees
 
18
from bzrlib.errors import BzrError
 
19
from bzrlib.symbol_versioning import *
17
20
from bzrlib.trace import mutter
18
 
from bzrlib.errors import BzrError
19
 
from bzrlib.delta import compare_trees
20
21
 
21
22
# TODO: Rather than building a changeset object, we should probably
22
23
# invoke callbacks on an object.  That object can either accumulate a
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
 
159
164
        output = sys.stdout
160
165
 
161
166
    if from_spec is None:
 
167
        old_tree = b.bzrdir.open_workingtree()
162
168
        if b2 is None:
163
 
            old_tree = b.basis_tree()
164
 
        else:
165
 
            old_tree = b.working_tree()
 
169
            old_tree = old_tree = old_tree.basis_tree()
166
170
    else:
167
171
        old_tree = b.repository.revision_tree(from_spec.in_history(b).rev_id)
168
172
 
169
173
    if revision2 is None:
170
174
        if b2 is None:
171
 
            new_tree = b.working_tree()
 
175
            new_tree = b.bzrdir.open_workingtree()
172
176
        else:
173
 
            new_tree = b2.working_tree()
 
177
            new_tree = b2.bzrdir.open_workingtree()
174
178
    else:
175
179
        new_tree = b.repository.revision_tree(revision2.in_history(b).rev_id)
176
180
 
178
182
                           external_diff_options)
179
183
 
180
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
 
181
227
 
182
228
def show_diff_trees(old_tree, new_tree, to_file, specific_files=None,
183
229
                    external_diff_options=None):