[PATCH 1 of 1 RFC] tag: abort if not at a branch head

Adrian Buehlmann adrian at cadifra.com
Tue Dec 7 02:43:31 CST 2010

On 2010-12-07 04:14, Matt Mackall wrote:
> On Tue, 2010-12-07 at 01:31 +0100, Adrian Buehlmann wrote:
>> On 2010-12-07 01:14, Matt Mackall wrote:
>>> On Mon, 2010-12-06 at 13:56 -0600, Kevin Bullock wrote:
>>>> # HG changeset patch
>>>> # User Kevin Bullock <kbullock at ringworld.org>
>>>> # Date 1291665075 21600
>>>> # Node ID f52e752c6d5f90352bb29ba6c2543656f6e4531e
>>>> # Parent  8c6b7a5f38c4585b1b2c2ceaffa8023f36a18479
>>>> tag: abort if not at a branch head
>>>> Since it's usually only desirable to make tag commits on top of branch
>>>> heads, abort if the working dir parent is not a branch head. -f/--force
>>>> may be passed to commit at a non-head anyway.
>>> I'm hard-pressed to think of any realistic use cases for committing a
>>> tag at somewhere other than a branch head. Can anyone think of one?
>> Someone might be used to doing weird things.
>> Assume you want to start a new feature based on an old revision
>> (slightly weird, but not completely mad).
>>   $ hg up <old rev>
>> Then assume that user wants to mark with a tag from where he started to
>> fork off ("I always forget from where I started my fork work, so I began
>> to tag it with a name"):
>>   $ hg tag feature-X-base
>>   hack, ci, hack, ci, etc
>> Certainly not a very elegant usage of Mercurial but Mercurial allowed
>> that in the past.
> Ok, that's half an answer. The other half is: do you think requiring -f
> in this case will be an issue?

Right. Having thought and written all the things following below, I'm
leaning towards accepting this change.

To be honest: I'm not completely sure. But I'm also reluctant to reject
this change or bikeshed it to premature death.

Requiring -f on commands tends to annoy those who know what they do. But
we could argue it's a unusual case if they want to use hg tag like that.

Another (possibly inflammatory) question we might ask ourselves: are we
going to require -f on commit as well if commit will create a new head?

(This reminds me of that user coming into #mercurial asking "I have four
heads, what should I do?" and someone -- who shall be unnamed here --
responded "See a doctor" :).

In other words: newbies have a hard time to understand how they create a
new head. And even more so getting rid of an unwanted one.

Interestingly, I just found that this use case is even mentioned in the
help text:

Tags are used to name particular revisions of the repository and are
very useful to compare different revisions, to go back to significant
earlier versions or to mark branch points as releases, etc.

Note the "...or to mark branch points".

If there's no consensus for requiring -f here (or a decision by
Mercurial's BDFL :), then we should at the very least consider emitting
the classical "created new head":

  $ hg tag bla
  created new head

like we already do on commit.

More information about the Mercurial-devel mailing list