##// END OF EJS Templates
dirstate: avoid a race with multiple commits in the same process...
dirstate: avoid a race with multiple commits in the same process (issue2264, issue2516) The race happens when two commits in a row change the same file without changing its size, *if* those two commits happen in the same second in the same process while holding the same repo lock. For example: commit 1: M a M b commit 2: # same process, same second, same repo lock M b # modify b without changing its size M c This first manifested in transplant, which is the most common way to do multiple commits in the same process. But it can manifest in any script or extension that does multiple commits under the same repo lock. (Thus, the test script tests both transplant and a custom script.) The problem was that dirstate.status() failed to notice the change to b when localrepo is about to do the second commit, meaning that change gets left in the working directory. In the context of transplant, that means either a crash ("RuntimeError: nothing committed after transplant") or a silently inaccurate transplant, depending on whether any other files were modified by the second transplanted changeset. The fix is to make status() work a little harder when we have previously marked files as clean (state 'normal') in the same process. Specifically, dirstate.normal() adds files to self._lastnormal, and other state-changing methods remove them. Then dirstate.status() puts any files in self._lastnormal into state 'lookup', which will make localrepository.status() read file contents to see if it has really changed. So we pay a small performance penalty for the second (and subsequent) commits in the same process, without affecting the common case. Anything that does lots of status updates and checks in the same process could suffer a performance hit. Incidentally, there is a simpler fix: call dirstate.normallookup() on every file updated by commit() at the end of the commit. The trouble with that solution is that it imposes a performance penalty on the common case: it means the next status-dependent hg command after every "hg commit" will be a little bit slower. The patch here is more complex, but only affects performance for the uncommon case.

File last commit:

r12666:ead4e21f default
r13704:a464763e default
Show More
help.tmpl
31 lines | 983 B | application/x-cheetah | CheetahLexer
{header}
<title>{repo|escape}: Branches</title>
<link rel="alternate" type="application/atom+xml"
href="{url}atom-tags" title="Atom feed for {repo|escape}"/>
<link rel="alternate" type="application/rss+xml"
href="{url}rss-tags" title="RSS feed for {repo|escape}"/>
</head>
<body>
<div class="page_header">
<a href="http://mercurial.selenic.com/" title="Mercurial" style="float: right;">Mercurial</a><a href="{url}summary{sessionvars%urlparameter}">{repo|escape}</a> / branches
</div>
<div class="page_nav">
<a href="{url}summary{sessionvars%urlparameter}">summary</a> |
<a href="{url}shortlog{sessionvars%urlparameter}">shortlog</a> |
<a href="{url}log{sessionvars%urlparameter}">changelog</a> |
<a href="{url}graph{sessionvars%urlparameter}">graph</a> |
<a href="{url}tags{sessionvars%urlparameter}">tags</a> |
branches |
<a href="{url}file/{node|short}{sessionvars%urlparameter}">files</a>
<br/>
</div>
<div class="title">&nbsp;</div>
<pre>
{doc|escape}
</pre>
{footer}