Patchwork [1,of,7] revert: add a test case to reverting "add" during merges

login
register
mail settings
Submitter Pierre-Yves David
Date May 19, 2014, 3:58 p.m.
Message ID <bf97b13adc66b73cac73.1400515080@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/4796/
State Accepted
Commit 4af19d39706e3684611a1cb221b6e1bd8e40dde8
Headers show

Comments

Pierre-Yves David - May 19, 2014, 3:58 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1400027299 25200
#      Tue May 13 17:28:19 2014 -0700
# Node ID bf97b13adc66b73cac73fe5e4135eac8822a110c
# Parent  63c3014d89ccc998da6fca896304c0f098da6eb6
revert: add a test case to reverting "add" during merges

This kind of revert is specifically trickier since the file is reported as
"modified" by status. This case was only tested by some largefiles test. We
introduce proper testing of all aspects of this case in the revert tests themself.

Patch

diff --git a/tests/test-revert.t b/tests/test-revert.t
--- a/tests/test-revert.t
+++ b/tests/test-revert.t
@@ -297,6 +297,90 @@  copies and renames, you have no chance t
     ignored
   A base
     removed
   R ignored
 
-  $ cd ..
+Test revert of a file added by one side of the merge
+
+(remove any pending change)
+
+  $ hg revert --all
+  forgetting allyour
+  forgetting base
+  undeleting ignored
+  $ hg purge --all --config extensions.purge=
+
+(Adds a new commit)
+
+  $ echo foo > newadd
+  $ hg add newadd
+  $ hg commit -m 'other adds'
+  created new head
+
+
+(merge it with the other head)
+
+  $ hg merge # merge 1 into 2
+  2 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  $ hg summary
+  parent: 2:b8ec310b2d4e tip
+   other adds
+  parent: 1:f6180deb8fbe 
+   rename
+  branch: default
+  commit: 2 modified, 1 removed (merge)
+  update: (current)
+
+(clarifies who added what)
+
+  $ hg status
+  M allyour
+  M base
+  R ignored
+  $ hg status --change 'p1()'
+  A newadd
+  $ hg status --change 'p2()'
+  A allyour
+  A base
+  R ignored
+
+(revert file added by p1() to p1() state)
+
+  $ hg revert -r 'p1()' 'glob:newad?'
+  $ hg status
+  M allyour
+  M base
+  R ignored
+
+(revert file added by p1() to p2() state)
+
+  $ hg revert -r 'p2()' 'glob:newad?'
+  removing newadd
+  $ hg status
+  M allyour
+  M base
+  R ignored
+  R newadd
+
+(revert file added by p2() to p2() state)
+spurious message comes from revert confusion when using p2. To be fixed soon.
+
+  $ hg revert -r 'p2()' 'glob:allyou?'
+  reverting allyour
+  $ hg status
+  M allyour
+  M base
+  R ignored
+  R newadd
+
+(revert file added by p2() to p1() state)
+
+  $ hg revert -r 'p1()' 'glob:allyou?'
+  removing allyour
+  $ hg status
+  M base
+  R allyour
+  R ignored
+  R newadd
+
+