16

I forgot to tag and older version of my files with a release tag. The older version is at r13, latest is about r65. I cloned the latest repository to a new directory, did an "hg update -r13" to get the older code I wanted to tag, then did the tag command, but got the message:

abort: not at a branch head (use -f to force)

Is it safe to use the -f option in this situation?

fred basset
  • 9,774
  • 28
  • 88
  • 138

1 Answers1

19

I guess you can still do the tagging right in the repo without updating yourself to a particular revision.

hg tag -r 13 tagname

See the details at Mercurial wiki.

I tried testing it :

temp $ hg init .
temp $ touch a.txt
temp $ hg add a.txt 
temp $ hg commit -m "added a"
temp $ hg status
temp $ echo "sdwwdd" >> a.txt 
temp $ hg commit -m "modified a"
temp $ echo "\neddwedd" >> a.txt 
temp $ hg commit -m "modified a again"
temp $ hg log
changeset:   2:ef40a402fdab
tag:         tip
user:        "xxxx"
date:        Fri Dec 23 16:51:48 2011 -0800
summary:     modified a again

changeset:   1:d630dc3e2e3a
user:        "xxxx"
date:        Fri Dec 23 16:51:31 2011 -0800
summary:     modified a

changeset:   0:7c9917f24515
user:        "xxxx"
date:        Fri Dec 23 16:51:04 2011 -0800
summary:     added a

Output:

temp $ hg tag -r 1 a.txt a_1
temp $ hg tags
tip                                3:e3157256098f
a_1                                1:d630dc3e2e3a
a.txt                              1:d630dc3e2e3a
temp $ hg tag -r 1 all_1
temp $ hg tags
tip                                4:a643971911d8
all_1                              1:d630dc3e2e3a
a_1                                1:d630dc3e2e3a
a.txt                              1:d630dc3e2e3a
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
pyfunc
  • 65,343
  • 15
  • 148
  • 136