[PATCH] don't allow tagging the null revision (issue1915)
Brad Hall
bhall at fb.com
Thu Jul 26 16:21:42 CDT 2012
# HG changeset patch
# User Brad Hall <bhall at fb.com>
# Date 1338940813 25200
# Node ID da78ad7f8183569ebd154b448e2b49a43583532a
# Parent cd7db8e05c657fb08b51903fa2ef8c2246de1c4b
don't allow tagging the null revision (issue1915)
Also fixed the tests that were doing this and expected it to work
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5564,6 +5564,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)
diff --git a/tests/test-http.t b/tests/test-http.t
--- a/tests/test-http.t
+++ b/tests/test-http.t
@@ -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'
diff --git a/tests/test-ssh.t b/tests/test-ssh.t
--- a/tests/test-ssh.t
+++ b/tests/test-ssh.t
@@ -277,9 +277,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
@@ -295,7 +298,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)
diff --git a/tests/test-static-http.t b/tests/test-static-http.t
--- a/tests/test-static-http.t
+++ b/tests/test-static-http.t
@@ -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
diff --git a/tests/test-tag.t b/tests/test-tag.t
--- a/tests/test-tag.t
+++ b/tests/test-tag.t
@@ -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
More information about the Mercurial-devel
mailing list