##// END OF EJS Templates
context: write dirstate out explicitly after marking files as clean...
context: write dirstate out explicitly after marking files as clean To detect change of a file without redundant comparison of file content, dirstate recognizes a file as certainly clean, if: (1) it is already known as "normal", (2) dirstate entry for it has valid (= not "-1") timestamp, and (3) mode, size and timestamp of it on the filesystem are as same as ones expected in dirstate This works as expected in many cases, but doesn't in the corner case that changing a file keeps mode, size and timestamp of it on the filesystem. The timetable below shows steps in one of typical such situations: ---- ----------------------------------- ---------------- timestamp of "f" ---------------- dirstate file- time action mem file system ---- ----------------------------------- ---- ----- ----- N -1 *** - make file "f" clean N - execute 'hg foobar' - instantiate 'dirstate' -1 -1 - 'dirstate.normal("f")' N -1 (e.g. via dirty check) - change "f", but keep size N N+1 - release wlock - 'dirstate.write()' N N - 'hg status' shows "f" as "clean" N N N ---- ----------------------------------- ---- ----- ----- The most important point is that 'dirstate.write()' is executed at N+1 or later. This causes writing dirstate timestamp N of "f" out successfully. If it is executed at N, 'parsers.pack_dirstate()' replaces timestamp N with "-1" before actual writing dirstate out. Occasional test failure for unexpected file status is typical example of this corner case. Batch execution with small working directory is finished in no time, and rarely satisfies condition (2) above. This issue can occur in cases below; - 'hg revert --rev REV' for revisions other than the parent - failure of 'merge.update()' before 'merge.recordupdates()' The root cause of this issue is that files are changed without flushing in-memory dirstate changes via 'repo.commit()' (even though omitting 'dirstate.normallookup()' on changed files also causes this issue). To detect changes of files correctly, this patch writes in-memory dirstate changes out explicitly after marking files as clean in 'workingctx._checklookup()', which is invoked via 'repo.status()'. After this change, timetable is changed as below: ---- ----------------------------------- ---------------- timestamp of "f" ---------------- dirstate file- time action mem file system ---- ----------------------------------- ---- ----- ----- N -1 *** - make file "f" clean N - execute 'hg foobar' - instantiate 'dirstate' -1 -1 - 'dirstate.normal("f")' N -1 (e.g. via dirty check) ----------------------------------- ---- ----- ----- - 'dirsttate.write()' -1 -1 ----------------------------------- ---- ----- ----- - change "f", but keep size N N+1 - release wlock - 'dirstate.write()' -1 -1 - 'hg status' -1 -1 N ---- ----------------------------------- ---- ----- ----- To reproduce this issue in tests certainly, this patch emulates some timing critical actions as below: - timestamp of "f" in '.hg/dirstate' is -1 at the beginning 'hg debugrebuildstate' before command invocation ensures it. - make file "f" clean at N - change "f" at N 'touch -t 200001010000' before and after command invocation changes mtime of "f" to "2000-01-01 00:00" (= N). - invoke 'dirstate.write()' via 'repo.status()' at N 'fakedirstatewritetime.py' forces 'pack_dirstate()' to use "2000-01-01 00:00" as "now", only if 'pack_dirstate()' is invoked via 'workingctx._checklookup()'. - invoke 'dirstate.write()' via releasing wlock at N+1 (or "not at N") 'pack_dirstate()' via releasing wlock uses actual timestamp at runtime as "now", and it should be different from the "2000-01-01 00:00" of "f". BTW, this patch also changes 'test-largefiles-misc.t', because adding 'dirstate.write()' makes recent dirstate changes visible to external process.

File last commit:

r25605:dd893046 default
r25753:fe03f522 default
Show More
map
329 lines | 13.8 KiB | text/plain | TextLexer
default = 'summary'
mimetype = 'text/html; charset={encoding}'
header = header.tmpl
footer = footer.tmpl
search = search.tmpl
changelog = changelog.tmpl
summary = summary.tmpl
error = error.tmpl
notfound = notfound.tmpl
help = help.tmpl
helptopics = helptopics.tmpl
helpentry = '
<tr><td>
<a href="{url|urlescape}help/{topic|escape}{sessionvars%urlparameter}">
{topic|escape}
</a>
</td><td>
{summary|escape}
</td></tr>'
naventry = '<a href="{url|urlescape}log/{node|short}{sessionvars%urlparameter}">{label|escape}</a> '
navshortentry = '<a href="{url|urlescape}shortlog/{node|short}{sessionvars%urlparameter}">{label|escape}</a> '
navgraphentry = '<a href="{url|urlescape}graph/{node|short}{sessionvars%urlparameter}">{label|escape}</a> '
filenaventry = '<a href="{url|urlescape}log/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{label|escape}</a> '
filedifflink = '<a href="{url|urlescape}diff/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{file|escape}</a> '
filenodelink = '
<tr class="parity{parity}">
<td><a class="list" href="{url|urlescape}diff/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{file|escape}</a></td>
<td></td>
<td class="link">
<a href="{url|urlescape}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">file</a> |
<a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}">annotate</a> |
<a href="{url|urlescape}diff/{node|short}/{file|urlescape}{sessionvars%urlparameter}">diff</a> |
<a href="{url|urlescape}comparison/{node|short}/{file|urlescape}{sessionvars%urlparameter}">comparison</a> |
<a href="{url|urlescape}log/{node|short}/{file|urlescape}{sessionvars%urlparameter}">revisions</a>
</td>
</tr>'
filenolink = '
<tr class="parity{parity}">
<td><a class="list" href="{url|urlescape}diff/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{file|escape}</a></td>
<td></td>
<td class="link">
file |
annotate |
<a href="{url|urlescape}diff/{node|short}/{file|urlescape}{sessionvars%urlparameter}">diff</a> |
<a href="{url|urlescape}comparison/{node|short}/{file|urlescape}{sessionvars%urlparameter}">comparison</a> |
<a href="{url|urlescape}log/{node|short}/{file|urlescape}{sessionvars%urlparameter}">revisions</a>
</td>
</tr>'
nav = '{before%naventry} {after%naventry}'
navshort = '{before%navshortentry}{after%navshortentry}'
navgraph = '{before%navgraphentry}{after%navgraphentry}'
filenav = '{before%filenaventry}{after%filenaventry}'
fileellipses = '...'
changelogentry = changelogentry.tmpl
searchentry = changelogentry.tmpl
changeset = changeset.tmpl
manifest = manifest.tmpl
direntry = '
<tr class="parity{parity}">
<td style="font-family:monospace">drwxr-xr-x</td>
<td style="font-family:monospace"></td>
<td style="font-family:monospace"></td>
<td>
<a href="{url|urlescape}file/{symrev}{path|urlescape}{sessionvars%urlparameter}">{basename|escape}</a>
<a href="{url|urlescape}file/{symrev}{path|urlescape}/{emptydirs|urlescape}{sessionvars%urlparameter}">{emptydirs|escape}</a>
</td>
<td class="link">
<a href="{url|urlescape}file/{symrev}{path|urlescape}{sessionvars%urlparameter}">files</a>
</td>
</tr>'
fileentry = '
<tr class="parity{parity}">
<td style="font-family:monospace">{permissions|permissions}</td>
<td style="font-family:monospace" align=right>{date|isodate}</td>
<td style="font-family:monospace" align=right>{size}</td>
<td class="list">
<a class="list" href="{url|urlescape}file/{symrev}/{file|urlescape}{sessionvars%urlparameter}">{basename|escape}</a>
</td>
<td class="link">
<a href="{url|urlescape}file/{symrev}/{file|urlescape}{sessionvars%urlparameter}">file</a> |
<a href="{url|urlescape}log/{symrev}/{file|urlescape}{sessionvars%urlparameter}">revisions</a> |
<a href="{url|urlescape}annotate/{symrev}/{file|urlescape}{sessionvars%urlparameter}">annotate</a>
</td>
</tr>'
filerevision = filerevision.tmpl
fileannotate = fileannotate.tmpl
filediff = filediff.tmpl
filecomparison = filecomparison.tmpl
filelog = filelog.tmpl
fileline = '
<div style="font-family:monospace" class="parity{parity}">
<pre><a class="linenr" href="#{lineid}" id="{lineid}">{linenumber}</a> {line|escape}</pre>
</div>'
annotateline = '
<tr style="font-family:monospace" class="parity{parity}">
<td class="linenr" style="text-align: right;">
<a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#l{targetline}"
title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a>
</td>
<td><pre><a class="linenr" href="#{lineid}" id="{lineid}">{linenumber}</a></pre></td>
<td><pre>{line|escape}</pre></td>
</tr>'
difflineplus = '<span class="difflineplus"><a class="linenr" href="#{lineid}" id="{lineid}">{linenumber}</a> {line|escape}</span>'
difflineminus = '<span class="difflineminus"><a class="linenr" href="#{lineid}" id="{lineid}">{linenumber}</a> {line|escape}</span>'
difflineat = '<span class="difflineat"><a class="linenr" href="#{lineid}" id="{lineid}">{linenumber}</a> {line|escape}</span>'
diffline = '<a class="linenr" href="#{lineid}" id="{lineid}">{linenumber}</a> {line|escape}'
comparisonblock ='
<tbody class="block">
{lines}
</tbody>'
comparisonline = '
<tr style="font-family:monospace">
<td class="{type}"><pre><a class="linenr" href="#{lineid}" id="{lineid}">{leftlinenumber}</a> {leftline|escape}</pre></td>
<td class="{type}"><pre><a class="linenr" href="#{lineid}" id="{lineid}">{rightlinenumber}</a> {rightline|escape}</pre></td>
</tr>'
changelogparent = '
<tr>
<th class="parent">parent {rev}:</th>
<td class="parent">
<a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a>
</td>
</tr>'
changesetlink = '<a class="list" href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a>'
changesetbranch = '<tr><td>branch</td><td>{name|escape}</td></tr>'
changesetparent = '
<tr>
<td>parent {rev}</td>
<td style="font-family:monospace">
{changesetlink}
</td>
</tr>'
changesetparentdiff = '
<tr>
<td>parent {rev}</td>
<td style="font-family:monospace">
{changesetlink} {ifeq(node, basenode, '(current diff)', '({difffrom})')}
</td>
</tr>'
difffrom = '<a href="{url|urlescape}rev/{node|short}:{originalnode|short}{sessionvars%urlparameter}">diff</a>'
filerevbranch = '<tr><td>branch</td><td>{name|escape}</td></tr>'
filerevparent = '
<tr>
<td>parent {rev}</td>
<td style="font-family:monospace">
<a class="list" href="{url|urlescape}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">
{rename%filerename}{node|short}
</a>
</td>
</tr>'
filerename = '{file|escape}@'
filelogrename = '| <a href="{url|urlescape}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">base</a>'
fileannotateparent = '
<tr>
<td>parent {rev}</td>
<td style="font-family:monospace">
<a class="list" href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}">
{rename%filerename}{node|short}
</a>
</td>
</tr>'
changelogchild = '
<tr>
<th class="child">child {rev}:</th>
<td class="child"><a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a></td>
</tr>'
changesetchild = '
<tr>
<td>child {rev}</td>
<td style="font-family:monospace">
<a class="list" href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a>
</td>
</tr>'
filerevchild = '
<tr>
<td>child {rev}</td>
<td style="font-family:monospace">
<a class="list" href="{url|urlescape}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{node|short}</a></td>
</tr>'
fileannotatechild = '
<tr>
<td>child {rev}</td>
<td style="font-family:monospace">
<a class="list" href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{node|short}</a></td>
</tr>'
tags = tags.tmpl
tagentry = '
<tr class="parity{parity}">
<td class="age"><i class="age">{date|rfc822date}</i></td>
<td><a class="list" href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}"><b>{tag|escape}</b></a></td>
<td class="link">
<a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">changeset</a> |
<a href="{url|urlescape}log/{node|short}{sessionvars%urlparameter}">changelog</a> |
<a href="{url|urlescape}file/{node|short}{sessionvars%urlparameter}">files</a>
</td>
</tr>'
bookmarks = bookmarks.tmpl
bookmarkentry = '
<tr class="parity{parity}">
<td class="age"><i class="age">{date|rfc822date}</i></td>
<td><a class="list" href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}"><b>{bookmark|escape}</b></a></td>
<td class="link">
<a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">changeset</a> |
<a href="{url|urlescape}log/{node|short}{sessionvars%urlparameter}">changelog</a> |
<a href="{url|urlescape}file/{node|short}{sessionvars%urlparameter}">files</a>
</td>
</tr>'
branches = branches.tmpl
branchentry = '
<tr class="parity{parity}">
<td class="age"><i class="age">{date|rfc822date}</i></td>
<td><a class="list" href="{url|urlescape}shortlog/{node|short}{sessionvars%urlparameter}"><b>{node|short}</b></a></td>
<td class="{status}">{branch|escape}</td>
<td class="link">
<a href="{url|urlescape}changeset/{node|short}{sessionvars%urlparameter}">changeset</a> |
<a href="{url|urlescape}log/{node|short}{sessionvars%urlparameter}">changelog</a> |
<a href="{url|urlescape}file/{node|short}{sessionvars%urlparameter}">files</a>
</td>
</tr>'
diffblock = '<pre>{lines}</pre>'
filediffparent = '
<tr>
<td>parent {rev}</td>
<td style="font-family:monospace">
<a class="list" href="{url|urlescape}diff/{node|short}/{file|urlescape}{sessionvars%urlparameter}">
{node|short}
</a>
</td>
</tr>'
filecompparent = '
<tr>
<td>parent {rev}</td>
<td style="font-family:monospace">
<a class="list" href="{url|urlescape}comparison/{node|short}/{file|urlescape}{sessionvars%urlparameter}">
{node|short}
</a>
</td>
</tr>'
filelogparent = '
<tr>
<td align="right">parent {rev}:&nbsp;</td>
<td><a href="{url|urlescape}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{node|short}</a></td>
</tr>'
filediffchild = '
<tr>
<td>child {rev}</td>
<td style="font-family:monospace">
<a class="list" href="{url|urlescape}diff/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{node|short}</a>
</td>
</tr>'
filecompchild = '
<tr>
<td>child {rev}</td>
<td style="font-family:monospace">
<a class="list" href="{url|urlescape}comparison/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{node|short}</a>
</td>
</tr>'
filelogchild = '
<tr>
<td align="right">child {rev}:&nbsp;</td>
<td><a href="{url|urlescape}file{node|short}/{file|urlescape}{sessionvars%urlparameter}">{node|short}</a></td>
</tr>'
shortlog = shortlog.tmpl
graph = graph.tmpl
tagtag = '<span class="tagtag" title="{name|escape}">{name|escape}</span> '
branchtag = '<span class="branchtag" title="{name|escape}">{name|escape}</span> '
inbranchtag = '<span class="inbranchtag" title="{name|escape}">{name|escape}</span> '
bookmarktag = '<span class="bookmarktag" title="{name|escape}">{name|escape}</span> '
shortlogentry = '
<tr class="parity{parity}">
<td class="age"><i class="age">{date|rfc822date}</i></td>
<td><i>{author|person}</i></td>
<td>
<a class="list" href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">
<b>{desc|strip|firstline|escape|nonempty}</b>
<span class="logtags">{inbranch%inbranchtag}{branches%branchtag}{tags%tagtag}{bookmarks%bookmarktag}</span>
</a>
</td>
<td class="link" nowrap>
<a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">changeset</a> |
<a href="{url|urlescape}file/{node|short}{sessionvars%urlparameter}">files</a>
</td>
</tr>'
filelogentry = '
<tr class="parity{parity}">
<td class="age"><i class="age">{date|rfc822date}</i></td>
<td>
<a class="list" href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">
<b>{desc|strip|firstline|escape|nonempty}</b>
<span class="logtags">{inbranch%inbranchtag}{branches%branchtag}{tags%tagtag}{bookmarks%bookmarktag}</span>
</a>
</td>
<td class="link">
<a href="{url|urlescape}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">file</a> |
<a href="{url|urlescape}diff/{node|short}/{file|urlescape}{sessionvars%urlparameter}">diff</a> |
<a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}">annotate</a>
{rename%filelogrename}
</td>
</tr>'
archiveentry = ' | <a href="{url|urlescape}archive/{symrev}{extension}{ifeq(path,'/','',path|urlescape)}">{type|escape}</a> '
indexentry = '
<tr class="parity{parity}">
<td>
<a class="list" href="{url|urlescape}{sessionvars%urlparameter}">
<b>{name|escape}</b>
</a>
</td>
<td>{description}</td>
<td>{contact|obfuscate}</td>
<td class="age">{lastchange|rfc822date}</td>
<td class="indexlinks">{archives%indexarchiveentry}</td>
<td>{if(isdirectory, '',
'<div class="rss_logo">
<a href="{url|urlescape}rss-log">RSS</a> <a href="{url|urlescape}atom-log">Atom</a>
</div>'
)}
</td>
</tr>\n'
indexarchiveentry = ' <a href="{url|urlescape}archive/{node|short}{extension}">{type|escape}</a> '
index = index.tmpl
urlparameter = '{separator}{name}={value|urlescape}'
hiddenformentry = '<input type="hidden" name="{name}" value="{value|escape}" />'
breadcrumb = '&gt; <a href="{url|urlescape}">{name|escape}</a> '