Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mercurial, how to tag old version of files

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?

like image 596
fred basset Avatar asked Dec 24 '11 00:12

fred basset


Video Answer


1 Answers

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
like image 91
pyfunc Avatar answered Oct 21 '22 15:10

pyfunc