Patchwork test-merge-tools: fix flaky test by avoiding debugsetparents

login
register
mail settings
Submitter Martin von Zweigbergk
Date Feb. 11, 2015, 12:24 a.m.
Message ID <4bba350e6e54c663a076.1423614243@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/7781/
State Accepted
Headers show

Comments

Martin von Zweigbergk - Feb. 11, 2015, 12:24 a.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1423613835 28800
#      Tue Feb 10 16:17:15 2015 -0800
# Node ID 4bba350e6e54c663a0763870bcd7a6f95857f601
# Parent  415414caf43924082eeab9ef1ce329cb2ab1f8eb
test-merge-tools: fix flaky test by avoiding debugsetparents

debugsetparents is a debug command and does not provide the same
guarantees as non-debug commands do. In particular, when the user sets
a different parent, any clean files will remain clean in the dirstate
even though the new parent might have a different version of the file
(so it should appear modified compared to the new parent). Let's
instead achieve the same effect by updating to the new parent and
reverting the contents back to what they were.

This fix can be tested by passing '--config
debug.dirstate.delaywrite=2' to the 'hg update' command in the
beforemerge().
Augie Fackler - Feb. 11, 2015, 2:37 p.m.
On Feb 10, 2015, at 7:24 PM, Martin von Zweigbergk <martinvonz@google.com> wrote:

> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1423613835 28800
> #      Tue Feb 10 16:17:15 2015 -0800
> # Node ID 4bba350e6e54c663a0763870bcd7a6f95857f601
> # Parent  415414caf43924082eeab9ef1ce329cb2ab1f8eb
> test-merge-tools: fix flaky test by avoiding debugsetparents

Queued this, thanks.

> 
> debugsetparents is a debug command and does not provide the same
> guarantees as non-debug commands do. In particular, when the user sets
> a different parent, any clean files will remain clean in the dirstate
> even though the new parent might have a different version of the file
> (so it should appear modified compared to the new parent). Let's
> instead achieve the same effect by updating to the new parent and
> reverting the contents back to what they were.
> 
> This fix can be tested by passing '--config
> debug.dirstate.delaywrite=2' to the 'hg update' command in the
> beforemerge().
> 
> diff -r 415414caf439 -r 4bba350e6e54 tests/test-merge-tools.t
> --- a/tests/test-merge-tools.t	Mon Feb 09 16:20:55 2015 -0800
> +++ b/tests/test-merge-tools.t	Tue Feb 10 16:17:15 2015 -0800
> @@ -603,7 +603,8 @@
>   true.priority=1
>   true.executable=cat
>   # hg update -C 1
> -  $ hg debugsetparent 0
> +  $ hg update -q 0
> +  $ hg revert -q -r 1 .
>   $ hg update -r 2
>   merging f
>   revision 1
> @@ -628,7 +629,8 @@
>   true.priority=1
>   true.executable=cat
>   # hg update -C 1
> -  $ hg debugsetparent 0
> +  $ hg update -q 0
> +  $ hg revert -q -r 1 .
>   $ hg update -r 2 --tool false
>   merging f
>   merging f failed!
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Pierre-Yves David - Feb. 25, 2015, 2:41 p.m.
On 02/11/2015 12:24 AM, Martin von Zweigbergk wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1423613835 28800
> #      Tue Feb 10 16:17:15 2015 -0800
> # Node ID 4bba350e6e54c663a0763870bcd7a6f95857f601
> # Parent  415414caf43924082eeab9ef1ce329cb2ab1f8eb
> test-merge-tools: fix flaky test by avoiding debugsetparents
>
> debugsetparents is a debug command and does not provide the same
> guarantees as non-debug commands do. In particular, when the user sets
> a different parent, any clean files will remain clean in the dirstate
> even though the new parent might have a different version of the file
> (so it should appear modified compared to the new parent).

This happen to be a very common mistake of fool playing with 
debugsetparent. Given that such fool also seems fairly common, should we 
add a warning to this debugcommand?

Patch

diff -r 415414caf439 -r 4bba350e6e54 tests/test-merge-tools.t
--- a/tests/test-merge-tools.t	Mon Feb 09 16:20:55 2015 -0800
+++ b/tests/test-merge-tools.t	Tue Feb 10 16:17:15 2015 -0800
@@ -603,7 +603,8 @@ 
   true.priority=1
   true.executable=cat
   # hg update -C 1
-  $ hg debugsetparent 0
+  $ hg update -q 0
+  $ hg revert -q -r 1 .
   $ hg update -r 2
   merging f
   revision 1
@@ -628,7 +629,8 @@ 
   true.priority=1
   true.executable=cat
   # hg update -C 1
-  $ hg debugsetparent 0
+  $ hg update -q 0
+  $ hg revert -q -r 1 .
   $ hg update -r 2 --tool false
   merging f
   merging f failed!