~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/delta.py

  • Committer: Aaron Bentley
  • Date: 2005-10-04 04:32:32 UTC
  • mfrom: (1185.12.6)
  • mto: (1185.12.13)
  • mto: This revision was merged to the branch mainline in revision 1419.
  • Revision ID: aaron.bentley@utoronto.ca-20051004043231-40302a149769263b
merged my own changes

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
18
17
from bzrlib.trace import mutter
19
18
 
20
19
class TreeDelta(object):
172
171
            kind = old_ie.kind
173
172
            assert kind == new_ie.kind
174
173
            
175
 
            assert kind in InventoryEntry.known_kinds, \
 
174
            assert kind in ('file', 'directory', 'symlink', 'root_directory'), \
176
175
                   'invalid file kind %r' % kind
177
176
 
178
177
            if kind == 'root_directory':
183
182
                    and not is_inside_any(specific_files, new_inv.id2path(file_id))):
184
183
                    continue
185
184
 
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)
 
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
193
207
 
194
208
            # TODO: Can possibly avoid calculating path strings if the
195
209
            # two files are unchanged and their names and parents are
198
212
            
199
213
            if (old_ie.name != new_ie.name
200
214
                or old_ie.parent_id != new_ie.parent_id):
201
 
                delta.renamed.append((old_path,
202
 
                                      new_path,
 
215
                delta.renamed.append((old_inv.id2path(file_id),
 
216
                                      new_inv.id2path(file_id),
203
217
                                      file_id, kind,
204
218
                                      text_modified, meta_modified))
205
219
            elif text_modified or meta_modified:
206
 
                delta.modified.append((new_path, file_id, kind,
 
220
                delta.modified.append((new_inv.id2path(file_id), file_id, kind,
207
221
                                       text_modified, meta_modified))
208
222
            elif want_unchanged:
209
 
                delta.unchanged.append((new_path, file_id, kind))
 
223
                delta.unchanged.append((new_inv.id2path(file_id), file_id, kind))
210
224
        else:
211
225
            kind = old_inv.get_file_kind(file_id)
212
226
            if kind == 'root_directory':