Patchwork [1,of,4] test-revert: improve comment

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 8, 2014, 10:27 p.m.
Message ID <2e2109ca6773462a30ca.1407536875@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5331/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 8, 2014, 10:27 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1403708285 -3600
#      Wed Jun 25 15:58:05 2014 +0100
# Node ID 2e2109ca6773462a30ca01125153ad4e1d9189b4
# Parent  ba5fc3f81f1588507a5a84ac2b43679705ceec7b
test-revert: improve comment

We highlight the behavior tested by each sections. (This is a gratuitous
improvement before significant upgrade of the test and massive refactoring of
the revert code)

Patch

diff --git a/tests/test-revert.t b/tests/test-revert.t
--- a/tests/test-revert.t
+++ b/tests/test-revert.t
@@ -12,10 +12,13 @@  nothing changed
   abort: no files or directories specified
   (use --all to revert all files)
   [255]
   $ hg revert --all
 
+Introduce some changes and revert them
+--------------------------------------
+
   $ echo 123 > b
 
 should show b unknown
 
   $ hg status
@@ -40,30 +43,44 @@  should show a removed, b added and c mod
 
   $ hg status
   M c
   A b
   R a
+
+revert removal of a file
+
   $ hg revert a
 
 should show b added, copy saved, and c modified
 
   $ hg status
   M c
   A b
+
+revert addition of a file
+
   $ hg revert b
 
 should show b unknown, and c modified
 
   $ hg status
   M c
   ? b
+
+revert modification of a file (--no-backup)
+
   $ hg revert --no-backup c
 
 should show unknown: b
 
   $ hg status
   ? b
+
+
+revert deletion (! status) of a added file
+------------------------------------------
+
   $ hg add b
 
 should show b added
 
   $ hg status b
@@ -87,30 +104,34 @@  should show a c e
   $ ls
   a
   c
   e
 
-should verbosely save backup to e.orig
+Test creation of backup (.orig) files
+-------------------------------------
 
   $ echo z > e
   $ hg revert --all -v
   saving current version of e as e.orig
   reverting e
 
-should say no changes needed
+revert on clean file (no change)
+--------------------------------
 
   $ hg revert a
   no changes needed to a
 
-should say file not managed
+revert on an untracked file
+---------------------------
 
   $ echo q > q
   $ hg revert q
   file not managed: q
   $ rm q
 
-should say file not found
+revert on file that does not exists
+-----------------------------------
 
   $ hg revert notfound
   notfound: no such file in rev 334a9e57682c
   $ touch d
   $ hg add d
@@ -120,25 +141,30 @@  should say file not found
   $ hg add z
   $ hg st
   A z
   ? e.orig
 
-should add a, remove d, forget z
+revert to another revision (--rev)
+----------------------------------
 
   $ hg revert --all -r0
   adding a
   removing d
   forgetting z
 
-should forget a, undelete d
+revert explicitly to parent (--rev)
+-----------------------------------
 
   $ hg revert --all -rtip
   forgetting a
   undeleting d
   $ rm a *.orig
 
-should silently add a
+revert to another revision (--rev) and exact match
+--------------------------------------------------
+
+exact match are more silent
 
   $ hg revert -r0 a
   $ hg st a
   A a
   $ hg rm d
@@ -151,10 +177,14 @@  should silently keep d removed
   $ hg st d
   R d
 
   $ hg update -C
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+revert of exec bit
+------------------
+
 #if execbit
   $ chmod +x c
   $ hg revert --all
   reverting c
 
@@ -178,10 +208,11 @@  should print executable
 
   $ cd ..
 
 
 Issue241: update and revert produces inconsistent repositories
+--------------------------------------------------------------
 
   $ hg init a
   $ cd a
   $ echo a >> a
   $ hg commit -A -d '1 0' -m a
@@ -191,24 +222,27 @@  Issue241: update and revert produces inc
   $ hg update 0
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ mkdir b
   $ echo b > b/b
 
-should fail - no arguments
+call `hg revert` with no file specified
+---------------------------------------
 
   $ hg revert -rtip
   abort: no files or directories specified
   (use --all to revert all files, or 'hg update 1' to update)
   [255]
 
-should succeed
+call `hg revert` with --all
+---------------------------
 
   $ hg revert --all -rtip
   reverting a
 
 
 Issue332: confusing message when reverting directory
+----------------------------------------------------
 
   $ hg ci -A -m b
   adding b/b
   created new head
   $ echo foobar > b/b
@@ -222,10 +256,11 @@  Issue332: confusing message when reverti
   $ hg revert .
   reverting b/b (glob)
 
 
 reverting a rename target should revert the source
+--------------------------------------------------
 
   $ hg mv a newa
   $ hg revert newa
   $ hg st a newa
   ? newa
@@ -256,10 +291,11 @@  4 ignored files (we will add/commit ever
   $ echo >> ignored
   $ echo >> ignoreddir/file
   $ hg rm removed ignoreddir/removed
 
 should revert ignored* and undelete *removed
+--------------------------------------------
 
   $ hg revert -a --no-backup
   reverting ignored
   reverting ignoreddir/file (glob)
   undeleting ignoreddir/removed (glob)
@@ -269,24 +305,28 @@  should revert ignored* and undelete *rem
   $ hg up -qC
   $ echo >> ignored
   $ hg rm removed
 
 should silently revert the named files
+--------------------------------------
 
   $ hg revert --no-backup ignored removed
   $ hg st -mardi
 
+Reverting copy (issue3920)
+--------------------------
+
 someone set up us the copies
 
   $ rm .hgignore
   $ hg update -C
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg mv ignored allyour
   $ hg copy removed base
   $ hg commit -m rename
 
-copies and renames, you have no chance to survive make your time (issue3920)
+copies and renames, you have no chance to survive make your time
 
   $ hg update '.^'
   1 files updated, 0 files merged, 2 files removed, 0 files unresolved
   $ hg revert -rtip -a
   adding allyour
@@ -298,28 +338,29 @@  copies and renames, you have no chance t
   A base
     removed
   R ignored
 
 Test revert of a file added by one side of the merge
+====================================================
 
-(remove any pending change)
+remove any pending change
 
   $ hg revert --all
   forgetting allyour
   forgetting base
   undeleting ignored
   $ hg purge --all --config extensions.purge=
 
-(Adds a new commit)
+Adds a new commit
 
   $ echo foo > newadd
   $ hg add newadd
   $ hg commit -m 'other adds'
   created new head
 
 
-(merge it with the other 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
@@ -329,11 +370,11 @@  Test revert of a file added by one side 
    rename
   branch: default
   commit: 2 modified, 1 removed (merge)
   update: (current)
 
-(clarifies who added what)
+clarifies who added what
 
   $ hg status
   M allyour
   M base
   R ignored
@@ -342,38 +383,42 @@  Test revert of a file added by one side 
   $ hg status --change 'p2()'
   A allyour
   A base
   R ignored
 
-(revert file added by p1() to p1() state)
+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)
+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)
+revert file added by p2() to p2() state
+------------------------------------------
 
   $ hg revert -r 'p2()' 'glob:allyou?'
   $ hg status
   M allyour
   M base
   R ignored
   R newadd
 
-(revert file added by p2() to p1() state)
+revert file added by p2() to p1() state
+------------------------------------------
 
   $ hg revert -r 'p1()' 'glob:allyou?'
   removing allyour
   $ hg status
   M base