~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

 added test for function fileid_involved

Show diffs side-by-side

added added

removed removed

Lines of Context:
1120
1120
        w = self._get_inventory_weave( )
1121
1121
        from_set = set(w.inclusions([w.lookup(from_revid)]))
1122
1122
        to_set = set(w.inclusions([w.lookup(to_revid)]))
1123
 
        changed = to_set.difference(from_set)
1124
 
        return self.fileid_involved_by_set(changed)
 
1123
        included = to_set.difference(from_set)
 
1124
        changed = map(w.idx_to_name,included)
 
1125
        return self._fileid_involved_by_set(changed)
1125
1126
 
1126
1127
    def fileid_involved(self, last_revid=None):
1127
1128
        """ This function returns the file_id(s) involved in the
1131
1132
        """
1132
1133
        w = self._get_inventory_weave( )
1133
1134
        if not last_revid:
1134
 
            changed = set(w.inclusions([w.numversions( )-1]))
 
1135
            changed = set(w._names)
1135
1136
        else:
1136
 
            changed = w.inclusions([w.lookup(last_revid)])
1137
 
        return self.fileid_involved_by_set(changed)
 
1137
            included = w.inclusions([w.lookup(last_revid)])
 
1138
            changed = map(w.idx_to_name, included)
 
1139
        return self._fileid_involved_by_set(changed)
1138
1140
 
1139
1141
    def fileid_involved_by_set(self, changes):
1140
1142
        """ This function returns the file_id(s) involved in the
1141
1143
            changese present in the set changes
1142
1144
        """
1143
1145
        w = self._get_inventory_weave( )
 
1146
        return self._fileid_involved_by_set(changes)
 
1147
 
 
1148
    def _fileid_involved_by_set(self, changes):
 
1149
        w = self._get_inventory_weave( )
1144
1150
        file_ids = set( )
1145
 
 
1146
 
        for lineno, insert, deleteset, line in w._walk():
1147
 
            if insert in changes:
1148
 
 
1149
 
                start = line.find('file_id="')+9
1150
 
                if start < 9: continue
1151
 
                end = line.find('"',start)
1152
 
                assert end>= 0
1153
 
                file_id = line[start:end]
1154
 
 
 
1151
        for line in w._weave:
 
1152
 
 
1153
            # it is ugly, but it is due to the weave structure
 
1154
            if not isinstance(line,basestring): continue
 
1155
 
 
1156
            start = line.find('file_id="')+9
 
1157
            if start < 9: continue
 
1158
            end = line.find('"',start)
 
1159
            assert end>= 0
 
1160
            file_id = line[start:end]
 
1161
 
 
1162
            # check if file_id is already present
 
1163
            if file_id in file_ids: continue
 
1164
 
 
1165
            start = line.find('revision="')+10
 
1166
            if start < 10: continue
 
1167
            end = line.find('"',start)
 
1168
            assert end>= 0
 
1169
            revision_id = line[start:end]
 
1170
 
 
1171
            if revision_id in changes:
1155
1172
                file_ids.add(file_id)
1156
1173
 
1157
1174
        return file_ids