Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/localrepo.py @ 26634:09bb1ee7e73e
dirstate: make writing in-memory changes aware of transaction activity
This patch delays writing in-memory changes out, if transaction is
running.
'_getfsnow()' is defined as a function, to hook it easily for
ambiguous timestamp tests (see also fakedirstatewritetime.py)
'if tr:' code path in this patch is still disabled at this revision,
because there is no client invoking 'dirstate.write()' with repo
object.
BTW, this patch changes 'dirstate.invalidate()' semantics around
'dirstate.write()' in a transaction scope:
before:
with repo.transaction():
dirstate.CHANGE('A')
dirstate.write() # change for A is written out here
dirstate.CHANGE('B')
dirstate.invalidate() # discards only change for B
after:
with repo.transaction():
dirstate.CHANGE('A')
dirstate.write() # change for A is still kept in memory
dirstate.CHANGE('B')
dirstate.invalidate() # discards changes for A and B
Fortunately, there is no code path expecting the former, at least, in
Mercurial itself, because 'dirstateguard' was introduced to remove
such 'dirstate.invalidate()'.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Wed, 14 Oct 2015 02:49:17 +0900 |
parents | e077ce385609 |
children | ec182d109dce |
comparison
equal
deleted
inserted
replaced
26633:020b12d591f3 | 26634:09bb1ee7e73e |
---|---|
998 reporef().hook('pretxnclose', throw=True, pending=pending, | 998 reporef().hook('pretxnclose', throw=True, pending=pending, |
999 txnname=desc, **tr.hookargs) | 999 txnname=desc, **tr.hookargs) |
1000 def releasefn(tr, success): | 1000 def releasefn(tr, success): |
1001 repo = reporef() | 1001 repo = reporef() |
1002 if success: | 1002 if success: |
1003 # this should be explicitly invoked here, because | |
1004 # in-memory changes aren't written out at closing | |
1005 # transaction, if tr.addfilegenerator (via | |
1006 # dirstate.write or so) isn't invoked while | |
1007 # transaction running | |
1003 repo.dirstate.write() | 1008 repo.dirstate.write() |
1004 else: | 1009 else: |
1005 # prevent in-memory changes from being written out at | 1010 # prevent in-memory changes from being written out at |
1006 # the end of outer wlock scope or so | 1011 # the end of outer wlock scope or so |
1007 repo.dirstate.invalidate() | 1012 repo.dirstate.invalidate() |