comparison mercurial/revlog.py @ 23856:062c3ad86651

revlog: add flags argument to _addrevision, update callers use default flags For revlog index flags to be useful to other parts of Mercurial, they need to be settable when writing revisions. The current use case for revlog index flags is the censorship feature: http://mercurial.selenic.com/wiki/CensorPlan While the censor flag could be inferred in _addrevision by interrogating the text/delta being added, that would bury the censorship logic and inappropriately couple it to all revision creation.
author Mike Edgar <adgar@google.com>
date Mon, 12 Jan 2015 14:30:24 -0500
parents 4f23081c901e
children 8a3c132f93d2
comparison
equal deleted inserted replaced
23855:4f23081c901e 23856:062c3ad86651
1177 if not self._inline: 1177 if not self._inline:
1178 dfh = self.opener(self.datafile, "a") 1178 dfh = self.opener(self.datafile, "a")
1179 ifh = self.opener(self.indexfile, "a+") 1179 ifh = self.opener(self.indexfile, "a+")
1180 try: 1180 try:
1181 return self._addrevision(node, text, transaction, link, p1, p2, 1181 return self._addrevision(node, text, transaction, link, p1, p2,
1182 cachedelta, ifh, dfh) 1182 REVIDX_DEFAULT_FLAGS, cachedelta, ifh, dfh)
1183 finally: 1183 finally:
1184 if dfh: 1184 if dfh:
1185 dfh.close() 1185 dfh.close()
1186 ifh.close() 1186 ifh.close()
1187 1187
1212 if text[0] == '\0': 1212 if text[0] == '\0':
1213 return ("", text) 1213 return ("", text)
1214 return ('u', text) 1214 return ('u', text)
1215 return ("", bin) 1215 return ("", bin)
1216 1216
1217 def _addrevision(self, node, text, transaction, link, p1, p2, 1217 def _addrevision(self, node, text, transaction, link, p1, p2, flags,
1218 cachedelta, ifh, dfh): 1218 cachedelta, ifh, dfh):
1219 """internal function to add revisions to the log 1219 """internal function to add revisions to the log
1220 1220
1221 see addrevision for argument descriptions. 1221 see addrevision for argument descriptions.
1222 invariants: 1222 invariants:
1266 curr = len(self) 1266 curr = len(self)
1267 prev = curr - 1 1267 prev = curr - 1
1268 base = chainbase = curr 1268 base = chainbase = curr
1269 chainlen = None 1269 chainlen = None
1270 offset = self.end(prev) 1270 offset = self.end(prev)
1271 flags = 0
1272 d = None 1271 d = None
1273 if self._basecache is None: 1272 if self._basecache is None:
1274 self._basecache = (prev, self.chainbase(prev)) 1273 self._basecache = (prev, self.chainbase(prev))
1275 basecache = self._basecache 1274 basecache = self._basecache
1276 p1r, p2r = self.rev(p1), self.rev(p2) 1275 p1r, p2r = self.rev(p1), self.rev(p2)
1397 raise LookupError(deltabase, self.indexfile, 1396 raise LookupError(deltabase, self.indexfile,
1398 _('unknown delta base')) 1397 _('unknown delta base'))
1399 1398
1400 baserev = self.rev(deltabase) 1399 baserev = self.rev(deltabase)
1401 chain = self._addrevision(node, None, transaction, link, 1400 chain = self._addrevision(node, None, transaction, link,
1402 p1, p2, (baserev, delta), ifh, dfh) 1401 p1, p2, REVIDX_DEFAULT_FLAGS,
1402 (baserev, delta), ifh, dfh)
1403 if not dfh and not self._inline: 1403 if not dfh and not self._inline:
1404 # addrevision switched from inline to conventional 1404 # addrevision switched from inline to conventional
1405 # reopen the index 1405 # reopen the index
1406 ifh.close() 1406 ifh.close()
1407 dfh = self.opener(self.datafile, "a") 1407 dfh = self.opener(self.datafile, "a")