##// END OF EJS Templates
revlog: addgroup checks if incoming deltas add censored revs, sets flag bit...
Mike Edgar -
r24255:4bfe9f2d default
parent child Browse files
Show More
@@ -5,8 +5,8 b''
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 import error, revlog
9 import re
8 import error, mdiff, revlog
9 import re, struct
10 10
11 11 _mdre = re.compile('\1\n')
12 12 def parsemeta(text):
@@ -107,3 +107,23 b' class filelog(revlog.revlog):'
107 107 def iscensored(self, rev):
108 108 """Check if a file revision is censored."""
109 109 return self.flags(rev) & revlog.REVIDX_ISCENSORED
110
111 def _peek_iscensored(self, baserev, delta, flush):
112 """Quickly check if a delta produces a censored revision."""
113 # Fragile heuristic: unless new file meta keys are added alphabetically
114 # preceding "censored", all censored revisions are prefixed by
115 # "\1\ncensored:". A delta producing such a censored revision must be a
116 # full-replacement delta, so we inspect the first and only patch in the
117 # delta for this prefix.
118 hlen = struct.calcsize(">lll")
119 if len(delta) <= hlen:
120 return False
121
122 oldlen = self.rawsize(baserev)
123 newlen = len(delta) - hlen
124 if delta[:hlen] != mdiff.replacediffheader(oldlen, newlen):
125 return False
126
127 add = "\1\ncensored:"
128 addlen = len(add)
129 return newlen >= addlen and delta[hlen:hlen + addlen] == add
@@ -1386,7 +1386,10 b' class revlog(object):'
1386 1386 transaction.add(self.indexfile, isize, r)
1387 1387 transaction.add(self.datafile, end)
1388 1388 dfh = self.opener(self.datafile, "a")
1389
1389 def flush():
1390 if dfh:
1391 dfh.flush()
1392 ifh.flush()
1390 1393 try:
1391 1394 # loop through our set of deltas
1392 1395 chain = None
@@ -1430,9 +1433,13 b' class revlog(object):'
1430 1433 raise error.CensoredBaseError(self.indexfile,
1431 1434 self.node(baserev))
1432 1435
1436 flags = REVIDX_DEFAULT_FLAGS
1437 if self._peek_iscensored(baserev, delta, flush):
1438 flags |= REVIDX_ISCENSORED
1439
1433 1440 chain = self._addrevision(node, None, transaction, link,
1434 p1, p2, REVIDX_DEFAULT_FLAGS,
1435 (baserev, delta), ifh, dfh)
1441 p1, p2, flags, (baserev, delta),
1442 ifh, dfh)
1436 1443 if not dfh and not self._inline:
1437 1444 # addrevision switched from inline to conventional
1438 1445 # reopen the index
@@ -1450,6 +1457,10 b' class revlog(object):'
1450 1457 """Check if a file revision is censored."""
1451 1458 return False
1452 1459
1460 def _peek_iscensored(self, baserev, delta, flush):
1461 """Quickly check if a delta produces a censored revision."""
1462 return False
1463
1453 1464 def getstrippoint(self, minlink):
1454 1465 """find the minimum rev that must be stripped to strip the linkrev
1455 1466
General Comments 0
You need to be logged in to leave comments. Login now