[PATCH 3 of 3 STABLE] tag: abort tagging which overwrites existing global one locally
FUJIWARA Katsunori
foozy at lares.dti.ne.jp
Wed Apr 24 10:12:29 CDT 2013
# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1366815055 -32400
# Wed Apr 24 23:50:55 2013 +0900
# Branch stable
# Node ID 2f5f9f62caabd1b0ae2900e4fe4e43218d3be676
# Parent 4b8427b226d6ab5088678b585bd9700c43c835f5
tag: abort tagging which overwrites existing global one locally
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5568,8 +5568,8 @@
if opts.get('rev'):
rev_ = opts['rev']
message = opts.get('message')
+ expectedtype = opts.get('local') and 'local' or 'global'
if opts.get('remove'):
- expectedtype = opts.get('local') and 'local' or 'global'
for n in names:
if not repo.tagtype(n):
raise util.Abort(_("tag '%s' does not exist") % n)
@@ -5582,9 +5582,15 @@
if not message:
# we don't translate commit messages
message = 'Removed tag %s' % ', '.join(names)
- elif not opts.get('force'):
+ else:
for n in names:
- if n in repo.tags():
+ if n not in repo.tags():
+ continue
+ if (repo.tagtype(n) != expectedtype and
+ expectedtype == 'local'):
+ raise util.Abort(_("global tag '%s' can't be overwritten"
+ " locally") % n)
+ elif not opts.get('force'):
raise util.Abort(_("tag '%s' already exists "
"(use -f to force)") % n)
if not opts.get('local'):
diff --git a/tests/test-tag.t b/tests/test-tag.t
--- a/tests/test-tag.t
+++ b/tests/test-tag.t
@@ -99,6 +99,10 @@
$ cat .hg/localtags
d4f0d2909abc9290e2773c08837d70c1794e3f5a bleah1
+ $ hg tag --local -r 1 bleah
+ abort: global tag 'bleah' can't be overwritten locally
+ [255]
+
tagging on a non-head revision
$ hg update 0
More information about the Mercurial-devel
mailing list