sapling/tests/test-alias-circular.t
Jun Wu 25eb53f3e7 alias: make resolution unaffected by definition order
Summary:
Previously, the alias resolution is affected by the alias definition order. So
things like:

  [alias]
  myglog = log -G
  myvlog = myglog -v

works. But

  [alias]
  myvlog = myglog -v
  myglog = log -G

doesn't. D8767902 changed ordering semantics and broke some people's aliases,
because if both `myvlog` and `myglog` are defined in system hgrc, their order
cannot be changed from a user hgrc.

Instead of having subtle behavior here depending on the order. Let's just do
not rely on the order. This diff makes it so, by resolving aliases using latest
(alias-if-possible) definitions, with only one special case: "foo = foo ..."
uses the original non-alias "foo" command.

The "alias ... shadows command ..." debug message was removed as it's
no longer accurate.

Reviewed By: simpkins

Differential Revision: D9417710

fbshipit-source-id: f4228eba3c8c728163a54bcf053c379fa86bd123
2018-08-21 12:06:18 -07:00

55 lines
865 B
Perl

Alias can override builtin commands.
$ newrepo
$ setconfig alias.log="log -T 'x\n'"
$ hg log -r null
x
Alias can override a builtin command to another builtin command.
$ newrepo
$ setconfig alias.log=id
$ hg log -r null
000000000000 tip
Alias can refer to another alias. Order does not matter.
$ newrepo
$ cat >> .hg/hgrc <<EOF
> [alias]
> a = b
> b = log -r null -T 'x\n'
> c = b
> EOF
$ hg a
x
$ hg c
x
Alias cannot form a cycle.
$ newrepo
$ cat >> .hg/hgrc << EOF
> [alias]
> c = a
> a = b
> b = c
> logwithsuffix = logwithsuff
> log = log
> EOF
$ hg a
abort: circular aliases: a b c
[255]
$ hg b
abort: circular aliases: a b c
[255]
$ hg c
abort: circular aliases: a b c
[255]
$ hg log -r null -T 'x\n'
x
$ hg logwithsuffix
abort: circular aliases: logwithsuffix
[255]