Mercurial > hg
comparison mercurial/localrepo.py @ 26748:5ba0a99ff27f
dirstate: make dirstate.write() callers pass transaction object to it
Now, 'dirstate.write(tr)' delays writing in-memory changes out, if a
transaction is running.
This may cause treating this revision as "the first bad one" at
bisecting in some cases using external hook process inside transaction
scope, because some external hooks and editor process are still
invoked without HG_PENDING and pending changes aren't visible to them.
'dirstate.write()' callers below in localrepo.py explicitly use 'None'
as 'tr', because they can assume that no transaction is running:
- just before starting transaction
- at closing transaction, or
- at unlocking wlock
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Sat, 17 Oct 2015 01:15:34 +0900 |
parents | e1568d5eb052 |
children | 520defbc0335 |
comparison
equal
deleted
inserted
replaced
26747:beff0b2481b3 | 26748:5ba0a99ff27f |
---|---|
975 raise error.RepoError( | 975 raise error.RepoError( |
976 _("abandoned transaction found"), | 976 _("abandoned transaction found"), |
977 hint=_("run 'hg recover' to clean up transaction")) | 977 hint=_("run 'hg recover' to clean up transaction")) |
978 | 978 |
979 # make journal.dirstate contain in-memory changes at this point | 979 # make journal.dirstate contain in-memory changes at this point |
980 self.dirstate.write() | 980 self.dirstate.write(None) |
981 | 981 |
982 idbase = "%.40f#%f" % (random.random(), time.time()) | 982 idbase = "%.40f#%f" % (random.random(), time.time()) |
983 txnid = 'TXN:' + util.sha1(idbase).hexdigest() | 983 txnid = 'TXN:' + util.sha1(idbase).hexdigest() |
984 self.hook('pretxnopen', throw=True, txnname=desc, txnid=txnid) | 984 self.hook('pretxnopen', throw=True, txnname=desc, txnid=txnid) |
985 | 985 |
1003 # this should be explicitly invoked here, because | 1003 # this should be explicitly invoked here, because |
1004 # in-memory changes aren't written out at closing | 1004 # in-memory changes aren't written out at closing |
1005 # transaction, if tr.addfilegenerator (via | 1005 # transaction, if tr.addfilegenerator (via |
1006 # dirstate.write or so) isn't invoked while | 1006 # dirstate.write or so) isn't invoked while |
1007 # transaction running | 1007 # transaction running |
1008 repo.dirstate.write() | 1008 repo.dirstate.write(None) |
1009 else: | 1009 else: |
1010 # prevent in-memory changes from being written out at | 1010 # prevent in-memory changes from being written out at |
1011 # the end of outer wlock scope or so | 1011 # the end of outer wlock scope or so |
1012 repo.dirstate.invalidate() | 1012 repo.dirstate.invalidate() |
1013 | 1013 |
1317 | 1317 |
1318 def unlock(): | 1318 def unlock(): |
1319 if self.dirstate.pendingparentchange(): | 1319 if self.dirstate.pendingparentchange(): |
1320 self.dirstate.invalidate() | 1320 self.dirstate.invalidate() |
1321 else: | 1321 else: |
1322 self.dirstate.write() | 1322 self.dirstate.write(None) |
1323 | 1323 |
1324 self._filecache['dirstate'].refresh() | 1324 self._filecache['dirstate'].refresh() |
1325 | 1325 |
1326 l = self._lock(self.vfs, "wlock", wait, unlock, | 1326 l = self._lock(self.vfs, "wlock", wait, unlock, |
1327 self.invalidatedirstate, _('working directory of %s') % | 1327 self.invalidatedirstate, _('working directory of %s') % |