~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/delta.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-07-13 13:31:05 UTC
  • mfrom: (1711.2.88 jam-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060713133105-7c8e508aaa4886e2
(Adeodato Simó) use terminal_width() for status pending merges

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2005, 2006 Canonical
2
 
#
 
2
 
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
7
 
#
 
7
 
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
11
# GNU General Public License for more details.
12
 
#
 
12
 
13
13
# You should have received a copy of the GNU General Public License
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
17
from bzrlib.inventory import InventoryEntry
18
18
from bzrlib.trace import mutter
19
 
from bzrlib.symbol_versioning import deprecated_function, zero_ten
 
19
from bzrlib import tree
20
20
 
21
21
 
22
22
class TreeDelta(object):
143
143
            show_list(self.unchanged)
144
144
 
145
145
 
146
 
@deprecated_function(zero_ten)
147
 
def compare_trees(old_tree, new_tree, want_unchanged=False,
148
 
                  specific_files=None, extra_trees=None,
 
146
def compare_trees(old_tree, new_tree, want_unchanged=False, 
 
147
                  specific_files=None, extra_trees=None, 
149
148
                  require_versioned=False):
150
 
    """compare_trees was deprecated in 0.10. Please see Tree.changes_from."""
151
 
    return new_tree.changes_from(old_tree,
152
 
        want_unchanged=want_unchanged,
153
 
        specific_files=specific_files,
154
 
        extra_trees=extra_trees,
155
 
        require_versioned=require_versioned)
 
149
    """Describe changes from one tree to another.
 
150
 
 
151
    Returns a TreeDelta with details of added, modified, renamed, and
 
152
    deleted entries.
 
153
 
 
154
    The root entry is specifically exempt.
 
155
 
 
156
    This only considers versioned files.
 
157
 
 
158
    want_unchanged
 
159
        If true, also list files unchanged from one version to
 
160
        the next.
 
161
 
 
162
    specific_files
 
163
        If supplied, only check for changes to specified names or
 
164
        files within them.  When mapping filenames to ids, all matches in all
 
165
        trees (including optional extra_trees) are used, and all children of
 
166
        matched directories are included.
 
167
 
 
168
    extra_trees
 
169
        If non-None, a list of more trees to use for looking up file_ids from
 
170
        paths
 
171
 
 
172
    require_versioned
 
173
        If true, an all files are required to be versioned, and
 
174
        PathsNotVersionedError will be thrown if they are not.
 
175
    """
 
176
    # NB: show_status depends on being able to pass in non-versioned files and
 
177
    # report them as unknown
 
178
    old_tree.lock_read()
 
179
    try:
 
180
        new_tree.lock_read()
 
181
        try:
 
182
            trees = (new_tree, old_tree)
 
183
            if extra_trees is not None:
 
184
                trees = trees + tuple(extra_trees)
 
185
            specific_file_ids = tree.find_ids_across_trees(specific_files, 
 
186
                trees, require_versioned=require_versioned)
 
187
            return _compare_trees(old_tree, new_tree, want_unchanged,
 
188
                                  specific_file_ids)
 
189
        finally:
 
190
            new_tree.unlock()
 
191
    finally:
 
192
        old_tree.unlock()
156
193
 
157
194
 
158
195
def _compare_trees(old_tree, new_tree, want_unchanged, specific_file_ids):
193
230
            return
194
231
 
195
232
        if specific_file_ids:
196
 
            if (old_entry.file_id not in specific_file_ids and 
197
 
                new_entry.file_id not in specific_file_ids):
 
233
            if (old_file_id not in specific_file_ids and 
 
234
                new_file_id not in specific_file_ids):
198
235
                return
199
236
 
200
237
        # temporary hack until all entries are populated before clients