487
487
def store_revision_signature(self, gpg_strategy, plaintext, revision_id):
488
488
raise NotImplementedError('store_revision_signature is abstract')
490
def fileid_involved_between_revs(self, from_revid, to_revid):
491
""" This function returns the file_id(s) involved in the
492
changes between the from_revid revision and the to_revid
495
raise NotImplementedError('fileid_involved_between_revs is abstract')
497
def fileid_involved(self, last_revid=None):
498
""" This function returns the file_id(s) involved in the
499
changes up to the revision last_revid
500
If no parametr is passed, then all file_id[s] present in the
501
repository are returned
503
raise NotImplementedError('fileid_involved is abstract')
505
def fileid_involved_by_set(self, changes):
506
""" This function returns the file_id(s) involved in the
507
changes present in the set 'changes'
509
raise NotImplementedError('fileid_involved_by_set is abstract')
490
511
class BzrBranch(Branch):
491
512
"""A branch stored in the actual filesystem.
1115
1136
self.revision_store.add(StringIO(gpg_strategy.sign(plaintext)),
1116
1137
revision_id, "sig")
1139
def fileid_involved_between_revs(self, from_revid, to_revid):
1140
""" This function returns the file_id(s) involved in the
1141
changes between the from_revid revision and the to_revid
1144
w = self._get_inventory_weave( )
1145
from_set = set(w.inclusions([w.lookup(from_revid)]))
1146
to_set = set(w.inclusions([w.lookup(to_revid)]))
1147
included = to_set.difference(from_set)
1148
changed = map(w.idx_to_name,included)
1149
return self._fileid_involved_by_set(changed)
1151
def fileid_involved(self, last_revid=None):
1152
""" This function returns the file_id(s) involved in the
1153
changes up to the revision last_revid
1154
If no parametr is passed, then all file_id[s] present in the
1155
repository are returned
1157
w = self._get_inventory_weave( )
1159
changed = set(w._names)
1161
included = w.inclusions([w.lookup(last_revid)])
1162
changed = map(w.idx_to_name, included)
1163
return self._fileid_involved_by_set(changed)
1165
def fileid_involved_by_set(self, changes):
1166
""" This function returns the file_id(s) involved in the
1167
changese present in the set changes
1169
w = self._get_inventory_weave( )
1170
return self._fileid_involved_by_set(changes)
1172
def _fileid_involved_by_set(self, changes):
1173
w = self._get_inventory_weave( )
1175
for line in w._weave:
1177
# it is ugly, but it is due to the weave structure
1178
if not isinstance(line,basestring): continue
1180
start = line.find('file_id="')+9
1181
if start < 9: continue
1182
end = line.find('"',start)
1184
file_id = line[start:end]
1186
# check if file_id is already present
1187
if file_id in file_ids: continue
1189
start = line.find('revision="')+10
1190
if start < 10: continue
1191
end = line.find('"',start)
1193
revision_id = line[start:end]
1195
if revision_id in changes:
1196
file_ids.add(file_id)
1119
1201
class ScratchBranch(BzrBranch):
1120
1202
"""Special test class: a branch that cleans up after itself.