~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/delta.py

  • Committer: Robert Collins
  • Date: 2005-10-04 03:35:31 UTC
  • mfrom: (1393.1.30)
  • Revision ID: robertc@robertcollins.net-20051004033531-f057603b470ca4a2
merge from mpool

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.inventory import InventoryEntry
17
18
from bzrlib.trace import mutter
18
19
 
19
20
class TreeDelta(object):
171
172
            kind = old_ie.kind
172
173
            assert kind == new_ie.kind
173
174
            
174
 
            assert kind in ('file', 'directory', 'symlink', 'root_directory'), \
 
175
            assert kind in InventoryEntry.known_kinds, \
175
176
                   'invalid file kind %r' % kind
176
177
 
177
178
            if kind == 'root_directory':
182
183
                    and not is_inside_any(specific_files, new_inv.id2path(file_id))):
183
184
                    continue
184
185
 
185
 
            if kind == 'file':
186
 
                old_sha1 = old_tree.get_file_sha1(file_id)
187
 
                new_sha1 = new_tree.get_file_sha1(file_id)
188
 
                text_modified = (old_sha1 != new_sha1)
189
 
                old_exec = old_tree.is_executable(file_id)
190
 
                new_exec = new_tree.is_executable(file_id)
191
 
                meta_modified = (old_exec != new_exec)
192
 
            elif kind == 'symlink':
193
 
                t1 = old_tree.get_symlink_target(file_id)
194
 
                t2 = new_tree.get_symlink_target(file_id)
195
 
                if t1 != t2:
196
 
                    mutter("    symlink target changed")
197
 
                    # FIXME: which should we use ?
198
 
                    text_modified = True
199
 
                    meta_modified = False
200
 
                else:
201
 
                    text_modified = False
202
 
                    meta_modified = False
203
 
            else:
204
 
                ## mutter("no text to check for %r %r" % (file_id, kind))
205
 
                text_modified = False
206
 
                meta_modified = False
 
186
            # temporary hack until all entries are populated before clients 
 
187
            # get them
 
188
            old_path = old_inv.id2path(file_id)
 
189
            new_path = new_inv.id2path(file_id)
 
190
            old_ie._read_tree_state(old_path, old_tree)
 
191
            new_ie._read_tree_state(new_path, new_tree)
 
192
            text_modified, meta_modified = new_ie.detect_changes(old_ie)
207
193
 
208
194
            # TODO: Can possibly avoid calculating path strings if the
209
195
            # two files are unchanged and their names and parents are
212
198
            
213
199
            if (old_ie.name != new_ie.name
214
200
                or old_ie.parent_id != new_ie.parent_id):
215
 
                delta.renamed.append((old_inv.id2path(file_id),
216
 
                                      new_inv.id2path(file_id),
 
201
                delta.renamed.append((old_path,
 
202
                                      new_path,
217
203
                                      file_id, kind,
218
204
                                      text_modified, meta_modified))
219
205
            elif text_modified or meta_modified:
220
 
                delta.modified.append((new_inv.id2path(file_id), file_id, kind,
 
206
                delta.modified.append((new_path, file_id, kind,
221
207
                                       text_modified, meta_modified))
222
208
            elif want_unchanged:
223
 
                delta.unchanged.append((new_inv.id2path(file_id), file_id, kind))
 
209
                delta.unchanged.append((new_path, file_id, kind))
224
210
        else:
225
211
            kind = old_inv.get_file_kind(file_id)
226
212
            if kind == 'root_directory':