changeset 2982:890e285c52a1

revert: require --all to revert all files.
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Mon, 21 Aug 2006 09:44:52 -0700
parents 26c8d37496c2
children 3b7626b861f8
files mercurial/commands.py tests/test-confused-revert tests/test-merge-revert tests/test-merge-revert2 tests/test-nested-repo tests/test-remove tests/test-revert tests/test-revert-unknown tests/test-revert.out
diffstat 9 files changed, 33 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Sun Aug 20 02:21:59 2006 -0300
+++ b/mercurial/commands.py	Mon Aug 21 09:44:52 2006 -0700
@@ -820,6 +820,7 @@
         parent = p1
     hg.clean(repo, node, show_stats=False)
     revert_opts = opts.copy()
+    revert_opts['all'] = True
     revert_opts['rev'] = hex(parent)
     revert(ui, repo, **revert_opts)
     commit_opts = opts.copy()
@@ -2288,8 +2289,12 @@
 
     If names are given, all files matching the names are reverted.
 
-    If no arguments are given, all files in the repository are reverted.
+    If no arguments are given, no files are reverted.
     """
+
+    if not pats and not opts['all']:
+        raise util.Abort(_('no files or directories specified'))
+
     parent, p2 = repo.dirstate.parents()
     if opts['rev']:
         node = repo.lookup(opts['rev'])
@@ -3044,7 +3049,8 @@
          _('hg rename [OPTION]... SOURCE... DEST')),
     "^revert":
         (revert,
-         [('r', 'rev', '', _('revision to revert to')),
+         [('', 'all', None, _('revert all changes when no arguments given')),
+          ('r', 'rev', '', _('revision to revert to')),
           ('', 'no-backup', None, _('do not save backup copies of files')),
           ('I', 'include', [], _('include names matching given patterns')),
           ('X', 'exclude', [], _('exclude names matching given patterns')),
--- a/tests/test-confused-revert	Sun Aug 20 02:21:59 2006 -0300
+++ b/tests/test-confused-revert	Mon Aug 21 09:44:52 2006 -0700
@@ -13,7 +13,7 @@
 hg status
 
 echo "reverting..."
-hg revert
+hg revert --all
 
 echo "%%% should show b unknown and a back to normal"
 hg status
@@ -42,10 +42,10 @@
 hg status
 
 echo "%%% revert should fail"
-hg revert
+hg revert --all
 
 echo "%%% revert should be ok now"
-hg revert -r2
+hg revert -r2 --all
 
 echo "%%% should show b unknown and a marked modified (merged)"
 hg status
--- a/tests/test-merge-revert	Sun Aug 20 02:21:59 2006 -0300
+++ b/tests/test-merge-revert	Mon Aug 21 09:44:52 2006 -0700
@@ -15,7 +15,7 @@
 hg id
 echo "changed file1" >> file1
 hg id
-hg revert
+hg revert --all
 hg diff
 hg status
 hg id
@@ -29,11 +29,11 @@
 hg diff
 hg status
 hg id
-hg revert
+hg revert --all
 hg diff
 hg status
 hg id
-hg revert -r tip
+hg revert -r tip --all
 hg diff
 hg status
 hg id
--- a/tests/test-merge-revert2	Sun Aug 20 02:21:59 2006 -0300
+++ b/tests/test-merge-revert2	Mon Aug 21 09:44:52 2006 -0700
@@ -16,7 +16,7 @@
 hg id
 echo "changed file1" >> file1
 hg id
-hg revert --no-backup
+hg revert --no-backup --all
 hg diff
 hg status
 hg id
@@ -31,11 +31,11 @@
               -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" -e "s/\(>>>>>>>\) .*/\1/"
 hg status
 hg id
-hg revert --no-backup
+hg revert --no-backup --all
 hg diff
 hg status
 hg id
-hg revert -r tip --no-backup
+hg revert -r tip --no-backup --all
 hg diff
 hg status
 hg id
--- a/tests/test-nested-repo	Sun Aug 20 02:21:59 2006 -0300
+++ b/tests/test-nested-repo	Mon Aug 21 09:44:52 2006 -0700
@@ -14,6 +14,6 @@
 echo '# should print A b/x'
 hg st
 echo '# should forget b/x'
-hg revert
+hg revert --all
 echo '# should print nothing'
 hg st b
--- a/tests/test-remove	Sun Aug 20 02:21:59 2006 -0300
+++ b/tests/test-remove	Mon Aug 21 09:44:52 2006 -0700
@@ -9,7 +9,7 @@
 hg remove
 rm foo
 hg remove foo
-hg revert
+hg revert --all
 rm foo
 hg remove --after
 hg commit -m 2 -d "1000000 0"
--- a/tests/test-revert	Sun Aug 20 02:21:59 2006 -0300
+++ b/tests/test-revert	Mon Aug 21 09:44:52 2006 -0700
@@ -31,7 +31,7 @@
 ls
 echo %% should verbosely save backup to e.orig
 echo z > e
-hg revert -v
+hg revert --all -v
 echo %% should say no changes needed
 hg revert a
 echo %% should say file not managed
@@ -46,9 +46,9 @@
 hg add z
 hg st
 echo %% should add a, forget z
-hg revert -r0
+hg revert --all -r0
 echo %% should forget a
-hg revert -rtip
+hg revert --all -rtip
 rm -f a *.orig
 echo %% should silently add a
 hg revert -r0 a
@@ -56,7 +56,7 @@
 
 hg update -C
 chmod +x c
-hg revert
+hg revert --all
 echo %% should print non-executable
 test -x c || echo non-executable
 
@@ -64,7 +64,7 @@
 hg commit -d '1000001 0' -m exe
 
 chmod -x c
-hg revert
+hg revert --all
 echo %% should print executable
 test -x c && echo executable
 
@@ -78,6 +78,11 @@
 hg update 0
 mkdir b
 echo b > b/b
+
+echo % should fail - no arguments
 hg revert -rtip
 
+echo % should succeed
+hg revert --all -rtip
+
 true
--- a/tests/test-revert-unknown	Sun Aug 20 02:21:59 2006 -0300
+++ b/tests/test-revert-unknown	Mon Aug 21 09:44:52 2006 -0700
@@ -13,7 +13,7 @@
 
 echo %% Should show unknown
 hg status
-hg revert -r 0
+hg revert -r 0 --all
 echo %% Should show unknown and b removed
 hg status
 echo %% Should show a and unknown
--- a/tests/test-revert.out	Sun Aug 20 02:21:59 2006 -0300
+++ b/tests/test-revert.out	Mon Aug 21 09:44:52 2006 -0700
@@ -54,4 +54,7 @@
 %% issue 241
 adding a
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+% should fail - no arguments
+abort: no files or directories specified
+% should succeed
 reverting a