~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/diff.py

Merge in bzrdir work to enable checkout improvements.

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
17
19
from bzrlib.trace import mutter
18
 
from bzrlib.errors import BzrError
19
 
from bzrlib.delta import compare_trees
 
20
from bzrlib.workingtree import WorkingTree
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
159
160
        output = sys.stdout
160
161
 
161
162
    if from_spec is None:
 
163
        old_tree = WorkingTree(b.base, b)
162
164
        if b2 is None:
163
 
            old_tree = b.basis_tree()
164
 
        else:
165
 
            old_tree = b.working_tree()
 
165
            old_tree = old_tree = old_tree.basis_tree()
166
166
    else:
167
 
        old_tree = b.revision_tree(from_spec.in_history(b).rev_id)
 
167
        old_tree = b.repository.revision_tree(from_spec.in_history(b).rev_id)
168
168
 
169
169
    if revision2 is None:
170
170
        if b2 is None:
171
 
            new_tree = b.working_tree()
 
171
            new_tree = WorkingTree(b.base, b)
172
172
        else:
173
 
            new_tree = b2.working_tree()
 
173
            new_tree = WorkingTree(b2.base, b2)
174
174
    else:
175
 
        new_tree = b.revision_tree(revision2.in_history(b).rev_id)
 
175
        new_tree = b.repository.revision_tree(revision2.in_history(b).rev_id)
176
176
 
177
177
    return show_diff_trees(old_tree, new_tree, output, specific_files,
178
178
                           external_diff_options)
190
190
        If set, use an external GNU diff and pass these options.
191
191
    """
192
192
 
 
193
    old_tree.lock_read()
 
194
    try:
 
195
        new_tree.lock_read()
 
196
        try:
 
197
            return _show_diff_trees(old_tree, new_tree, to_file,
 
198
                                    specific_files, external_diff_options)
 
199
        finally:
 
200
            new_tree.unlock()
 
201
    finally:
 
202
        old_tree.unlock()
 
203
 
 
204
 
 
205
def _show_diff_trees(old_tree, new_tree, to_file,
 
206
                     specific_files, external_diff_options):
 
207
 
193
208
    # TODO: Options to control putting on a prefix or suffix, perhaps as a format string
194
209
    old_label = ''
195
210
    new_label = ''