# HG changeset patch # User Brad Hall # Date 2012-06-06 00:00:13 # Node ID e432fb4b422144eae57e7e3c716c47f8c2150989 # Parent e96ad092fb18912894c65fa1ca0b22d2d1ad9417 tag: 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 @@ -5643,6 +5643,11 @@ def tag(ui, repo, name1, *names, **opts) 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 @@ test http authentication 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 @@ -278,9 +278,12 @@ hide outer repo 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 @@ parameters: > 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 @@ test with "/" URI (issue 747) and subrep $ 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 @@ test with "/" URI (issue 747) and subrep 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 @@ tagging when at named-branch-head that's 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 @@ tagging on null rev $ 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 @@ tagging on an uncommitted merge (issue25 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 @@ commit hook on tag used to be run withou 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