##// 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:

r31056:37ab9e20 default
r32050:77eaf953 4.1.3 stable
Show More
test-histedit-edit.t
482 lines | 11.8 KiB | text/troff | Tads3Lexer
/ tests / test-histedit-edit.t
Mads Kiilerich
tests: convert histedit tests to .t...
r17085 $ . "$TESTDIR/histedit-helpers.sh"
$ cat >> $HGRCPATH <<EOF
> [extensions]
> histedit=
Mateusz Kwapich
histedit: don't allow to strip nodes which are necessary to continue histedit...
r24111 > strip=
Mads Kiilerich
tests: convert histedit tests to .t...
r17085 > EOF
$ initrepo ()
> {
> hg init r
> cd r
Mateusz Kwapich
histedit: add --edit-plan option to histedit...
r24142 > for x in a b c d e f g; do
Mads Kiilerich
tests: convert histedit tests to .t...
r17085 > echo $x > $x
> hg add $x
> hg ci -m $x
> done
> }
$ initrepo
log before edit
$ hg log --graph
Mateusz Kwapich
histedit: add --edit-plan option to histedit...
r24142 @ changeset: 6:3c6a8ed2ebe8
Mads Kiilerich
tests: convert histedit tests to .t...
r17085 | tag: tip
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
Mateusz Kwapich
histedit: add --edit-plan option to histedit...
r24142 | summary: g
|
o changeset: 5:652413bf663e
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
Mads Kiilerich
tests: convert histedit tests to .t...
r17085 | summary: f
|
o changeset: 4:e860deea161a
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
| summary: e
|
o changeset: 3:055a42cdd887
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
| summary: d
|
o changeset: 2:177f92b77385
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
| summary: c
|
o changeset: 1:d2ae7f538514
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
| summary: b
|
o changeset: 0:cb9a9f314b8b
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: a
timeless
test-histedit-edit: test histedit with dirty repo
r27544 dirty a file
$ echo a > g
$ hg histedit 177f92b77385 --commands - 2>&1 << EOF
> EOF
abort: uncommitted changes
[255]
$ echo g > g
Mads Kiilerich
tests: convert histedit tests to .t...
r17085
edit the history
Pierre-Yves David
histedit-test: generalise --commands "-" usage...
r19019 $ hg histedit 177f92b77385 --commands - 2>&1 << EOF| fixbundle
> pick 177f92b77385 c
> pick 055a42cdd887 d
> edit e860deea161a e
> pick 652413bf663e f
Mateusz Kwapich
histedit: add --edit-plan option to histedit...
r24142 > pick 3c6a8ed2ebe8 g
Pierre-Yves David
histedit-test: generalise --commands "-" usage...
r19019 > EOF
Mateusz Kwapich
histedit: add --edit-plan option to histedit...
r24142 0 files updated, 0 files merged, 3 files removed, 0 files unresolved
timeless
histedit: list action when intervention is required
r27629 Editing (e860deea161a), you may commit or record as needed now.
(hg histedit --continue to resume)
Mads Kiilerich
tests: convert histedit tests to .t...
r17085
Jason Gauci
tests: ensure that 'hg update' is disabled during histedit (issue3655)
r28890 try to update and get an error
$ hg update tip
abort: histedit in progress
(use 'hg histedit --continue' or 'hg histedit --abort')
[255]
Durham Goode
histedit: fix --edit-plan...
r24920 edit the plan via the editor
Durham Goode
histedit: fix test-histedit-edit on vfat...
r24933 $ cat >> $TESTTMP/editplan.sh <<EOF
Durham Goode
histedit: fix --edit-plan...
r24920 > cat > \$1 <<EOF2
> drop e860deea161a e
> drop 652413bf663e f
> drop 3c6a8ed2ebe8 g
> EOF2
> EOF
Durham Goode
histedit: fix test-histedit-edit on vfat...
r24933 $ HGEDITOR="sh $TESTTMP/editplan.sh" hg histedit --edit-plan
Durham Goode
histedit: fix --edit-plan...
r24920 $ cat .hg/histedit-state
v1
055a42cdd88768532f9cf79daa407fc8d138de9b
3c6a8ed2ebe862cc949d2caa30775dd6f16fb799
False
3
drop
e860deea161a2f77de56603b340ebbb4536308ae
drop
652413bf663ef2a641cab26574e46d5f5a64a55a
drop
3c6a8ed2ebe862cc949d2caa30775dd6f16fb799
0
strip-backup/177f92b77385-0ebe6a8f-histedit.hg
edit the plan via --commands
Mateusz Kwapich
histedit: add --edit-plan option to histedit...
r24142 $ hg histedit --edit-plan --commands - 2>&1 << EOF
> edit e860deea161a e
> pick 652413bf663e f
> drop 3c6a8ed2ebe8 g
> EOF
Durham Goode
histedit: fix --edit-plan...
r24920 $ cat .hg/histedit-state
v1
055a42cdd88768532f9cf79daa407fc8d138de9b
3c6a8ed2ebe862cc949d2caa30775dd6f16fb799
False
3
edit
e860deea161a2f77de56603b340ebbb4536308ae
pick
652413bf663ef2a641cab26574e46d5f5a64a55a
drop
3c6a8ed2ebe862cc949d2caa30775dd6f16fb799
0
strip-backup/177f92b77385-0ebe6a8f-histedit.hg
Mateusz Kwapich
histedit: add --edit-plan option to histedit...
r24142
Pierre-Yves David
histedit: simplify computation of `newchildren` during --continue...
r17749 Go at a random point and try to continue
$ hg id -n
3+
$ hg up 0
Matt Mackall
histedit: add checkunfinished support (issue3955)...
r19479 abort: histedit in progress
(use 'hg histedit --continue' or 'hg histedit --abort')
Pierre-Yves David
histedit: simplify computation of `newchildren` during --continue...
r17749 [255]
Mateusz Kwapich
histedit: don't allow to strip nodes which are necessary to continue histedit...
r24111 Try to delete necessary commit
Durham Goode
histedit: fix preventing strips during histedit...
r24626 $ hg strip -r 652413b
abort: histedit in progress, can't strip 652413bf663e
Mateusz Kwapich
histedit: don't allow to strip nodes which are necessary to continue histedit...
r24111 [255]
Matt Mackall
checkunfinished: accommodate histedit quirk...
r19496 commit, then edit the revision
$ hg ci -m 'wat'
Mads Kiilerich
tests: convert histedit tests to .t...
r17085 created new head
$ echo a > e
Augie Fackler
test-histedit-edit.t: demonstrate qnew fails during a histedit (issue4366)...
r24299
qnew should fail while we're in the middle of the edit step
$ hg --config extensions.mq= qnew please-fail
abort: histedit in progress
(use 'hg histedit --continue' or 'hg histedit --abort')
[255]
Mads Kiilerich
tests: make histedit pass on Windows MSYS...
r17087 $ HGEDITOR='echo foobaz > ' hg histedit --continue 2>&1 | fixbundle
Mads Kiilerich
tests: convert histedit tests to .t...
r17085
$ hg log --graph
Pierre-Yves David
histedit: record histedit source (issue3681)...
r18437 @ changeset: 6:b5f70786f9b0
Mads Kiilerich
tests: convert histedit tests to .t...
r17085 | tag: tip
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
| summary: f
|
Pierre-Yves David
histedit: record histedit source (issue3681)...
r18437 o changeset: 5:a5e1ba2f7afb
Mads Kiilerich
tests: convert histedit tests to .t...
r17085 | user: test
| date: Thu Jan 01 00:00:00 1970 +0000
| summary: foobaz
|
o changeset: 4:1a60820cd1f6
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
| summary: wat
|
o changeset: 3:055a42cdd887
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
| summary: d
|
o changeset: 2:177f92b77385
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
| summary: c
|
o changeset: 1:d2ae7f538514
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
| summary: b
|
o changeset: 0:cb9a9f314b8b
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: a
$ hg cat e
a
Durham Goode
histedit: store backup file before histedit...
r24757 Stripping necessary commits should not break --abort
$ hg histedit 1a60820cd1f6 --commands - 2>&1 << EOF| fixbundle
> edit 1a60820cd1f6 wat
> pick a5e1ba2f7afb foobaz
> pick b5f70786f9b0 g
> EOF
0 files updated, 0 files merged, 2 files removed, 0 files unresolved
timeless
histedit: list action when intervention is required
r27629 Editing (1a60820cd1f6), you may commit or record as needed now.
(hg histedit --continue to resume)
Durham Goode
histedit: store backup file before histedit...
r24757
$ mv .hg/histedit-state .hg/histedit-state.bak
$ hg strip -q -r b5f70786f9b0
$ mv .hg/histedit-state.bak .hg/histedit-state
$ hg histedit --abort
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 3 files
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg log -r .
changeset: 6:b5f70786f9b0
tag: tip
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: f
Pierre-Yves David
histedit: record histedit source (issue3681)...
r18437 check histedit_source
$ hg log --debug --rev 5
changeset: 5:a5e1ba2f7afb899ef1581cea528fd885d2fca70d
phase: draft
parent: 4:1a60820cd1f6004a362aa622ebc47d59bc48eb34
parent: -1:0000000000000000000000000000000000000000
manifest: 5:5ad3be8791f39117565557781f5464363b918a45
user: test
date: Thu Jan 01 00:00:00 1970 +0000
files: e
extra: branch=default
extra: histedit_source=e860deea161a2f77de56603b340ebbb4536308ae
description:
foobaz
Pierre-Yves David
histedit-test: generalise --commands "-" usage...
r19019 $ hg histedit tip --commands - 2>&1 <<EOF| fixbundle
Pierre-Yves David
histedit: record histedit source (issue3681)...
r18437 > edit b5f70786f9b0 f
Mads Kiilerich
tests: convert histedit tests to .t...
r17085 > EOF
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
timeless
histedit: list action when intervention is required
r27629 Editing (b5f70786f9b0), you may commit or record as needed now.
(hg histedit --continue to resume)
Mads Kiilerich
tests: convert histedit tests to .t...
r17085 $ hg status
A f
Bryan O'Sullivan
summary: add tests for some extensions we plan to modify
r19213
$ hg summary
parent: 5:a5e1ba2f7afb
foobaz
branch: default
commit: 1 added (new branch head)
update: 1 new changesets (update)
Gilles Moris
summary: move the parents phase marker to commit line (issue4688)...
r25382 phases: 7 draft
Bryan O'Sullivan
summary: add a histedit hook
r19215 hist: 1 remaining (histedit --continue)
Bryan O'Sullivan
summary: add tests for some extensions we plan to modify
r19213
FUJIWARA Katsunori
histedit: use "getcommiteditor()" instead of explicit editor choice for "--continue"...
r21409 (test also that editor is invoked if histedit is continued for
"edit" action)
$ HGEDITOR='cat' hg histedit --continue
f
HG: Enter commit message. Lines beginning with 'HG:' are removed.
HG: Leave message empty to abort commit.
HG: --
HG: user: test
HG: branch 'default'
HG: added f
Durham Goode
bundles: do not overwrite existing backup bundles (BC)...
r23835 saved backup bundle to $TESTTMP/r/.hg/strip-backup/b5f70786f9b0-c28d9c86-backup.hg (glob)
Pierre-Yves David
histedit: record histedit source (issue3681)...
r18437
Mads Kiilerich
tests: convert histedit tests to .t...
r17085 $ hg status
log after edit
$ hg log --limit 1
Pierre-Yves David
histedit: record histedit source (issue3681)...
r18437 changeset: 6:a107ee126658
Mads Kiilerich
tests: convert histedit tests to .t...
r17085 tag: tip
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: f
say we'll change the message, but don't.
$ cat > ../edit.sh <<EOF
Mads Kiilerich
tests: make histedit tests more resilient to filesystem variation...
r17086 > cat "\$1" | sed s/pick/mess/ > tmp
> mv tmp "\$1"
Mads Kiilerich
tests: convert histedit tests to .t...
r17085 > EOF
Mads Kiilerich
tests: make histedit tests more resilient to filesystem variation...
r17086 $ HGEDITOR="sh ../edit.sh" hg histedit tip 2>&1 | fixbundle
Mads Kiilerich
tests: convert histedit tests to .t...
r17085 $ hg status
$ hg log --limit 1
Pierre-Yves David
histedit: record histedit source (issue3681)...
r18437 changeset: 6:1fd3b2fe7754
Mads Kiilerich
tests: convert histedit tests to .t...
r17085 tag: tip
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: f
modify the message
FUJIWARA Katsunori
histedit: save manually edited commit message into ".hg/last-message.txt"...
r21028
check saving last-message.txt, at first
$ cat > $TESTTMP/commitfailure.py <<EOF
Pierre-Yves David
error: get Abort from 'error' instead of 'util'...
r26587 > from mercurial import error
FUJIWARA Katsunori
histedit: save manually edited commit message into ".hg/last-message.txt"...
r21028 > def reposetup(ui, repo):
> class commitfailure(repo.__class__):
> def commit(self, *args, **kwargs):
Pierre-Yves David
error: get Abort from 'error' instead of 'util'...
r26587 > raise error.Abort('emulating unexpected abort')
FUJIWARA Katsunori
histedit: save manually edited commit message into ".hg/last-message.txt"...
r21028 > repo.__class__ = commitfailure
> EOF
FUJIWARA Katsunori
histedit: use "editor" argument of "commit()" instead of explicit "ui.edit()"...
r21233 $ cat >> .hg/hgrc <<EOF
FUJIWARA Katsunori
histedit: save manually edited commit message into ".hg/last-message.txt"...
r21028 > [extensions]
FUJIWARA Katsunori
histedit: use "editor" argument of "commit()" instead of explicit "ui.edit()"...
r21233 > # this failure occurs before editor invocation
FUJIWARA Katsunori
histedit: save manually edited commit message into ".hg/last-message.txt"...
r21028 > commitfailure = $TESTTMP/commitfailure.py
> EOF
$ cat > $TESTTMP/editor.sh <<EOF
> echo "==== before editing"
> cat \$1
> echo "===="
> echo "check saving last-message.txt" >> \$1
> EOF
FUJIWARA Katsunori
histedit: use "editor" argument of "commit()" instead of explicit "ui.edit()"...
r21233
(test that editor is not invoked before transaction starting)
$ rm -f .hg/last-message.txt
$ HGEDITOR="sh $TESTTMP/editor.sh" hg histedit tip --commands - 2>&1 << EOF | fixbundle
> mess 1fd3b2fe7754 f
> EOF
abort: emulating unexpected abort
Danek Duvall
tests: cat error messages are different on Solaris
r21930 $ test -f .hg/last-message.txt
FUJIWARA Katsunori
histedit: use "editor" argument of "commit()" instead of explicit "ui.edit()"...
r21233 [1]
$ cat >> .hg/hgrc <<EOF
> [extensions]
> commitfailure = !
> EOF
$ hg histedit --abort -q
(test that editor is invoked and commit message is saved into
"last-message.txt")
$ cat >> .hg/hgrc <<EOF
> [hooks]
> # this failure occurs after editor invocation
> pretxncommit.unexpectedabort = false
> EOF
FUJIWARA Katsunori
histedit: use the editor gotten by "getcommiteditor()" for "message"...
r21407 $ hg status --rev '1fd3b2fe7754^1' --rev 1fd3b2fe7754
A f
FUJIWARA Katsunori
histedit: save manually edited commit message into ".hg/last-message.txt"...
r21028 $ rm -f .hg/last-message.txt
FUJIWARA Katsunori
histedit: use the editor gotten by "getcommiteditor()" for "message"...
r21407 $ HGEDITOR="sh $TESTTMP/editor.sh" hg histedit tip --commands - 2>&1 << EOF
FUJIWARA Katsunori
histedit: save manually edited commit message into ".hg/last-message.txt"...
r21028 > mess 1fd3b2fe7754 f
> EOF
==== before editing
f
FUJIWARA Katsunori
histedit: use the editor gotten by "getcommiteditor()" for "message"...
r21407
HG: Enter commit message. Lines beginning with 'HG:' are removed.
HG: Leave message empty to abort commit.
HG: --
HG: user: test
HG: branch 'default'
HG: added f
FUJIWARA Katsunori
histedit: save manually edited commit message into ".hg/last-message.txt"...
r21028 ====
Laurent Charignon
localrepo: put bookmark move following commit in one transaction...
r26998 note: commit message saved in .hg/last-message.txt
FUJIWARA Katsunori
histedit: use "editor" argument of "commit()" instead of explicit "ui.edit()"...
r21233 transaction abort!
rollback completed
abort: pretxncommit.unexpectedabort hook exited with status 1
FUJIWARA Katsunori
histedit: use the editor gotten by "getcommiteditor()" for "message"...
r21407 [255]
FUJIWARA Katsunori
histedit: save manually edited commit message into ".hg/last-message.txt"...
r21028 $ cat .hg/last-message.txt
f
FUJIWARA Katsunori
histedit: use the editor gotten by "getcommiteditor()" for "message"...
r21407
FUJIWARA Katsunori
histedit: save manually edited commit message into ".hg/last-message.txt"...
r21028 check saving last-message.txt
FUJIWARA Katsunori
histedit: use "getcommiteditor()" instead of explicit editor choice for "--continue"...
r21409 (test also that editor is invoked if histedit is continued for "message"
action)
$ HGEDITOR=cat hg histedit --continue
f
HG: Enter commit message. Lines beginning with 'HG:' are removed.
HG: Leave message empty to abort commit.
HG: --
HG: user: test
HG: branch 'default'
HG: added f
Laurent Charignon
localrepo: put bookmark move following commit in one transaction...
r26998 note: commit message saved in .hg/last-message.txt
FUJIWARA Katsunori
histedit: use "getcommiteditor()" instead of explicit editor choice for "--continue"...
r21409 transaction abort!
rollback completed
abort: pretxncommit.unexpectedabort hook exited with status 1
[255]
FUJIWARA Katsunori
histedit: use "editor" argument of "commit()" instead of explicit "ui.edit()"...
r21233 $ cat >> .hg/hgrc <<EOF
> [hooks]
> pretxncommit.unexpectedabort =
FUJIWARA Katsunori
histedit: save manually edited commit message into ".hg/last-message.txt"...
r21028 > EOF
$ hg histedit --abort -q
then, check "modify the message" itself
Pierre-Yves David
histedit-test: generalise --commands "-" usage...
r19019 $ hg histedit tip --commands - 2>&1 << EOF | fixbundle
Pierre-Yves David
histedit: record histedit source (issue3681)...
r18437 > mess 1fd3b2fe7754 f
Mads Kiilerich
tests: convert histedit tests to .t...
r17085 > EOF
$ hg status
$ hg log --limit 1
Pierre-Yves David
histedit-test: generalise --commands "-" usage...
r19019 changeset: 6:62feedb1200e
Mads Kiilerich
tests: convert histedit tests to .t...
r17085 tag: tip
user: test
date: Thu Jan 01 00:00:00 1970 +0000
Pierre-Yves David
histedit-test: generalise --commands "-" usage...
r19019 summary: f
Mads Kiilerich
tests: convert histedit tests to .t...
r17085
rollback should not work after a histedit
$ hg rollback
no rollback information available
[1]
$ cd ..
Bryan O'Sullivan
histedit: support editing of the first commit (issue3767)
r18913 $ hg clone -qr0 r r0
$ cd r0
$ hg phase -fdr0
Pierre-Yves David
histedit-test: generalise --commands "-" usage...
r19019 $ hg histedit --commands - 0 2>&1 << EOF
> edit cb9a9f314b8b a > $EDITED
> EOF
Bryan O'Sullivan
histedit: support editing of the first commit (issue3767)
r18913 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
adding a
timeless
histedit: list action when intervention is required
r27629 Editing (cb9a9f314b8b), you may commit or record as needed now.
(hg histedit --continue to resume)
Matt Mackall
histedit: update tests for new intervention framework
r18942 [1]
Bryan O'Sullivan
histedit: support editing of the first commit (issue3767)
r18913 $ HGEDITOR=true hg histedit --continue
Durham Goode
bundles: do not overwrite existing backup bundles (BC)...
r23835 saved backup bundle to $TESTTMP/r0/.hg/strip-backup/cb9a9f314b8b-cc5ccb0b-backup.hg (glob)
Augie Fackler
test-histedit-edit: add test that demonstrates bug in issue4704...
r25451
$ hg log -G
@ changeset: 0:0efcea34f18a
tag: tip
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: a
$ echo foo >> b
$ hg addr
adding b
$ hg ci -m 'add b'
$ echo foo >> a
$ hg ci -m 'extend a'
$ hg phase --public 1
Attempting to fold a change into a public change should not work:
$ cat > ../edit.sh <<EOF
> cat "\$1" | sed s/pick/fold/ > tmp
> mv tmp "\$1"
> EOF
$ HGEDITOR="sh ../edit.sh" hg histedit 2
timeless
histedit: mention histedit-last-edit.txt on abort...
r27171 warning: histedit rules saved to: .hg/histedit-last-edit.txt
timeless
histedit: use parse-error exception for parsing
r27545 hg: parse error: cannot fold into public change 18aa70c8ad22
Augie Fackler
histedit: abort rather than edit a public changeset (issue4704)...
r25452 [255]
timeless
histedit: mention histedit-last-edit.txt on abort...
r27171 $ cat .hg/histedit-last-edit.txt
fold 0012be4a27ea 2 extend a
# Edit history between 0012be4a27ea and 0012be4a27ea
#
# Commits are listed from least to most recent
#
liscju
histedit: adds hint how to reorder changesets at editor (issue3766)
r28396 # You can reorder changesets by reordering the lines
#
timeless
histedit: mention histedit-last-edit.txt on abort...
r27171 # Commands:
timeless
histedit: prefer edit commit, edit message, use commit...
r27674 #
# e, edit = use commit, but stop for amending
# m, mess = edit commit message without changing commit content
timeless
histedit: mention histedit-last-edit.txt on abort...
r27171 # p, fold = use commit
timeless
histedit: prefer edit commit, edit message, use commit...
r27674 # d, drop = remove commit from history
timeless
histedit: mention histedit-last-edit.txt on abort...
r27171 # f, fold = use commit, but combine it with the one above
# r, roll = like fold, but discard this commit's description
#