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