##// END OF EJS Templates
dispatch: protect against malicious 'hg serve --stdio' invocations (sec)...
dispatch: protect against malicious 'hg serve --stdio' invocations (sec) Some shared-ssh installations assume that 'hg serve --stdio' is a safe command to run for minimally trusted users. Unfortunately, the messy implementation of argument parsing here meant that trying to access a repo named '--debugger' would give the user a pdb prompt, thereby sidestepping any hoped-for sandboxing. Serving repositories over HTTP(S) is unaffected. We're not currently hardening any subcommands other than 'serve'. If your service exposes other commands to users with arbitrary repository names, it is imperative that you defend against repository names of '--debugger' and anything starting with '--config'. The read-only mode of hg-ssh stopped working because it provided its hook configuration to "hg serve --stdio" via --config parameter. This is banned for security reasons now. This patch switches it to directly call ui.setconfig(). If your custom hosting infrastructure relies on passing --config to "hg serve --stdio", you'll need to find a different way to get that configuration into Mercurial, either by using ui.setconfig() as hg-ssh does in this patch, or by placing an hgrc file someplace where Mercurial will read it. mitrandir@fb.com provided some extra fixes for the dispatch code and for hg-ssh in places that I overlooked.

File last commit:

r26812:58a309e9 default
r32050:77eaf953 4.1.3 stable
Show More
test-convert-splicemap.t
241 lines | 6.4 KiB | text/troff | Tads3Lexer
/ tests / test-convert-splicemap.t
Matt Mackall
tests: unify test-convert-splicemap
r12531
$ echo "[extensions]" >> $HGRCPATH
$ echo "convert=" >> $HGRCPATH
$ glog()
> {
Martin Geisler
tests: don't load unnecessary graphlog extension...
r20117 > hg log -G --template '{rev}:{node|short} "{desc|firstline}"\
Patrick Mezard
convert: use splicemap entries when sorting revisions (issue1748)...
r16106 > files: {files}\n' "$@"
Matt Mackall
tests: unify test-convert-splicemap
r12531 > }
$ hg init repo1
$ cd repo1
$ echo a > a
$ hg ci -Am adda
adding a
$ echo b > b
$ echo a >> a
$ hg ci -Am addb
adding b
$ PARENTID1=`hg id --debug -i`
$ echo c > c
$ hg ci -Am addc
adding c
$ PARENTID2=`hg id --debug -i`
$ cd ..
Patrick Mezard
convert: use splicemap entries when sorting revisions (issue1748)...
r16106 $ glog -R repo1
@ 2:e55c719b85b6 "addc" files: c
|
o 1:6d4c2037ddc2 "addb" files: a b
|
o 0:07f494440405 "adda" files: a
Matt Mackall
tests: unify test-convert-splicemap
r12531 $ hg init repo2
$ cd repo2
$ echo b > a
$ echo d > d
$ hg ci -Am addaandd
adding a
adding d
Ben Goswami
splicemap: improve error handling when source is hg (issue2084)...
r19120 $ INVALIDID1=afd12345af
$ INVALIDID2=28173x36ddd1e67bf7098d541130558ef5534a86
Matt Mackall
tests: unify test-convert-splicemap
r12531 $ CHILDID1=`hg id --debug -i`
$ echo d >> d
$ hg ci -Am changed
$ CHILDID2=`hg id --debug -i`
$ echo e > e
$ hg ci -Am adde
adding e
$ cd ..
Patrick Mezard
convert: use splicemap entries when sorting revisions (issue1748)...
r16106 $ glog -R repo2
@ 2:a39b65753b0a "adde" files: e
|
o 1:e4ea00df9189 "changed" files: d
|
o 0:527cdedf31fb "addaandd" files: a d
Matt Mackall
tests: unify test-convert-splicemap
r12531
Ben Goswami
splicemap: improve error handling when source is hg (issue2084)...
r19120 test invalid splicemap1
Matt Mackall
tests: unify test-convert-splicemap
r12531
$ cat > splicemap <<EOF
> $CHILDID2
> EOF
$ hg convert --splicemap splicemap repo2 repo1
Patrick Mezard
convert: turn splicemap into a simple dictionary...
r16105 abort: syntax error in splicemap(1): child parent1[,parent2] expected
Matt Mackall
tests: unify test-convert-splicemap
r12531 [255]
Ben Goswami
splicemap: improve error handling when source is hg (issue2084)...
r19120 test invalid splicemap2
$ cat > splicemap <<EOF
> $CHILDID2 $PARENTID1, $PARENTID2, $PARENTID2
> EOF
$ hg convert --splicemap splicemap repo2 repo1
abort: syntax error in splicemap(1): child parent1[,parent2] expected
[255]
test invalid splicemap3
$ cat > splicemap <<EOF
> $INVALIDID1 $INVALIDID2
> EOF
$ hg convert --splicemap splicemap repo2 repo1
abort: splicemap entry afd12345af is not a valid revision identifier
[255]
Matt Mackall
tests: unify test-convert-splicemap
r12531 splice repo2 on repo1
$ cat > splicemap <<EOF
Patrick Mezard
convert: use splicemap entries when sorting revisions (issue1748)...
r16106 > $CHILDID1 $PARENTID1
Matt Mackall
tests: unify test-convert-splicemap
r12531 > $CHILDID2 $PARENTID2,$CHILDID1
Patrick Mezard
convert: ignore blank lines in mapfiles (issue3286)
r16190 >
Matt Mackall
tests: unify test-convert-splicemap
r12531 > EOF
Patrick Mezard
convert: use splicemap entries when sorting revisions (issue1748)...
r16106 $ cat splicemap
527cdedf31fbd5ea708aa14eeecf53d4676f38db 6d4c2037ddc2cb2627ac3a244ecce35283268f8e
e4ea00df91897da3079a10fab658c1eddba6617b e55c719b85b60e5102fac26110ba626e7cb6b7dc,527cdedf31fbd5ea708aa14eeecf53d4676f38db
Patrick Mezard
convert: ignore blank lines in mapfiles (issue3286)
r16190
Matt Mackall
tests: unify test-convert-splicemap
r12531 $ hg clone repo1 target1
updating to branch default
3 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg convert --splicemap splicemap repo2 target1
scanning source...
sorting...
converting...
2 addaandd
Mads Kiilerich
convert: fix Python syntax in 'splice in' message...
r26812 spliced in 6d4c2037ddc2cb2627ac3a244ecce35283268f8e as parents of 527cdedf31fbd5ea708aa14eeecf53d4676f38db
Matt Mackall
tests: unify test-convert-splicemap
r12531 1 changed
Mads Kiilerich
convert: fix Python syntax in 'splice in' message...
r26812 spliced in e55c719b85b60e5102fac26110ba626e7cb6b7dc and 527cdedf31fbd5ea708aa14eeecf53d4676f38db as parents of e4ea00df91897da3079a10fab658c1eddba6617b
Matt Mackall
tests: unify test-convert-splicemap
r12531 0 adde
$ glog -R target1
Patrick Mezard
convert: use splicemap entries when sorting revisions (issue1748)...
r16106 o 5:16bc847b02aa "adde" files: e
|
o 4:e30e4fee3418 "changed" files: d
|\
| o 3:e673348c3a3c "addaandd" files: a d
| |
@ | 2:e55c719b85b6 "addc" files: c
|/
o 1:6d4c2037ddc2 "addb" files: a b
Matt Mackall
tests: unify test-convert-splicemap
r12531 |
Patrick Mezard
convert: use splicemap entries when sorting revisions (issue1748)...
r16106 o 0:07f494440405 "adda" files: a
Test splicemap and conversion order
$ hg init ordered
$ cd ordered
$ echo a > a
$ hg ci -Am adda
adding a
$ hg branch branch
marked working directory as branch branch
(branches are permanent and global, did you want a bookmark?)
$ echo a >> a
$ hg ci -Am changea
$ echo a >> a
$ hg ci -Am changeaagain
$ hg up 0
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ echo b > b
$ hg ci -Am addb
adding b
We want 2 to depend on 1 and 3. Since 3 is always converted after 2,
the bug should be exhibited with all conversion orders.
$ cat > ../splicemap <<EOF
Mads Kiilerich
tests: fix bashism in test-convert-splicemap.t...
r16480 > `(hg id -r 2 -i --debug)` `(hg id -r 1 -i --debug)`, `(hg id -r 3 -i --debug)`
Patrick Mezard
convert: use splicemap entries when sorting revisions (issue1748)...
r16106 > EOF
$ cd ..
$ cat splicemap
Patrick Mezard
convert: tolerate spaces between splicemap parent ids (issue3203)...
r16118 7c364e7fa7d70ae525610c016317ed717b519d97 717d54d67e6c31fd75ffef2ff3042bdd98418437, 102a90ea7b4a3361e4082ed620918c261189a36a
Patrick Mezard
convert: use splicemap entries when sorting revisions (issue1748)...
r16106
Test regular conversion
$ hg convert --splicemap splicemap ordered ordered-hg1
initializing destination ordered-hg1 repository
scanning source...
sorting...
converting...
3 adda
2 changea
1 addb
0 changeaagain
Mads Kiilerich
convert: fix Python syntax in 'splice in' message...
r26812 spliced in 717d54d67e6c31fd75ffef2ff3042bdd98418437 and 102a90ea7b4a3361e4082ed620918c261189a36a as parents of 7c364e7fa7d70ae525610c016317ed717b519d97
Patrick Mezard
convert: use splicemap entries when sorting revisions (issue1748)...
r16106 $ glog -R ordered-hg1
o 3:4cb04b9afbf2 "changeaagain" files: a
Matt Mackall
tests: unify test-convert-splicemap
r12531 |\
Patrick Mezard
convert: use splicemap entries when sorting revisions (issue1748)...
r16106 | o 2:102a90ea7b4a "addb" files: b
Matt Mackall
tests: unify test-convert-splicemap
r12531 | |
Patrick Mezard
convert: use splicemap entries when sorting revisions (issue1748)...
r16106 o | 1:717d54d67e6c "changea" files: a
Matt Mackall
tests: unify test-convert-splicemap
r12531 |/
Patrick Mezard
convert: use splicemap entries when sorting revisions (issue1748)...
r16106 o 0:07f494440405 "adda" files: a
Matt Mackall
tests: unify test-convert-splicemap
r12531
Patrick Mezard
convert: use splicemap entries when sorting revisions (issue1748)...
r16106
Test conversion with parent revisions already in dest, using source
and destination identifiers. Test unknown splicemap target.
$ hg convert -r1 ordered ordered-hg2
initializing destination ordered-hg2 repository
scanning source...
sorting...
converting...
1 adda
0 changea
$ hg convert -r3 ordered ordered-hg2
scanning source...
sorting...
converting...
0 addb
$ cat > splicemap <<EOF
Mads Kiilerich
tests: fix bashism in test-convert-splicemap.t...
r16480 > `(hg -R ordered id -r 2 -i --debug)` \
> `(hg -R ordered-hg2 id -r 1 -i --debug)`,\
> `(hg -R ordered-hg2 id -r 2 -i --debug)`
Patrick Mezard
convert: use splicemap entries when sorting revisions (issue1748)...
r16106 > deadbeef102a90ea7b4a3361e4082ed620918c26 deadbeef102a90ea7b4a3361e4082ed620918c27
> EOF
$ hg convert --splicemap splicemap ordered ordered-hg2
scanning source...
splice map revision deadbeef102a90ea7b4a3361e4082ed620918c26 is not being converted, ignoring
sorting...
converting...
0 changeaagain
Mads Kiilerich
convert: fix Python syntax in 'splice in' message...
r26812 spliced in 717d54d67e6c31fd75ffef2ff3042bdd98418437 and 102a90ea7b4a3361e4082ed620918c261189a36a as parents of 7c364e7fa7d70ae525610c016317ed717b519d97
Patrick Mezard
convert: use splicemap entries when sorting revisions (issue1748)...
r16106 $ glog -R ordered-hg2
o 3:4cb04b9afbf2 "changeaagain" files: a
|\
| o 2:102a90ea7b4a "addb" files: b
| |
o | 1:717d54d67e6c "changea" files: a
|/
o 0:07f494440405 "adda" files: a
Test empty conversion
$ hg convert --splicemap splicemap ordered ordered-hg2
scanning source...
splice map revision deadbeef102a90ea7b4a3361e4082ed620918c26 is not being converted, ignoring
sorting...
converting...
Test clonebranches
$ hg --config convert.hg.clonebranches=true convert \
> --splicemap splicemap ordered ordered-hg3
initializing destination ordered-hg3 repository
scanning source...
Wagner Bruna
convert: fix typos in error messages
r16162 abort: revision 717d54d67e6c31fd75ffef2ff3042bdd98418437 not found in destination repository (lookups with clonebranches=true are not implemented)
Patrick Mezard
convert: use splicemap entries when sorting revisions (issue1748)...
r16106 [255]
Test invalid dependency
$ cat > splicemap <<EOF
Mads Kiilerich
tests: fix bashism in test-convert-splicemap.t...
r16480 > `(hg -R ordered id -r 2 -i --debug)` \
Patrick Mezard
convert: use splicemap entries when sorting revisions (issue1748)...
r16106 > deadbeef102a90ea7b4a3361e4082ed620918c26,\
Mads Kiilerich
tests: fix bashism in test-convert-splicemap.t...
r16480 > `(hg -R ordered-hg2 id -r 2 -i --debug)`
Patrick Mezard
convert: use splicemap entries when sorting revisions (issue1748)...
r16106 > EOF
$ hg convert --splicemap splicemap ordered ordered-hg4
initializing destination ordered-hg4 repository
scanning source...
abort: unknown splice map parent: deadbeef102a90ea7b4a3361e4082ed620918c26
[255]