annotate tests/test-rebase-rename @ 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 2313dc4d9817
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7954
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
1 #!/bin/sh
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
2
11208
2313dc4d9817 tests: fix bashism to load helpers.sh
Yuya Nishihara <yuya@tcha.org>
parents: 11198
diff changeset
3 . $TESTDIR/helpers.sh
11198
b345b1cc124f rebase: use helpers.sh in tests
Matt Mackall <mpm@selenic.com>
parents: 7954
diff changeset
4
7954
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
5 echo "[extensions]" >> $HGRCPATH
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
6 echo "rebase=" >> $HGRCPATH
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
7 echo "[diff]" >> $HGRCPATH
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
8 echo "git=1" >> $HGRCPATH
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
9
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
10 BASE=`pwd`
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
11
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
12 hg init repo1
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
13 cd repo1
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
14 echo "a">a
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
15 hg commit -Am "A" --date '0 0'
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
16 echo "b"> b
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
17 hg commit -Am "B" --date '1 0'
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
18 hg up -C 0
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
19 hg mv a a-renamed
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
20 hg commit -m 'rename A' --date '2 0'
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
21
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
22 echo
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
23 echo '% Rename is tracked'
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
24 hg log -p -r tip --template '{rev}:{desc}\n'
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
25
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
26 echo '% Rebase the revision containing the rename'
11198
b345b1cc124f rebase: use helpers.sh in tests
Matt Mackall <mpm@selenic.com>
parents: 7954
diff changeset
27 hg rebase -s 2 -d 1 --quiet | cleanrebase
7954
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
28
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
29 echo
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
30 echo '% Rename is not lost'
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
31 hg log -p -r tip --template '{rev}:{desc}\n'
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
32
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
33 cd $BASE
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
34 rm -rf repo1
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
35 hg init repo1
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
36 cd repo1
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
37 echo "a">a
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
38 hg commit -Am "A" --date '0 0'
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
39 echo "b"> b
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
40 hg commit -Am "B" --date '1 0'
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
41 hg up -C 0
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
42 hg cp a a-copied
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
43 hg commit -m 'copy A' --date '2 0'
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
44
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
45 echo
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
46 echo '% Copy is tracked'
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
47 hg log -p -r tip --template '{rev}:{desc}\n'
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
48
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
49 echo '% Rebase the revision containing the copy'
11198
b345b1cc124f rebase: use helpers.sh in tests
Matt Mackall <mpm@selenic.com>
parents: 7954
diff changeset
50 hg rebase -s 2 -d 1 --quiet | cleanrebase
7954
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
51
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
52 echo
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
53 echo '% Copy is not lost'
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
54 hg log -p -r tip --template '{rev}:{desc}\n'
b969611064ae rebase: don't lose rename/copy data (Issue1423)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
55