2094 """find the minimum rev that must be stripped to strip the linkrev |
2094 """find the minimum rev that must be stripped to strip the linkrev |
2095 |
2095 |
2096 Returns a tuple containing the minimum rev and a set of all revs that |
2096 Returns a tuple containing the minimum rev and a set of all revs that |
2097 have linkrevs that will be broken by this strip. |
2097 have linkrevs that will be broken by this strip. |
2098 """ |
2098 """ |
2099 brokenrevs = set() |
2099 return storageutil.resolvestripinfo(minlink, len(self) - 1, |
2100 strippoint = len(self) |
2100 self.headrevs(), |
2101 |
2101 self.linkrev, self.parentrevs) |
2102 heads = {} |
|
2103 futurelargelinkrevs = set() |
|
2104 for head in self.headrevs(): |
|
2105 headlinkrev = self.linkrev(head) |
|
2106 heads[head] = headlinkrev |
|
2107 if headlinkrev >= minlink: |
|
2108 futurelargelinkrevs.add(headlinkrev) |
|
2109 |
|
2110 # This algorithm involves walking down the rev graph, starting at the |
|
2111 # heads. Since the revs are topologically sorted according to linkrev, |
|
2112 # once all head linkrevs are below the minlink, we know there are |
|
2113 # no more revs that could have a linkrev greater than minlink. |
|
2114 # So we can stop walking. |
|
2115 while futurelargelinkrevs: |
|
2116 strippoint -= 1 |
|
2117 linkrev = heads.pop(strippoint) |
|
2118 |
|
2119 if linkrev < minlink: |
|
2120 brokenrevs.add(strippoint) |
|
2121 else: |
|
2122 futurelargelinkrevs.remove(linkrev) |
|
2123 |
|
2124 for p in self.parentrevs(strippoint): |
|
2125 if p != nullrev: |
|
2126 plinkrev = self.linkrev(p) |
|
2127 heads[p] = plinkrev |
|
2128 if plinkrev >= minlink: |
|
2129 futurelargelinkrevs.add(plinkrev) |
|
2130 |
|
2131 return strippoint, brokenrevs |
|
2132 |
2102 |
2133 def strip(self, minlink, transaction): |
2103 def strip(self, minlink, transaction): |
2134 """truncate the revlog on the first revision with a linkrev >= minlink |
2104 """truncate the revlog on the first revision with a linkrev >= minlink |
2135 |
2105 |
2136 This function is called when we're stripping revision minlink and |
2106 This function is called when we're stripping revision minlink and |