##// END OF EJS Templates
tag: abort if not at a branch head (issue2552)...
Kevin Bullock -
r13135:1c1ca9d3 stable
parent child Browse files
Show More
@@ -3660,16 +3660,23 b' def tag(ui, repo, name1, *names, **opts)'
3660
3660
3661 Tags are used to name particular revisions of the repository and are
3661 Tags are used to name particular revisions of the repository and are
3662 very useful to compare different revisions, to go back to significant
3662 very useful to compare different revisions, to go back to significant
3663 earlier versions or to mark branch points as releases, etc.
3663 earlier versions or to mark branch points as releases, etc. Changing
3664 an existing tag is normally disallowed; use -f/--force to override.
3664
3665
3665 If no revision is given, the parent of the working directory is
3666 If no revision is given, the parent of the working directory is
3666 used, or tip if no revision is checked out.
3667 used, or tip if no revision is checked out.
3667
3668
3668 To facilitate version control, distribution, and merging of tags,
3669 To facilitate version control, distribution, and merging of tags,
3669 they are stored as a file named ".hgtags" which is managed
3670 they are stored as a file named ".hgtags" which is managed similarly
3670 similarly to other project files and can be hand-edited if
3671 to other project files and can be hand-edited if necessary. This
3671 necessary. The file '.hg/localtags' is used for local tags (not
3672 also means that tagging creates a new commit. The file
3672 shared among repositories).
3673 ".hg/localtags" is used for local tags (not shared among
3674 repositories).
3675
3676 Tag commits are usually made at the head of a branch. If the parent
3677 of the working directory is not a branch head, :hg:`tag` aborts; use
3678 -f/--force to force the tag commit to be based on a non-head
3679 changeset.
3673
3680
3674 See :hg:`help dates` for a list of formats valid for -d/--date.
3681 See :hg:`help dates` for a list of formats valid for -d/--date.
3675
3682
@@ -3712,8 +3719,13 b' def tag(ui, repo, name1, *names, **opts)'
3712 if n in repo.tags():
3719 if n in repo.tags():
3713 raise util.Abort(_('tag \'%s\' already exists '
3720 raise util.Abort(_('tag \'%s\' already exists '
3714 '(use -f to force)') % n)
3721 '(use -f to force)') % n)
3715 if not opts.get('local') and repo.dirstate.parents()[1] != nullid:
3722 if not opts.get('local'):
3723 p1, p2 = repo.dirstate.parents()
3724 if p2 != nullid:
3716 raise util.Abort(_('uncommitted merge'))
3725 raise util.Abort(_('uncommitted merge'))
3726 bheads = repo.branchheads()
3727 if not opts.get('force') and bheads and p1 not in bheads:
3728 raise util.Abort(_('not at a branch head (use -f to force)'))
3717 r = repo[rev_].node()
3729 r = repo[rev_].node()
3718
3730
3719 if not message:
3731 if not message:
@@ -4475,7 +4487,7 b' table = {'
4475 _('[OPTION]... [FILE]...')),
4487 _('[OPTION]... [FILE]...')),
4476 "tag":
4488 "tag":
4477 (tag,
4489 (tag,
4478 [('f', 'force', None, _('replace existing tag')),
4490 [('f', 'force', None, _('force tag')),
4479 ('l', 'local', None, _('make the tag local')),
4491 ('l', 'local', None, _('make the tag local')),
4480 ('r', 'rev', '',
4492 ('r', 'rev', '',
4481 _('revision to tag'), _('REV')),
4493 _('revision to tag'), _('REV')),
@@ -9,7 +9,7 b''
9
9
10 $ hg co 1
10 $ hg co 1
11 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
11 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
12 $ hg tag -r0 t1
12 $ hg tag -f -r0 t1
13 $ hg tags
13 $ hg tags
14 tip 3:a49829c4fc11
14 tip 3:a49829c4fc11
15 t1 0:f7b1eb17ad24
15 t1 0:f7b1eb17ad24
@@ -78,13 +78,20 b''
78 $ cat .hg/localtags
78 $ cat .hg/localtags
79 d4f0d2909abc9290e2773c08837d70c1794e3f5a bleah1
79 d4f0d2909abc9290e2773c08837d70c1794e3f5a bleah1
80
80
81 tagging on a non-head revision
82
81 $ hg update 0
83 $ hg update 0
82 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
84 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
85 $ hg tag -l localblah
83 $ hg tag "foobar"
86 $ hg tag "foobar"
87 abort: not at a branch head (use -f to force)
88 [255]
89 $ hg tag -f "foobar"
84 $ cat .hgtags
90 $ cat .hgtags
85 acb14030fe0a21b60322c440ad2d20cf7685a376 foobar
91 acb14030fe0a21b60322c440ad2d20cf7685a376 foobar
86 $ cat .hg/localtags
92 $ cat .hg/localtags
87 d4f0d2909abc9290e2773c08837d70c1794e3f5a bleah1
93 d4f0d2909abc9290e2773c08837d70c1794e3f5a bleah1
94 acb14030fe0a21b60322c440ad2d20cf7685a376 localblah
88
95
89 $ hg tag -l 'xx
96 $ hg tag -l 'xx
90 > newline'
97 > newline'
@@ -102,6 +109,7 b' cloning local tags'
102 tag: bleah
109 tag: bleah
103 tag: bleah0
110 tag: bleah0
104 tag: foobar
111 tag: foobar
112 tag: localblah
105 user: test
113 user: test
106 date: Thu Jan 01 00:00:00 1970 +0000
114 date: Thu Jan 01 00:00:00 1970 +0000
107 summary: test
115 summary: test
@@ -156,10 +164,10 b" doesn't end with EOL"
156 > f = file('.hg/localtags', 'w'); f.write(last); f.close()
164 > f = file('.hg/localtags', 'w'); f.write(last); f.close()
157 > EOF
165 > EOF
158 $ cat .hg/localtags; echo
166 $ cat .hg/localtags; echo
159 d4f0d2909abc9290e2773c08837d70c1794e3f5a bleah1
167 acb14030fe0a21b60322c440ad2d20cf7685a376 localblah
160 $ hg tag -l localnewline
168 $ hg tag -l localnewline
161 $ cat .hg/localtags; echo
169 $ cat .hg/localtags; echo
162 d4f0d2909abc9290e2773c08837d70c1794e3f5a bleah1
170 acb14030fe0a21b60322c440ad2d20cf7685a376 localblah
163 c2899151f4e76890c602a2597a650a72666681bf localnewline
171 c2899151f4e76890c602a2597a650a72666681bf localnewline
164
172
165
173
@@ -197,6 +205,7 b' test custom commit messages'
197 custom tag message
205 custom tag message
198 second line
206 second line
199
207
208
200 local tag with .hgtags modified
209 local tag with .hgtags modified
201
210
202 $ hg tag hgtags-modified
211 $ hg tag hgtags-modified
@@ -209,6 +218,31 b' local tag with .hgtags modified'
209 $ hg tag --local baz
218 $ hg tag --local baz
210 $ hg revert --no-backup .hgtags
219 $ hg revert --no-backup .hgtags
211
220
221
222 tagging when at named-branch-head that's not a topo-head
223
224 $ hg up default
225 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
226 $ hg merge -t internal:local
227 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
228 (branch merge, don't forget to commit)
229 $ hg ci -m 'merge named branch'
230 $ hg up 11
231 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
232 $ hg tag new-topo-head
233
234
235 tagging on null rev
236
237 $ hg up null
238 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
239 $ hg tag nullrev
240 abort: not at a branch head (use -f to force)
241 [255]
242
243 $ hg init empty
244 $ hg tag -R empty nullrev
245
212 $ cd ..
246 $ cd ..
213
247
214 tagging on an uncommitted merge (issue2542)
248 tagging on an uncommitted merge (issue2542)
General Comments 0
You need to be logged in to leave comments. Login now