##// END OF EJS Templates
pycompat: custom implementation of urllib.parse.quote()...
pycompat: custom implementation of urllib.parse.quote() urllib.parse.quote() accepts either str or bytes and returns str. There exists a urllib.parse.quote_from_bytes() which only accepts bytes. We should probably use that to retain strong typing and avoid surprises. In addition, since nearly all strings in Mercurial are bytes, we probably don't want quote() returning unicode. So, this patch implements a custom quote() that only accepts bytes and returns bytes. The quoted URL should only contain URL safe characters which is a strict subset of ASCII. So `.encode('ascii', 'strict')` should be safe.

File last commit:

r27629:e7ff83b2 default
r31400:fb1f7033 default
Show More
test-histedit-no-change.t
218 lines | 6.5 KiB | text/troff | Tads3Lexer
/ tests / test-histedit-no-change.t
Mads Kiilerich
tests: convert histedit tests to .t...
r17085 test for old histedit issue #6:
editing a changeset without any actual change would corrupt the repository
$ . "$TESTDIR/histedit-helpers.sh"
$ cat >> $HGRCPATH <<EOF
> [extensions]
> histedit=
> EOF
$ initrepo ()
> {
> dir="$1"
> comment="$2"
> if [ -n "${comment}" ]; then
> echo % ${comment}
> echo % ${comment} | sed 's:.:-:g'
> fi
> hg init ${dir}
> cd ${dir}
> for x in a b c d e f ; do
> echo $x > $x
> hg add $x
> hg ci -m $x
> done
> cd ..
> }
$ geneditor ()
> {
> # generate an editor script for selecting changesets to be edited
> choice=$1 # changesets that should be edited (using sed line ranges)
> cat <<EOF | sed 's:^....::'
> # editing the rules, replacing 'pick' with 'edit' for the chosen lines
Mads Kiilerich
tests: make histedit tests more resilient to filesystem variation...
r17086 > sed '${choice}s:^pick:edit:' "\$1" > "\${1}.tmp"
> mv "\${1}.tmp" "\$1"
Mads Kiilerich
tests: convert histedit tests to .t...
r17085 > # displaying the resulting rules, minus comments and empty lines
Mads Kiilerich
tests: make histedit tests more resilient to filesystem variation...
r17086 > sed '/^#/d;/^$/d;s:^:| :' "\$1" >&2
Mads Kiilerich
tests: convert histedit tests to .t...
r17085 > EOF
> }
$ startediting ()
> {
> # begin an editing session
> choice="$1" # changesets that should be edited
> number="$2" # number of changesets considered (from tip)
> comment="$3"
> geneditor "${choice}" > edit.sh
> echo % start editing the history ${comment}
Mads Kiilerich
tests: make histedit tests more resilient to filesystem variation...
r17086 > HGEDITOR="sh ./edit.sh" hg histedit -- -${number} 2>&1 | fixbundle
Mads Kiilerich
tests: convert histedit tests to .t...
r17085 > }
$ continueediting ()
> {
> # continue an edit already in progress
> editor="$1" # message editor when finalizing editing
> comment="$2"
> echo % finalize changeset editing ${comment}
> HGEDITOR=${editor} hg histedit --continue 2>&1 | fixbundle
> }
$ graphlog ()
> {
> comment="${1:-log}"
> echo % "${comment}"
Martin Geisler
tests: don't load unnecessary graphlog extension...
r20117 > hg log -G --template '{rev} {node} \"{desc|firstline}\"\n'
Mads Kiilerich
tests: convert histedit tests to .t...
r17085 > }
$ initrepo r1 "test editing with no change"
% test editing with no change
-----------------------------
$ cd r1
$ graphlog "log before editing"
% log before editing
@ 5 652413bf663ef2a641cab26574e46d5f5a64a55a "f"
|
o 4 e860deea161a2f77de56603b340ebbb4536308ae "e"
|
o 3 055a42cdd88768532f9cf79daa407fc8d138de9b "d"
|
o 2 177f92b773850b59254aa5e923436f921b55483b "c"
|
o 1 d2ae7f538514cd87c17547b0de4cea71fe1af9fb "b"
|
o 0 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b "a"
$ startediting 2 3 "(not changing anything)" # edit the 2nd of 3 changesets
% start editing the history (not changing anything)
| pick 055a42cdd887 3 d
| edit e860deea161a 4 e
| pick 652413bf663e 5 f
0 files updated, 0 files merged, 2 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 $ continueediting true "(leaving commit message unaltered)"
% finalize changeset editing (leaving commit message unaltered)
Pierre-Yves David
histedit: record histedit source (issue3681)...
r18437
Mads Kiilerich
tests: convert histedit tests to .t...
r17085
check state of working copy
$ hg id
Pierre-Yves David
histedit: record histedit source (issue3681)...
r18437 794fe033d0a0 tip
Mads Kiilerich
tests: convert histedit tests to .t...
r17085
$ graphlog "log after history editing"
% log after history editing
Pierre-Yves David
histedit: record histedit source (issue3681)...
r18437 @ 5 794fe033d0a030f8df77c5de945fca35c9181c30 "f"
Mads Kiilerich
tests: convert histedit tests to .t...
r17085 |
Pierre-Yves David
histedit: record histedit source (issue3681)...
r18437 o 4 04d2fab980779f332dec458cc944f28de8b43435 "e"
Mads Kiilerich
tests: convert histedit tests to .t...
r17085 |
o 3 055a42cdd88768532f9cf79daa407fc8d138de9b "d"
|
o 2 177f92b773850b59254aa5e923436f921b55483b "c"
|
o 1 d2ae7f538514cd87c17547b0de4cea71fe1af9fb "b"
|
o 0 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b "a"
$ cd ..
$ initrepo r2 "test editing with no change, then abort"
% test editing with no change, then abort
-----------------------------------------
$ cd r2
$ graphlog "log before editing"
% log before editing
@ 5 652413bf663ef2a641cab26574e46d5f5a64a55a "f"
|
o 4 e860deea161a2f77de56603b340ebbb4536308ae "e"
|
o 3 055a42cdd88768532f9cf79daa407fc8d138de9b "d"
|
o 2 177f92b773850b59254aa5e923436f921b55483b "c"
|
o 1 d2ae7f538514cd87c17547b0de4cea71fe1af9fb "b"
|
o 0 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b "a"
$ startediting 1,2 3 "(not changing anything)" # edit the 1st two of 3 changesets
% start editing the history (not changing anything)
| edit 055a42cdd887 3 d
| edit e860deea161a 4 e
| pick 652413bf663e 5 f
0 files updated, 0 files merged, 3 files removed, 0 files unresolved
timeless
histedit: list action when intervention is required
r27629 Editing (055a42cdd887), you may commit or record as needed now.
(hg histedit --continue to resume)
Mads Kiilerich
tests: convert histedit tests to .t...
r17085 $ continueediting true "(leaving commit message unaltered)"
% finalize changeset editing (leaving commit message unaltered)
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 $ graphlog "log after first edit"
% log after first edit
Pierre-Yves David
histedit: record histedit source (issue3681)...
r18437 @ 6 e5ae3ca2f1ffdbd89ec41ebc273a231f7c3022f2 "d"
Mads Kiilerich
tests: convert histedit tests to .t...
r17085 |
Pierre-Yves David
histedit: record histedit source (issue3681)...
r18437 | o 5 652413bf663ef2a641cab26574e46d5f5a64a55a "f"
| |
| o 4 e860deea161a2f77de56603b340ebbb4536308ae "e"
| |
| o 3 055a42cdd88768532f9cf79daa407fc8d138de9b "d"
|/
Mads Kiilerich
tests: convert histedit tests to .t...
r17085 o 2 177f92b773850b59254aa5e923436f921b55483b "c"
|
o 1 d2ae7f538514cd87c17547b0de4cea71fe1af9fb "b"
|
o 0 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b "a"
Matt Mackall
histedit: don't clobber working copy on --abort if not on histedit cset...
r19519 abort editing session, after first forcibly updating away
$ hg up 0
abort: histedit in progress
(use 'hg histedit --continue' or 'hg histedit --abort')
[255]
$ mv .hg/histedit-state .hg/histedit-state-ignore
$ hg up 0
0 files updated, 0 files merged, 3 files removed, 0 files unresolved
$ mv .hg/histedit-state-ignore .hg/histedit-state
$ hg sum
parent: 0:cb9a9f314b8b
a
branch: default
Matt Mackall
dirstate: properly clean-up some more merge state on setparents
r22895 commit: 1 added, 1 unknown (new branch head)
Matt Mackall
histedit: don't clobber working copy on --abort if not on histedit cset...
r19519 update: 6 new changesets (update)
Gilles Moris
summary: move the parents phase marker to commit line (issue4688)...
r25382 phases: 7 draft
Matt Mackall
histedit: don't clobber working copy on --abort if not on histedit cset...
r19519 hist: 2 remaining (histedit --continue)
Mads Kiilerich
tests: convert histedit tests to .t...
r17085 $ hg histedit --abort 2>&1 | fixbundle
Matt Mackall
histedit: don't clobber working copy on --abort if not on histedit cset...
r19519
modified files should survive the abort when we've moved away already
$ hg st
Matt Mackall
dirstate: properly clean-up some more merge state on setparents
r22895 A e
Matt Mackall
histedit: don't clobber working copy on --abort if not on histedit cset...
r19519 ? edit.sh
Mads Kiilerich
tests: convert histedit tests to .t...
r17085
$ graphlog "log after abort"
% log after abort
Matt Mackall
histedit: don't clobber working copy on --abort if not on histedit cset...
r19519 o 5 652413bf663ef2a641cab26574e46d5f5a64a55a "f"
Mads Kiilerich
tests: convert histedit tests to .t...
r17085 |
o 4 e860deea161a2f77de56603b340ebbb4536308ae "e"
|
o 3 055a42cdd88768532f9cf79daa407fc8d138de9b "d"
|
o 2 177f92b773850b59254aa5e923436f921b55483b "c"
|
o 1 d2ae7f538514cd87c17547b0de4cea71fe1af9fb "b"
|
Matt Mackall
histedit: don't clobber working copy on --abort if not on histedit cset...
r19519 @ 0 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b "a"
Mads Kiilerich
tests: convert histedit tests to .t...
r17085
timeless
histedit: omit useless message from abort...
r27403 aborting and not changing files can skip mentioning updating (no) files
$ hg up
5 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg commit --close-branch -m 'closebranch'
$ startediting 1 1 "(not changing anything)" # edit the 3rd of 3 changesets
% start editing the history (not changing anything)
| edit 292aec348d9e 6 closebranch
timeless
histedit: list action when intervention is required
r27629 Editing (292aec348d9e), you may commit or record as needed now.
(hg histedit --continue to resume)
timeless
histedit: omit useless message from abort...
r27403 $ hg histedit --abort
Mads Kiilerich
tests: convert histedit tests to .t...
r17085
$ cd ..