~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/delta.py

  • Committer: Aaron Bentley
  • Date: 2006-09-19 15:08:19 UTC
  • mto: This revision was merged to the branch mainline in revision 2162.
  • Revision ID: abentley@panoramicfeedback.com-20060919150819-fe949d51643d9d7c
Simplify add/remove code

Show diffs side-by-side

added added

removed removed

Lines of Context:
173
173
            continue
174
174
        assert kind[0] == kind[1] or None in kind
175
175
        # the only 'kind change' permitted is creation/deletion
176
 
 
177
 
        # If the name changes, or the parent_id changes, we have a rename
178
 
        # (if we move a parent, that doesn't count as a rename for the file)
179
 
        if versioned[0] != versioned[1]:
180
 
            if versioned == (False, True) and (kind[0] != kind[1]
181
 
                                               and kind[1] is not None):
182
 
                delta.added.append((path, file_id, kind[1]))
183
 
            else:
184
 
                assert versioned == (True, False)
185
 
                old_path = old_tree.id2path(file_id)
186
 
                old_kind = old_tree.kind(file_id)
187
 
                delta.removed.append((old_path, file_id, old_kind))
188
 
        elif kind[0] != kind[1]:
189
 
            if kind[0] is None:
190
 
                delta.added.append((path, file_id, kind[1]))
191
 
            else:
192
 
                assert kind[1] is None
193
 
                old_path = old_tree.id2path(file_id)
194
 
                old_kind = old_tree.kind(file_id)
195
 
                delta.removed.append((old_path, file_id, old_kind))
196
 
                
 
176
        fully_present = tuple((versioned[x] and kind[x] is not None) for
 
177
                              x in range(2))
 
178
        if fully_present[1] and not fully_present[0]:
 
179
            delta.added.append((path, file_id, kind[1]))
 
180
        elif fully_present[0] and not fully_present[1]:
 
181
            old_path = old_tree.id2path(file_id)
 
182
            delta.removed.append((old_path, file_id, kind[0]))
197
183
        elif name[0] != name[1] or parent_id[0] != parent_id[1]:
 
184
            # If the name changes, or the parent_id changes, we have a rename
 
185
            # (if we move a parent, that doesn't count as a rename for the
 
186
            # file)
198
187
            old_path = old_tree.id2path(file_id)
199
188
            delta.renamed.append((old_path,
200
189
                                  path,