Mercurial > hg
view tests/test-rebase-mq.out @ 11989:f853873fc66d
aliases: provide more flexible ways to work with shell alias arguments
This patch changes the functionality of shell aliases to add more powerful
options for working with shell alias arguments.
First: the alias name + arguments to a shell alias are set as an HG_ARGS
environment variable, delimited by spaces. This matches the behavior of hooks.
Second: any occurrences of "$@" (without quotes) are replaced with the
arguments, separated by spaces. This happens *before* the alias gets to the shell.
Third: any positive numeric variables ("$1", "$2", etc) are replaced with the
appropriate argument, indexed from 1. "$0" is replaced with the name of the
alias. Any "extra" numeric variables are replaced with an empty string. This
happens *before* the alias gets to the shell.
These changes allow for more flexible shell aliases:
[alias]
echo = !echo $@
count = !hg log -r "$@" --template='.' | wc -c | sed -e 's/ //g'
qqueuemv = !mv "`hg root`/.hg/patches-$1" "`hg root`/.hg/patches-$2"
In action:
$ hg echo foo
foo
$ hg count 'branch(default)'
901
$ hg count 'branch(stable) and keyword(fixes)'
102
$ hg qqueuemv myfeature somefeature
author | Steve Losh <steve@stevelosh.com> |
---|---|
date | Wed, 18 Aug 2010 18:56:44 -0400 |
parents | 92342fa9fbd8 |
children |
line wrap: on
line source
1 files updated, 0 files merged, 0 files removed, 0 files unresolved @ 3 P1 tags: f2.patch qtip tip | o 2 P0 tags: f.patch qbase | | o 1 R1 tags: |/ o 0 C1 tags: qparent % Rebase - try to rebase on an applied mq patch abort: cannot rebase onto an applied mq patch % Rebase - same thing, but mq patch is default dest abort: cannot rebase onto an applied mq patch % Rebase - generate a conflict merging f warning: conflicts during merge. merging f failed! abort: fix unresolved conflicts with hg resolve then run hg rebase --continue % Fix the 1st conflict warning: conflicts during merge. merging f failed! abort: fix unresolved conflicts with hg resolve then run hg rebase --continue merging f % Fix the 2nd conflict saved backup bundle to @ 3 P1 tags: f2.patch qtip tip | o 2 P0 tags: f.patch qbase | o 1 R1 tags: qparent | o 0 C1 tags: % Update to qbase 1 files updated, 0 files merged, 0 files removed, 0 files unresolved % f correctly reflects the merge result mq1r1 % And the patch is correct # HG changeset patch # User test # Date # Node ID # Parent P0 diff -r x -r y f --- a/f +++ b/f @@ -1,1 +1,1 @@ -r1 +mq1r1 % Update to qtip 1 files updated, 0 files merged, 0 files removed, 0 files unresolved % f correctly reflects the merge result mq1r1mq2 % And the patch is correct # HG changeset patch # User test # Date # Node ID # Parent P1 diff -r x -r y f --- a/f +++ b/f @@ -1,1 +1,1 @@ -mq1r1 +mq1r1mq2 % Adding one git-style patch and one normal popping f2.patch popping f.patch patch queue now empty 1 files updated, 0 files merged, 0 files removed, 0 files unresolved % patch series step 1/2 f_git.patch: P0 (git) f.patch: P1 % patch queue manifest step 1/2 .hgignore f.patch f_git.patch series % Git patch P0 (git) diff --git a/p b/p new file mode 100644 --- /dev/null +++ b/p @@ -0,0 +1,1 @@ +mq1 % Normal patch P1 diff -r x p --- a/p +++ b/p @@ -1,1 +1,1 @@ -mq1 +mq2 % Rebase the applied mq patches % patch series step 2/2 f_git.patch: P0 (git) f.patch: P1 % patch queue manifest step 2/2 .hgignore f.patch f_git.patch series % And the patches are correct % Git patch # HG changeset patch # User test # Date # Node ID # Parent P0 (git) diff --git a/p b/p new file mode 100644 --- /dev/null +++ b/p @@ -0,0 +1,1 @@ +mq1 % Normal patch # HG changeset patch # User test # Date # Node ID # Parent P1 --- a/p +++ b/p @@ -1,1 +1,1 @@ -mq1 +mq2