view tests/test-minirst.py.out @ 25757:4d1382fd96ff

context: write dirstate out explicitly at the end of markcommitted 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 ---- ----------------------------------- ---- ----- ----- * *** *** - 'hg transplant REV1 REV2 ...' - transplanting REV1 .... N - change "f", but keep size N (via 'patch.patch()') - 'dirstate.normal("f")' N *** (via 'repo.commit()') - transplanting REV2 - change "f", but keep size N (via 'patch.patch()') - aborted while patching N+1 - release wlock - 'dirstate.write()' N N N - 'hg status' shows "r1" 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. This issue can occur when 'hg transplant' satisfies conditions below: - multiple revisions to be transplanted change the same file - those revisions don't change mode and size of the file, and - the 2nd or later revision of them fails after changing the file 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 files changed by 'patch.patch()' for efficiency 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 'committablectx.markcommitted()', which is invoked via 'repo.commit()'. After this change, timetable is changed as below: ---- ----------------------------------- ---------------- timestamp of "f" ---------------- dirstate file- time action mem file system ---- ----------------------------------- ---- ----- ----- * *** *** - 'hg transplant REV1 REV2 ...' - transplanting REV1 .... N - change "f", but keep size N (via 'patch.patch()') - 'dirstate.normal("f")' N *** (via 'repo.commit()') ----------------------------------- ---- ----- ----- - 'dirsttate.write()' -1 -1 ----------------------------------- ---- ----- ----- - transplanting REV2 - change "f", but keep size N (via 'patch.patch()') - aborted while patching N+1 - release wlock - 'dirstate.write()' -1 -1 N - 'hg status' shows "r1" as "clean" -1 -1 N ---- ----------------------------------- ---- ----- ----- To reproduce this issue in tests certainly, this patch emulates some timing critical actions as below: - change "f" at N 'patch.patch()' with 'fakepatchtime.py' explicitly changes mtime of patched files to "2000-01-01 00:00" (= N). - 'dirstate.write()' via 'repo.commit()' at N 'fakedirstatewritetime.py' forces 'pack_dirstate()' to use "2000-01-01 00:00" as "now", only if 'pack_dirstate()' is invoked via 'committablectx.markcommitted()'. - '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 doesn't test cases below, even though 'patch.patch()' is used similarly in these cases: 1. failure of 'hg import' or 'hg qpush' 2. success of 'hg import', 'hg qpush' or 'hg transplant' Case (1) above doesn't cause this kind of issue, because: - if patching is aborted by conflicts, changed files are committed changed files are marked as CLEAN, even though they are partially patched. - otherwise, dirstate are fully restored by 'dirstateguard' For example in timetable above, timestamp of "f" in .hg/dirstate is restored to -1 (or less than N), and subsequent 'hg status' can detect changes correctly. Case (2) always causes 'repo.status()' invocation via 'repo.commit()' just after changing files inside same wlock scope. ---- ----------------------------------- ---------------- timestamp of "f" ---------------- dirstate file- time action mem file system ---- ----------------------------------- ---- ----- ----- N *** *** - make file "f" clean N - execute 'hg foobar' .... - 'dirstate.normal("f")' N *** (e.g. via dirty check or previous 'repo.commit()') - change "f", but keep size N - 'repo.status()' (*1) (via 'repo.commit()') ---- ----------------------------------- ---- ----- ----- At a glance, 'repo.status()' at (*1) seems to cause similar issue (= "changed files are treated as clean"), but actually doesn't. 'dirstate._lastnormaltime' should be N at (*1) above, because 'dirstate.normal()' via dirty check is finished at N. Therefore, "f" changed at N (= 'dirstate._lastnormaltime') is forcibly treated as "unsure" at (*1), and changes are detected as expected (see 'dirstate.status()' for detail). If 'hg import' is executed with '--no-commit', 'repo.status()' isn't invoked just after changing files inside same wlock scope. But preceding 'dirstate.normal()' is invoked inside another wlock scope via 'cmdutil.bailifchanged()', and in-memory changes should be flushed at the end of that scope. Therefore, timestamp N of clean "f" should be replaced by -1, if 'dirstate.write()' is invoked at N. It means that condition of this issue isn't satisfied.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Wed, 08 Jul 2015 17:01:09 +0900
parents af9d9b778550
children 58f8b29c37ff
line wrap: on
line source

== paragraphs ==
60 column format:
----------------------------------------------------------------------
This is some text in the first paragraph.

  A small indented paragraph. It is followed by some lines
  containing random whitespace.

The third and final paragraph.
----------------------------------------------------------------------

30 column format:
----------------------------------------------------------------------
This is some text in the first
paragraph.

  A small indented paragraph.
  It is followed by some lines
  containing random
  whitespace.

The third and final paragraph.
----------------------------------------------------------------------

html format:
----------------------------------------------------------------------
<p>
This is some text in the first paragraph.
</p>
<p>
A small indented paragraph.
It is followed by some lines
containing random whitespace.
</p>
<p>
The third and final paragraph.
</p>
----------------------------------------------------------------------

== definitions ==
60 column format:
----------------------------------------------------------------------
A Term
  Definition. The indented lines make up the definition.

Another Term
    Another definition. The final line in the definition
    determines the indentation, so this will be indented
    with four spaces.

  A Nested/Indented Term
    Definition.
----------------------------------------------------------------------

30 column format:
----------------------------------------------------------------------
A Term
  Definition. The indented
  lines make up the
  definition.

Another Term
    Another definition. The
    final line in the
    definition determines the
    indentation, so this will
    be indented with four
    spaces.

  A Nested/Indented Term
    Definition.
----------------------------------------------------------------------

html format:
----------------------------------------------------------------------
<dl>
 <dt>A Term
 <dd>Definition. The indented lines make up the definition.
 <dt>Another Term
 <dd>Another definition. The final line in the definition determines the indentation, so this will be indented with four spaces.
 <dt>A Nested/Indented Term
 <dd>Definition.
</dl>
----------------------------------------------------------------------

== literals ==
60 column format:
----------------------------------------------------------------------
The fully minimized form is the most convenient form:

  Hello
    literal
      world

In the partially minimized form a paragraph simply ends with
space-double-colon.

  ////////////////////////////////////////
  long un-wrapped line in a literal block
  \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

  This literal block is started with '::',
    the so-called expanded form. The paragraph
      with '::' disappears in the final output.
----------------------------------------------------------------------

30 column format:
----------------------------------------------------------------------
The fully minimized form is
the most convenient form:

  Hello
    literal
      world

In the partially minimized
form a paragraph simply ends
with space-double-colon.

  ////////////////////////////////////////
  long un-wrapped line in a literal block
  \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

  This literal block is started with '::',
    the so-called expanded form. The paragraph
      with '::' disappears in the final output.
----------------------------------------------------------------------

html format:
----------------------------------------------------------------------
<p>
The fully minimized form is the most
convenient form:
</p>
<pre>
Hello
  literal
    world
</pre>
<p>
In the partially minimized form a paragraph
simply ends with space-double-colon.
</p>
<pre>
////////////////////////////////////////
long un-wrapped line in a literal block
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
</pre>
<pre>
This literal block is started with '::',
  the so-called expanded form. The paragraph
    with '::' disappears in the final output.
</pre>
----------------------------------------------------------------------

== lists ==
60 column format:
----------------------------------------------------------------------
- This is the first list item.

  Second paragraph in the first list item.

- List items need not be separated by a blank line.
- And will be rendered without one in any case.

We can have indented lists:

  - This is an indented list item
  - Another indented list item:

      - A literal block in the middle
            of an indented list.

      (The above is not a list item since we are in the literal block.)

  Literal block with no indentation (apart from
  the two spaces added to all literal blocks).

1. This is an enumerated list (first item).
2. Continuing with the second item.
(1) foo
(2) bar
1) Another
2) List

Line blocks are also a form of list:

This is the first line. The line continues here.
This is the second line.
----------------------------------------------------------------------

30 column format:
----------------------------------------------------------------------
- This is the first list item.

  Second paragraph in the
  first list item.

- List items need not be
  separated by a blank line.
- And will be rendered without
  one in any case.

We can have indented lists:

  - This is an indented list
    item
  - Another indented list
    item:

      - A literal block in the middle
            of an indented list.

      (The above is not a list item since we are in the literal block.)

  Literal block with no indentation (apart from
  the two spaces added to all literal blocks).

1. This is an enumerated list
   (first item).
2. Continuing with the second
   item.
(1) foo
(2) bar
1) Another
2) List

Line blocks are also a form of
list:

This is the first line. The
line continues here.
This is the second line.
----------------------------------------------------------------------

html format:
----------------------------------------------------------------------
<ul>
 <li> This is the first list item.
<p>
Second paragraph in the first list item.
</p>
 <li> List items need not be separated   by a blank line.
 <li> And will be rendered without   one in any case.
</ul>
<p>
We can have indented lists:
</p>
<ul>
 <li> This is an indented list item
 <li> Another indented list item:
<pre>
- A literal block in the middle
      of an indented list.
</pre>
<pre>
(The above is not a list item since we are in the literal block.)
</pre>
</ul>
<pre>
Literal block with no indentation (apart from
the two spaces added to all literal blocks).
</pre>
<ol>
 <li> This is an enumerated list (first item).
 <li> Continuing with the second item.
 <li> foo
 <li> bar
 <li> Another
 <li> List
</ol>
<p>
Line blocks are also a form of list:
</p>
<ol>
 <li> This is the first line.   The line continues here.
 <li> This is the second line.
</ol>
----------------------------------------------------------------------

== options ==
60 column format:
----------------------------------------------------------------------
There is support for simple option lists, but only with long
options:

 -X --exclude filter  an option with a short and long option
                      with an argument
 -I --include         an option with both a short option and
                      a long option
    --all             Output all.
    --both            Output both (this description is quite
                      long).
    --long            Output all day long.
    --par             This option has two paragraphs in its
                      description. This is the first.

                      This is the second.  Blank lines may
                      be omitted between options (as above)
                      or left in (as here).

The next paragraph looks like an option list, but lacks the
two-space marker after the option. It is treated as a normal
paragraph:

--foo bar baz
----------------------------------------------------------------------

30 column format:
----------------------------------------------------------------------
There is support for simple
option lists, but only with
long options:

 -X --exclude filter  an
                      option
                      with a
                      short
                      and
                      long
                      option
                      with an
                      argumen
                      t
 -I --include         an
                      option
                      with
                      both a
                      short
                      option
                      and a
                      long
                      option
    --all             Output
                      all.
    --both            Output
                      both
                      (this d
                      escript
                      ion is
                      quite
                      long).
    --long            Output
                      all day
                      long.
    --par             This
                      option
                      has two
                      paragra
                      phs in
                      its des
                      criptio
                      n. This
                      is the
                      first.

                      This is
                      the
                      second.
                      Blank
                      lines
                      may be
                      omitted
                      between
                      options
                      (as
                      above)
                      or left
                      in (as
                      here).

The next paragraph looks like
an option list, but lacks the
two-space marker after the
option. It is treated as a
normal paragraph:

--foo bar baz
----------------------------------------------------------------------

html format:
----------------------------------------------------------------------
<p>
There is support for simple option lists,
but only with long options:
</p>
<dl>
 <dt>-X --exclude filter
 <dd>an option with a short and long option with an argument
 <dt>-I --include
 <dd>an option with both a short option and a long option
 <dt>   --all
 <dd>Output all.
 <dt>   --both
 <dd>Output both (this description is quite long).
 <dt>   --long
 <dd>Output all day long.
 <dt>   --par
 <dd>This option has two paragraphs in its description. This is the first.
<p>
This is the second.  Blank lines may be omitted between
options (as above) or left in (as here).
</p>
</dl>
<p>
The next paragraph looks like an option list, but lacks the two-space
marker after the option. It is treated as a normal paragraph:
</p>
<p>
--foo bar baz
</p>
----------------------------------------------------------------------

== fields ==
60 column format:
----------------------------------------------------------------------
a             First item.
ab            Second item. Indentation and wrapping is
              handled automatically.

Next list:

small         The larger key below triggers full indentation
              here.
much too large
              This key is big enough to get its own line.
----------------------------------------------------------------------

30 column format:
----------------------------------------------------------------------
a             First item.
ab            Second item.
              Indentation and
              wrapping is
              handled
              automatically.

Next list:

small         The larger key
              below triggers
              full indentation
              here.
much too large
              This key is big
              enough to get
              its own line.
----------------------------------------------------------------------

html format:
----------------------------------------------------------------------
<dl>
 <dt>a
 <dd>First item.
 <dt>ab
 <dd>Second item. Indentation and wrapping is handled automatically.
</dl>
<p>
Next list:
</p>
<dl>
 <dt>small
 <dd>The larger key below triggers full indentation here.
 <dt>much too large
 <dd>This key is big enough to get its own line.
</dl>
----------------------------------------------------------------------

== containers (normal) ==
60 column format:
----------------------------------------------------------------------
Normal output.
----------------------------------------------------------------------

30 column format:
----------------------------------------------------------------------
Normal output.
----------------------------------------------------------------------

html format:
----------------------------------------------------------------------
<p>
Normal output.
</p>
----------------------------------------------------------------------

== containers (verbose) ==
60 column format:
----------------------------------------------------------------------
Normal output.

Verbose output.
----------------------------------------------------------------------
['debug', 'debug']
----------------------------------------------------------------------

30 column format:
----------------------------------------------------------------------
Normal output.

Verbose output.
----------------------------------------------------------------------
['debug', 'debug']
----------------------------------------------------------------------

html format:
----------------------------------------------------------------------
<p>
Normal output.
</p>
<p>
Verbose output.
</p>
----------------------------------------------------------------------
['debug', 'debug']
----------------------------------------------------------------------

== containers (debug) ==
60 column format:
----------------------------------------------------------------------
Normal output.

Initial debug output.
----------------------------------------------------------------------
['verbose']
----------------------------------------------------------------------

30 column format:
----------------------------------------------------------------------
Normal output.

Initial debug output.
----------------------------------------------------------------------
['verbose']
----------------------------------------------------------------------

html format:
----------------------------------------------------------------------
<p>
Normal output.
</p>
<p>
Initial debug output.
</p>
----------------------------------------------------------------------
['verbose']
----------------------------------------------------------------------

== containers (verbose debug) ==
60 column format:
----------------------------------------------------------------------
Normal output.

Initial debug output.

Verbose output.

Debug output.
----------------------------------------------------------------------
[]
----------------------------------------------------------------------

30 column format:
----------------------------------------------------------------------
Normal output.

Initial debug output.

Verbose output.

Debug output.
----------------------------------------------------------------------
[]
----------------------------------------------------------------------

html format:
----------------------------------------------------------------------
<p>
Normal output.
</p>
<p>
Initial debug output.
</p>
<p>
Verbose output.
</p>
<p>
Debug output.
</p>
----------------------------------------------------------------------
[]
----------------------------------------------------------------------

== roles ==
60 column format:
----------------------------------------------------------------------
Please see "hg add".
----------------------------------------------------------------------

30 column format:
----------------------------------------------------------------------
Please see "hg add".
----------------------------------------------------------------------

html format:
----------------------------------------------------------------------
<p>
Please see &quot;hg add&quot;.
</p>
----------------------------------------------------------------------

== sections ==
60 column format:
----------------------------------------------------------------------
Title
=====

Section
-------

Subsection
''''''''''

Markup: "foo" and "hg help"
---------------------------
----------------------------------------------------------------------

30 column format:
----------------------------------------------------------------------
Title
=====

Section
-------

Subsection
''''''''''

Markup: "foo" and "hg help"
---------------------------
----------------------------------------------------------------------

html format:
----------------------------------------------------------------------
<h1>Title</h1>
<h2>Section</h2>
<h3>Subsection</h3>
<h2>Markup: &quot;foo&quot; and &quot;hg help&quot;</h2>
----------------------------------------------------------------------

== admonitions ==
60 column format:
----------------------------------------------------------------------
Note:
   This is a note

   - Bullet 1
   - Bullet 2

   Warning!
      This is a warning Second input line of warning

!Danger!
   This is danger
----------------------------------------------------------------------

30 column format:
----------------------------------------------------------------------
Note:
   This is a note

   - Bullet 1
   - Bullet 2

   Warning!
      This is a warning Second
      input line of warning

!Danger!
   This is danger
----------------------------------------------------------------------

html format:
----------------------------------------------------------------------
<p>
<b>Note:</b> 
</p>
<p>
This is a note
</p>
<ul>
 <li> Bullet 1
 <li> Bullet 2
</ul>
<p>
<b>Warning!</b> This is a warning Second input line of warning
</p>
<p>
<b>!Danger!</b> This is danger
</p>
----------------------------------------------------------------------

== comments ==
60 column format:
----------------------------------------------------------------------
Some text.

   Some indented text.

Empty comment above
----------------------------------------------------------------------

30 column format:
----------------------------------------------------------------------
Some text.

   Some indented text.

Empty comment above
----------------------------------------------------------------------

html format:
----------------------------------------------------------------------
<p>
Some text.
</p>
<p>
Some indented text.
</p>
<p>
Empty comment above
</p>
----------------------------------------------------------------------

  === === ========================================
  a   b   c                                       
  === === ========================================
  1   2   3                                       
  foo bar baz this list is very very very long man
  === === ========================================

== table ==
60 column format:
----------------------------------------------------------------------
  a   b   c
  ------------------------------------------------
  1   2   3
  foo bar baz this list is very very very long man
----------------------------------------------------------------------

30 column format:
----------------------------------------------------------------------
  a   b   c
  ------------------------------
  1   2   3
  foo bar baz this list is
          very very very long
          man
----------------------------------------------------------------------

html format:
----------------------------------------------------------------------
<table>
<tr><td>a</td>
<td>b</td>
<td>c</td></tr>
<tr><td>1</td>
<td>2</td>
<td>3</td></tr>
<tr><td>foo</td>
<td>bar</td>
<td>baz this list is very very very long man</td></tr>
</table>
----------------------------------------------------------------------

 = ==== ======================================
 s long line goes on here                     
   xy   tried to fix here by indenting        
 = ==== ======================================

== table+nl ==
60 column format:
----------------------------------------------------------------------
 s long line goes on here
   xy   tried to fix here by indenting
----------------------------------------------------------------------

30 column format:
----------------------------------------------------------------------
 s long line goes on here
   xy   tried to fix here by
        indenting
----------------------------------------------------------------------

html format:
----------------------------------------------------------------------
<table>
<tr><td>s</td>
<td>long</td>
<td>line goes on here</td></tr>
<tr><td></td>
<td>xy</td>
<td>tried to fix here by indenting</td></tr>
</table>
----------------------------------------------------------------------