comparison mercurial/localrepo.py @ 17126:8fa8717b47b6

obsolete: write obsolete marker inside a transaction Marker are now written as soon as possible but within a transaction. Using a transaction ensure a proper behavior on error and rollback compatibility. Flush logic are not necessary anymore and are dropped from lock release. With this changeset, the obsstore is open, written and closed for every single added marker. This is expected to be highly inefficient and batched write should be implemented "quickly". Another issue is that every flush of the file will invalidate the obsstore filecache and trigger a full re instantiation of the repo.obsstore attribute (including, reading and parsing entry). This is also expected to be highly inefficient and proper filecache operation should be implemented "quickly" too. A side benefit of the filecache issue is that repo.obsstore object is properly invalidated on transaction abortion.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Wed, 04 Jul 2012 02:21:04 +0200
parents 95d785ccb4e5
children ad1b5e070f16
comparison
equal deleted inserted replaced
17125:95d785ccb4e5 17126:8fa8717b47b6
985 985
986 def unlock(): 986 def unlock():
987 self.store.write() 987 self.store.write()
988 if '_phasecache' in vars(self): 988 if '_phasecache' in vars(self):
989 self._phasecache.write() 989 self._phasecache.write()
990 if 'obsstore' in vars(self):
991 self.obsstore.flushmarkers()
992 for k, ce in self._filecache.items(): 990 for k, ce in self._filecache.items():
993 if k == 'dirstate': 991 if k == 'dirstate':
994 continue 992 continue
995 ce.refresh() 993 ce.refresh()
996 994
1605 r.append(l) 1603 r.append(l)
1606 1604
1607 return r 1605 return r
1608 1606
1609 def pull(self, remote, heads=None, force=False): 1607 def pull(self, remote, heads=None, force=False):
1608 # don't open transaction for nothing or you break future useful
1609 # rollback call
1610 tr = None
1611 trname = 'pull\n' + util.hidepassword(remote.url())
1610 lock = self.lock() 1612 lock = self.lock()
1611 try: 1613 try:
1612 tmp = discovery.findcommonincoming(self, remote, heads=heads, 1614 tmp = discovery.findcommonincoming(self, remote, heads=heads,
1613 force=force) 1615 force=force)
1614 common, fetch, rheads = tmp 1616 common, fetch, rheads = tmp
1615 if not fetch: 1617 if not fetch:
1616 self.ui.status(_("no changes found\n")) 1618 self.ui.status(_("no changes found\n"))
1617 added = [] 1619 added = []
1618 result = 0 1620 result = 0
1619 else: 1621 else:
1622 tr = self.transaction(trname)
1620 if heads is None and list(common) == [nullid]: 1623 if heads is None and list(common) == [nullid]:
1621 self.ui.status(_("requesting all changes\n")) 1624 self.ui.status(_("requesting all changes\n"))
1622 elif heads is None and remote.capable('changegroupsubset'): 1625 elif heads is None and remote.capable('changegroupsubset'):
1623 # issue1320, avoid a race if remote changed after discovery 1626 # issue1320, avoid a race if remote changed after discovery
1624 heads = rheads 1627 heads = rheads
1663 # should be seen as public 1666 # should be seen as public
1664 phases.advanceboundary(self, phases.public, subset) 1667 phases.advanceboundary(self, phases.public, subset)
1665 1668
1666 remoteobs = remote.listkeys('obsolete') 1669 remoteobs = remote.listkeys('obsolete')
1667 if 'dump' in remoteobs: 1670 if 'dump' in remoteobs:
1671 if tr is None:
1672 tr = self.transaction(trname)
1668 data = base85.b85decode(remoteobs['dump']) 1673 data = base85.b85decode(remoteobs['dump'])
1669 self.obsstore.mergemarkers(data) 1674 self.obsstore.mergemarkers(tr, data)
1675 if tr is not None:
1676 tr.close()
1670 finally: 1677 finally:
1678 if tr is not None:
1679 tr.release()
1671 lock.release() 1680 lock.release()
1672 1681
1673 return result 1682 return result
1674 1683
1675 def checkpush(self, force, revs): 1684 def checkpush(self, force, revs):