Bug 2993 - hg choosing alias instead of full command
Summary: hg choosing alias instead of full command
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: Mercurial (show other bugs)
Version: unspecified
Hardware: All All
: normal bug
Assignee: Bugzilla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-08 13:02 UTC by Matt Austin
Modified: 2012-05-13 05:11 UTC (History)
6 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Austin 2011-09-08 13:02 UTC
Observed with Mercurial 1.9.1

If the user has specified an alias that is the prefix of a command, then the
prefix alias is used, even when the entire command is specified. (e.g. if
the user specifies an alias for 'id', then whatever the alias for id is will
be used even when the full command 'identify' is used).

[maustin@yakko ~]$ python --version
Python 2.7.1
[maustin@yakko ~]$ rpm -q python
python-2.7.1-7.fc15.x86_64
[maustin@yakko ~]$ hg --version
Mercurial Distributed SCM (version 1.9.1)
(see http://mercurial.selenic.com for more information)

Copyright (C) 2005-2011 Matt Mackall and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[maustin@yakko ~]$ rpm -q mercurial
mercurial-1.9.1-1.fc15.x86_64
[maustin@yakko ~]$ hg init tmp
[maustin@yakko ~]$ cd tmp
[maustin@yakko tmp]$ hg id
000000000000 tip
[maustin@yakko tmp]$ cat > .hg/hgrc <<EOF
> [alias]
> id=identify -nibt
> EOF
[maustin@yakko tmp]$ hg id
000000000000 -1 default tip
[maustin@yakko tmp]$ hg identify
000000000000 -1 default tip
[maustin@yakko tmp]$ hg --config alias.id=identify identify
000000000000 tip
[maustin@yakko tmp]$ hg --config alias.id='identify -nibt' identify
000000000000 -1 default tip
[maustin@yakko ~]$ hg --config alias.id=log identify -n 2> /dev/null
hg identify [OPTION]... [FILE]

alias for: hg log
options:

 -f --follow               follow changeset history, or file history across
                           copies and renames
    --follow-first         only follow the first parent of merge changesets
 -d --date DATE            show revisions matching date spec
 -C --copies               show copied files
 -k --keyword TEXT [+]     do case-insensitive search for a given text
 -r --rev REV [+]          show the specified revision or range
    --removed              include revisions where files were removed
 -m --only-merges          show only merges
 -u --user USER [+]        revisions committed by user
 -b --branch BRANCH [+]    show changesets within the given named branch
 -P --prune REV [+]        do not display revision or any of its ancestors
 -h --hidden               show hidden changesets
 -p --patch                show patch
 -g --git                  use git extended diff format
 -l --limit NUM            limit number of changes displayed
 -M --no-merges            do not show merges
    --stat                 output diffstat-style summary of changes
    --style STYLE          display using template map file
    --template TEMPLATE    display with template
 -I --include PATTERN [+]  include names matching the given patterns
 -X --exclude PATTERN [+]  exclude names matching the given patterns

[+] marked option can be specified multiple times

use "hg help identify" to show the full help text
[maustin@yakko ~]$ hg --config alias.id=log identify -n
hg identify: option -n not recognized
hg identify [OPTION]... [FILE]

alias for: hg log

options:

 -f --follow               follow changeset history, or file history across
                           copies and renames
    --follow-first         only follow the first parent of merge changesets
 -d --date DATE            show revisions matching date spec
 -C --copies               show copied files
 -k --keyword TEXT [+]     do case-insensitive search for a given text
 -r --rev REV [+]          show the specified revision or range
    --removed              include revisions where files were removed
 -m --only-merges          show only merges
 -u --user USER [+]        revisions committed by user
 -b --branch BRANCH [+]    show changesets within the given named branch
 -P --prune REV [+]        do not display revision or any of its ancestors
 -h --hidden               show hidden changesets
 -p --patch                show patch
 -g --git                  use git extended diff format
 -l --limit NUM            limit number of changes displayed
 -M --no-merges            do not show merges
    --stat                 output diffstat-style summary of changes
    --style STYLE          display using template map file
    --template TEMPLATE    display with template
 -I --include PATTERN [+]  include names matching the given patterns
 -X --exclude PATTERN [+]  exclude names matching the given patterns

[+] marked option can be specified multiple times

use "hg help identify" to show the full help text
Comment 1 Matt Mackall 2011-09-12 16:56 UTC
Confirmed.
Comment 2 Augie Fackler 2011-10-11 16:45 UTC
I've mailed a possible fix to the list, but I'm not sure of its correctness
yet. Things in alias are a little twisty.
Comment 3 HG Bot 2011-10-12 11:00 UTC
Fixed by http://selenic.com/repo/hg/rev/81c97964d123
Augie Fackler <durin42@gmail.com>
alias: don't shadow commands that we only partially matched (issue2993) (BC)

(please test the fix)
Comment 4 Bugzilla 2012-05-12 09:23 UTC

--- Bug imported by bugzilla@serpentine.com 2012-05-12 09:23 EDT  ---

This bug was previously known as _bug_ 2993 at http://mercurial.selenic.com/bts/issue2993