##// END OF EJS Templates
strip: add faster revlog strip computation...
Durham Goode -
r20074:5fc2ae1c default
parent child Browse files
Show More
@@ -38,16 +38,8 b' def _collectbrokencsets(repo, files, str'
38 38 """return the changesets which will be broken by the truncation"""
39 39 s = set()
40 40 def collectone(revlog):
41 linkgen = (revlog.linkrev(i) for i in revlog)
42 # find the truncation point of the revlog
43 for lrev in linkgen:
44 if lrev >= striprev:
45 break
46 # see if any revision after this point has a linkrev
47 # less than striprev (those will be broken by strip)
48 for lrev in linkgen:
49 if lrev < striprev:
50 s.add(lrev)
41 _, brokenset = revlog.getstrippoint(striprev)
42 s.update([revlog.linkrev(r) for r in brokenset])
51 43
52 44 collectone(repo.manifest)
53 45 for fname in files:
@@ -1285,6 +1285,46 b' class revlog(object):'
1285 1285
1286 1286 return content
1287 1287
1288 def getstrippoint(self, minlink):
1289 """find the minimum rev that must be stripped to strip the linkrev
1290
1291 Returns a tuple containing the minimum rev and a set of all revs that
1292 have linkrevs that will be broken by this strip.
1293 """
1294 brokenrevs = set()
1295 strippoint = len(self)
1296
1297 heads = {}
1298 futurelargelinkrevs = set()
1299 for head in self.headrevs():
1300 headlinkrev = self.linkrev(head)
1301 heads[head] = headlinkrev
1302 if headlinkrev >= minlink:
1303 futurelargelinkrevs.add(headlinkrev)
1304
1305 # This algorithm involves walking down the rev graph, starting at the
1306 # heads. Since the revs are topologically sorted according to linkrev,
1307 # once all head linkrevs are below the minlink, we know there are
1308 # no more revs that could have a linkrev greater than minlink.
1309 # So we can stop walking.
1310 while futurelargelinkrevs:
1311 strippoint -= 1
1312 linkrev = heads.pop(strippoint)
1313
1314 if linkrev < minlink:
1315 brokenrevs.add(strippoint)
1316 else:
1317 futurelargelinkrevs.remove(linkrev)
1318
1319 for p in self.parentrevs(strippoint):
1320 if p != nullrev:
1321 plinkrev = self.linkrev(p)
1322 heads[p] = plinkrev
1323 if plinkrev >= minlink:
1324 futurelargelinkrevs.add(plinkrev)
1325
1326 return strippoint, brokenrevs
1327
1288 1328 def strip(self, minlink, transaction):
1289 1329 """truncate the revlog on the first revision with a linkrev >= minlink
1290 1330
@@ -1302,10 +1342,8 b' class revlog(object):'
1302 1342 if len(self) == 0:
1303 1343 return
1304 1344
1305 for rev in self:
1306 if self.index[rev][4] >= minlink:
1307 break
1308 else:
1345 rev, _ = self.getstrippoint(minlink)
1346 if rev == len(self):
1309 1347 return
1310 1348
1311 1349 # first truncate the files on disk
General Comments 0
You need to be logged in to leave comments. Login now