##// END OF EJS Templates
changelog: handle writepending in the transaction...
Pierre-Yves David -
r23203:3872d563 default
parent child Browse files
Show More
@@ -661,12 +661,6 b' def addchangegroup(repo, source, srctype'
661 661 changesets = files = revisions = 0
662 662 efiles = set()
663 663
664 # write changelog data to temp files so concurrent readers will not see
665 # inconsistent view
666 cl = repo.changelog
667 cl.delayupdate()
668 oldheads = cl.heads()
669
670 664 tr = repo.transaction("\n".join([srctype, util.hidepassword(url)]))
671 665 # The transaction could have been created before and already carries source
672 666 # information. In this case we use the top level data. We overwrite the
@@ -674,6 +668,12 b' def addchangegroup(repo, source, srctype'
674 668 # this function.
675 669 srctype = tr.hookargs.setdefault('source', srctype)
676 670 url = tr.hookargs.setdefault('url', url)
671
672 # write changelog data to temp files so concurrent readers will not see
673 # inconsistent view
674 cl = repo.changelog
675 cl.delayupdate(tr)
676 oldheads = cl.heads()
677 677 try:
678 678 repo.hook('prechangegroup', throw=True, **tr.hookargs)
679 679
@@ -756,7 +756,7 b' def addchangegroup(repo, source, srctype'
756 756 repo.invalidatevolatilesets()
757 757
758 758 if changesets > 0:
759 p = lambda: cl.writepending() and repo.root or ""
759 p = lambda: tr.writepending() and repo.root or ""
760 760 if 'node' not in tr.hookargs:
761 761 tr.hookargs['node'] = hex(cl.node(clstart))
762 762 hookargs = dict(tr.hookargs)
@@ -224,7 +224,7 b' class changelog(revlog.revlog):'
224 224 raise error.FilteredIndexError(rev)
225 225 return super(changelog, self).flags(rev)
226 226
227 def delayupdate(self):
227 def delayupdate(self, tr):
228 228 "delay visibility of index updates to other readers"
229 229
230 230 if not self._delayed:
@@ -238,6 +238,7 b' class changelog(revlog.revlog):'
238 238 self.opener = _delayopener(self._realopener, self.indexfile,
239 239 self._delaybuf)
240 240 self._delayed = True
241 tr.addpending('cl-%i' % id(self), self._writepending)
241 242
242 243 def finalize(self, tr):
243 244 "finalize index updates"
@@ -266,7 +267,7 b' class changelog(revlog.revlog):'
266 267 self._nodecache = r._nodecache
267 268 self._chunkcache = r._chunkcache
268 269
269 def writepending(self):
270 def _writepending(self):
270 271 "create a file containing the unfinalized state for pretxnchangegroup"
271 272 if self._delaybuf:
272 273 # make a temporary copy of the index
@@ -854,9 +854,7 b' class pulloperation(object):'
854 854 """close transaction if created"""
855 855 if self._tr is not None:
856 856 repo = self.repo
857 cl = repo.unfiltered().changelog
858 p = cl.writepending() and repo.root or ""
859 p = cl.writepending() and repo.root or ""
857 p = lambda: self._tr.writepending() and repo.root or ""
860 858 repo.hook('b2x-pretransactionclose', throw=True, pending=p,
861 859 **self._tr.hookargs)
862 860 self._tr.close()
@@ -1279,8 +1277,7 b' def unbundle(repo, cg, heads, source, ur'
1279 1277 tr.hookargs['url'] = url
1280 1278 tr.hookargs['bundle2-exp'] = '1'
1281 1279 r = bundle2.processbundle(repo, cg, lambda: tr).reply
1282 cl = repo.unfiltered().changelog
1283 p = cl.writepending() and repo.root or ""
1280 p = lambda: tr.writepending() and repo.root or ""
1284 1281 repo.hook('b2x-pretransactionclose', throw=True, pending=p,
1285 1282 **tr.hookargs)
1286 1283 tr.close()
@@ -1437,11 +1437,11 b' class localrepository(object):'
1437 1437 files = []
1438 1438
1439 1439 # update changelog
1440 self.changelog.delayupdate()
1440 self.changelog.delayupdate(tr)
1441 1441 n = self.changelog.add(mn, files, ctx.description(),
1442 1442 trp, p1.node(), p2.node(),
1443 1443 user, ctx.date(), ctx.extra().copy())
1444 p = lambda: self.changelog.writepending() and self.root or ""
1444 p = lambda: tr.writepending() and self.root or ""
1445 1445 xp1, xp2 = p1.hex(), p2 and p2.hex() or ''
1446 1446 self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1,
1447 1447 parent2=xp2, pending=p)
General Comments 0
You need to be logged in to leave comments. Login now