tag: don't allow tagging the null revision (issue1915) stable
authorBrad Hall <bhall@fb.com>
Tue, 05 Jun 2012 17:00:13 -0700
branchstable
changeset 17260 e432fb4b4221
parent 17259 e96ad092fb18
child 17262 f62cac85ce79
tag: don't allow tagging the null revision (issue1915) Also fixed the tests that were doing this and expected it to work
mercurial/commands.py
tests/test-http.t
tests/test-ssh.t
tests/test-static-http.t
tests/test-tag.t
--- a/mercurial/commands.py	Thu Jul 26 13:58:43 2012 +0900
+++ b/mercurial/commands.py	Tue Jun 05 17:00:13 2012 -0700
@@ -5643,6 +5643,11 @@
         if opts.get('edit'):
             message = ui.edit(message, ui.username())
 
+        # don't allow tagging the null rev
+        if (not opts.get('remove') and
+            scmutil.revsingle(repo, rev_).rev() == nullrev):
+            raise util.Abort(_("null revision specified"))
+
         repo.tag(names, r, message, opts.get('local'), opts.get('user'), date)
     finally:
         release(lock, wlock)
--- a/tests/test-http.t	Thu Jul 26 13:58:43 2012 +0900
+++ b/tests/test-http.t	Tue Jun 05 17:00:13 2012 -0700
@@ -176,7 +176,10 @@
 clone of serve with repo in root and unserved subrepo (issue2970)
 
   $ hg --cwd test init sub
-  $ hg --cwd test/sub tag something
+  $ echo empty > test/sub/empty
+  $ hg --cwd test/sub add empty
+  $ hg --cwd test/sub commit -qm 'add empty'
+  $ hg --cwd test/sub tag -r 0 something
   $ echo sub = sub > test/.hgsub
   $ hg --cwd test add .hgsub
   $ hg --cwd test commit -qm 'add subrepo'
--- a/tests/test-ssh.t	Thu Jul 26 13:58:43 2012 +0900
+++ b/tests/test-ssh.t	Tue Jun 05 17:00:13 2012 -0700
@@ -278,9 +278,12 @@
 Test remote paths with spaces (issue2983):
 
   $ hg init --ssh "python \"$TESTDIR/dummyssh\"" "ssh://user@dummy/a repo"
+  $ touch "$TESTTMP/a repo/test"
+  $ hg -R 'a repo' commit -A -m "test"
+  adding test
   $ hg -R 'a repo' tag tag
   $ hg id --ssh "python \"$TESTDIR/dummyssh\"" "ssh://user@dummy/a repo"
-  3fb238f49e8c
+  73649e48688a
 
 Test hg-ssh using a helper script that will restore PYTHONPATH (which might
 have been cleared by a hg.exe wrapper) and invoke hg-ssh with the right
@@ -296,7 +299,7 @@
   > EOF
 
   $ hg id --ssh "sh ssh.sh" "ssh://user@dummy/a repo"
-  3fb238f49e8c
+  73649e48688a
 
   $ hg id --ssh "sh ssh.sh" "ssh://user@dummy/a'repo"
   remote: Illegal repository "$TESTTMP/a'repo" (glob)
--- a/tests/test-static-http.t	Thu Jul 26 13:58:43 2012 +0900
+++ b/tests/test-static-http.t	Tue Jun 05 17:00:13 2012 -0700
@@ -112,6 +112,9 @@
 
   $ hg init
   $ hg init sub
+  $ touch sub/test
+  $ hg -R sub commit -A -m "test"
+  adding test
   $ hg -R sub tag not-empty
   $ echo sub=sub > .hgsub
   $ echo a > a
@@ -129,7 +132,7 @@
   adding changesets
   adding manifests
   adding file changes
-  added 1 changesets with 1 changes to 1 files
+  added 2 changesets with 2 changes to 2 files
   3 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ cd local2
   $ hg verify
--- a/tests/test-tag.t	Thu Jul 26 13:58:43 2012 +0900
+++ b/tests/test-tag.t	Tue Jun 05 17:00:13 2012 -0700
@@ -248,7 +248,6 @@
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg tag new-topo-head
 
-
 tagging on null rev
 
   $ hg up null
@@ -259,6 +258,12 @@
 
   $ hg init empty
   $ hg tag -R empty nullrev
+  abort: null revision specified
+  [255]
+
+  $ hg tag -R empty -r 00000000000 -f nulltag
+  abort: null revision specified
+  [255]
 
   $ cd ..
 
@@ -300,6 +305,9 @@
 commit hook on tag used to be run without write lock - issue3344
 
   $ hg init repo-tag
+  $ touch repo-tag/test
+  $ hg -R repo-tag commit -A -m "test"
+  adding test
   $ hg init repo-tag-target
   $ hg -R repo-tag --config hooks.commit="\"hg\" push \"`pwd`/repo-tag-target\"" tag tag
   pushing to $TESTTMP/repo-tag-target
@@ -307,5 +315,5 @@
   adding changesets
   adding manifests
   adding file changes
-  added 1 changesets with 1 changes to 1 files
+  added 2 changesets with 2 changes to 2 files