##// END OF EJS Templates
phabricator: warn if unable to amend, instead of aborting after posting...
phabricator: warn if unable to amend, instead of aborting after posting There was a divergence in behavior here between obsolete and strip based amending. I first noticed the abort when testing outside of the test harness, but then had trouble recreating it here after reverting the code changes. It turns out, strip based amend was successfully amending the public commit after it was posted! It looks like the protection is in the `commit --amend` command, not in the underlying code that it calls. I considered doing a preflight check and aborting. But the locks are only acquired at the end, if amending, and this is too large a section of code to be wrapped in a maybe-it's-held-or-not context manager for my tastes. Additionally, some people do post-push reviews, and amending is the default behavior, so they shouldn't see a misleading error message. The lack of a 'Differential Revision' entry in the commit message breaks a {phabreview} test, so it had to be partially conditionalized.

File last commit:

r39967:0d703063 default
r41198:0101a35d default
Show More
test-dispatch.t
220 lines | 5.9 KiB | text/troff | Tads3Lexer
Adrian Buehlmann
tests: unify test-dispatch
r12157 test command parsing and dispatch
$ hg init a
$ cd a
Nicolas Dumazet
tests: move test-issue436 in test-dispatch where fancyopts is tested
r14115
Redundant options used to crash (issue436):
$ hg -v log -v
$ hg -v log -v x
Adrian Buehlmann
tests: unify test-dispatch
r12157 $ echo a > a
$ hg ci -Ama
adding a
Missing arg:
$ hg cat
hg cat: invalid arguments
hg cat [OPTION]... FILE...
output the current or given revision of files
Matt Mackall
help: fold repeatable option message into option table header...
r22117 options ([+] can be repeated):
Adrian Buehlmann
tests: unify test-dispatch
r12157
Matt Mackall
help: use RST to format option lists
r15145 -o --output FORMAT print output to file with formatted name
-r --rev REV print the given revision
Pierre-Yves David
help: backout f3c4edfd35e1 (mark boolean flags with [no-] in help) for now...
r30152 --decode apply any matching decode filter
Matt Mackall
help: use RST to format option lists
r15145 -I --include PATTERN [+] include names matching the given patterns
-X --exclude PATTERN [+] exclude names matching the given patterns
Yuya Nishihara
formatter: remove experimental marker from -T option...
r39967 -T --template TEMPLATE display with template
Adrian Buehlmann
tests: unify test-dispatch
r12157
timeless
help: use single quotes in use warning
r29974 (use 'hg cat -h' to show more help)
Matt Mackall
tests: add exit codes to unified tests
r12316 [255]
Adrian Buehlmann
tests: unify test-dispatch
r12157
Yuya Nishihara
dispatch: do not drop unpaired argument at _earlygetopt()...
r35056 Missing parameter for early option:
$ hg log -R 2>&1 | grep 'hg log'
hg log: option -R requires argument
hg log [OPTION]... [FILE]
(use 'hg log -h' to show more help)
Yuya Nishihara
fancyopts: use getopt.gnu_getopt()...
r35226 "--" may be an option value:
$ hg -R -- log
Yuya Nishihara
fancyopts: fix handling of "--" value in earlygetopt()
r35227 abort: repository -- not found!
Yuya Nishihara
fancyopts: use getopt.gnu_getopt()...
r35226 [255]
$ hg log -R --
Yuya Nishihara
fancyopts: fix handling of "--" value in earlygetopt()
r35227 abort: repository -- not found!
Yuya Nishihara
fancyopts: use getopt.gnu_getopt()...
r35226 [255]
$ hg log -T --
-- (no-eol)
$ hg log -T -- -k nomatch
Yuya Nishihara
dispatch: do not drop unpaired argument at _earlygetopt()...
r35056
Yuya Nishihara
dispatch: stop parsing of early boolean option at "--"
r35058 Parsing of early options should stop at "--":
$ hg cat -- --config=hooks.pre-cat=false
--config=hooks.pre-cat=false: no such file in rev cb9a9f314b8b
[1]
$ hg cat -- --debugger
--debugger: no such file in rev cb9a9f314b8b
[1]
Yuya Nishihara
dispatch: abort if early boolean options can't be parsed...
r35059 Unparsable form of early options:
$ hg cat --debugg
abort: option --debugger may not be abbreviated!
[255]
Yuya Nishihara
dispatch: verify result of early command parsing...
r35063 Parsing failure of early options should be detected before executing the
command:
$ hg log -b '--config=hooks.pre-log=false' default
abort: option --config may not be abbreviated!
[255]
$ hg log -b -R. default
abort: option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo!
[255]
$ hg log --cwd .. -b --cwd=. default
abort: option --cwd may not be abbreviated!
[255]
However, we can't prevent it from loading extensions and configs:
$ cat <<EOF > bad.py
> raise Exception('bad')
> EOF
$ hg log -b '--config=extensions.bad=bad.py' default
*** failed to import extension bad from bad.py: bad
abort: option --config may not be abbreviated!
[255]
$ mkdir -p badrepo/.hg
$ echo 'invalid-syntax' > badrepo/.hg/hgrc
$ hg log -b -Rbadrepo default
Matt Harbison
tests: remove (glob) annotations that were only for '\' matches...
r35394 hg: parse error at badrepo/.hg/hgrc:1: invalid-syntax
Yuya Nishihara
dispatch: verify result of early command parsing...
r35063 [255]
$ hg log -b --cwd=inexistent default
Matt Harbison
tests: add a substitution for ENOENT/ERROR_FILE_NOT_FOUND messages...
r35230 abort: $ENOENT$: 'inexistent'
Yuya Nishihara
dispatch: verify result of early command parsing...
r35063 [255]
$ hg log -b '--config=ui.traceback=yes' 2>&1 | grep '^Traceback'
Traceback (most recent call last):
$ hg log -b '--config=profiling.enabled=yes' 2>&1 | grep -i sample
Sample count: .*|No samples recorded\. (re)
Early options can't be specified in [aliases] and [defaults] because they are
applied before the command name is resolved:
$ hg log -b '--config=alias.log=log --config=hooks.pre-log=false'
hg log: option -b not recognized
error in definition for alias 'log': --config may only be given on the command
line
[255]
$ hg log -b '--config=defaults.log=--config=hooks.pre-log=false'
abort: option --config may not be abbreviated!
[255]
Shell aliases bypass any command parsing rules but for the early one:
$ hg log -b '--config=alias.log=!echo howdy'
howdy
Yuya Nishihara
dispatch: add HGPLAIN=+strictflags to restrict early parsing of global options...
r35180 Early options must come first if HGPLAIN=+strictflags is specified:
(BUG: chg cherry-picks early options to pass them as a server command)
#if no-chg
$ HGPLAIN=+strictflags hg log -b --config='hooks.pre-log=false' default
abort: unknown revision '--config=hooks.pre-log=false'!
[255]
$ HGPLAIN=+strictflags hg log -b -R. default
abort: unknown revision '-R.'!
[255]
$ HGPLAIN=+strictflags hg log -b --cwd=. default
abort: unknown revision '--cwd=.'!
[255]
#endif
$ HGPLAIN=+strictflags hg log -b --debugger default
abort: unknown revision '--debugger'!
[255]
$ HGPLAIN=+strictflags hg log -b --config='alias.log=!echo pwned' default
abort: unknown revision '--config=alias.log=!echo pwned'!
[255]
$ HGPLAIN=+strictflags hg log --config='hooks.pre-log=false' -b default
abort: option --config may not be abbreviated!
[255]
$ HGPLAIN=+strictflags hg log -q --cwd=.. -b default
abort: option --cwd may not be abbreviated!
[255]
$ HGPLAIN=+strictflags hg log -q -R . -b default
abort: option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo!
[255]
$ HGPLAIN=+strictflags hg --config='hooks.pre-log=false' log -b default
abort: pre-log hook exited with status 1
[255]
$ HGPLAIN=+strictflags hg --cwd .. -q -Ra log -b default
0:cb9a9f314b8b
Yuya Nishihara
dispatch: alias --repo to --repository while parsing early options...
r35223 $ HGPLAIN=+strictflags hg --cwd .. -q --repository a log -b default
0:cb9a9f314b8b
$ HGPLAIN=+strictflags hg --cwd .. -q --repo a log -b default
0:cb9a9f314b8b
Yuya Nishihara
dispatch: add HGPLAIN=+strictflags to restrict early parsing of global options...
r35180
For compatibility reasons, HGPLAIN=+strictflags is not enabled by plain HGPLAIN:
$ HGPLAIN= hg log --config='hooks.pre-log=false' -b default
abort: pre-log hook exited with status 1
[255]
$ HGPLAINEXCEPT= hg log --cwd .. -q -Ra -b default
0:cb9a9f314b8b
Adrian Buehlmann
tests: unify test-dispatch
r12157 [defaults]
$ hg cat a
a
$ cat >> $HGRCPATH <<EOF
> [defaults]
> cat = -r null
> EOF
$ hg cat a
a: no such file in rev 000000000000
Matt Mackall
tests: add exit codes to unified tests
r12316 [1]
Adrian Buehlmann
tests: unify test-dispatch
r12157
Mads Kiilerich
tests: convert some 'hghave no-outer-repo' to #if...
r17014 $ cd "$TESTTMP"
Mads Kiilerich
tests: fix for windows - slashes and no serve
r18506 OSError "No such file or directory" / "The system cannot find the path
specified" should include filename even when it is empty
Mads Kiilerich
dispatch: show empty filename in OSError aborts...
r18227
$ hg -R a archive ''
Mads Kiilerich
tests: fix for windows - slashes and no serve
r18506 abort: *: '' (glob)
Mads Kiilerich
dispatch: show empty filename in OSError aborts...
r18227 [255]
Mads Kiilerich
tests: convert some 'hghave no-outer-repo' to #if...
r17014 #if no-outer-repo
Adrian Buehlmann
tests: unify test-dispatch
r12157 No repo:
$ hg cat
Matt Mackall
dispatch: improve repository not found message...
r13967 abort: no repository found in '$TESTTMP' (.hg not found)!
Matt Mackall
tests: add exit codes to unified tests
r12316 [255]
Adrian Buehlmann
tests: unify test-dispatch
r12157
Mads Kiilerich
tests: convert some 'hghave no-outer-repo' to #if...
r17014 #endif
Jun Wu
hgweb: do not import uuid immediately to avoid its side effect...
r34644
#if rmcwd
Current directory removed:
$ mkdir $TESTTMP/repo1
$ cd $TESTTMP/repo1
$ rm -rf $TESTTMP/repo1
Jun Wu
test-dispatch: stabilize the test...
r34954
The output could be one of the following and something else:
chg: abort: failed to getcwd (errno = *) (glob)
abort: error getting current working directory: * (glob)
Matt Harbison
tests: add a substitution for ENOENT/ERROR_FILE_NOT_FOUND messages...
r35230 sh: 0: getcwd() failed: $ENOENT$
Jun Wu
test-dispatch: stabilize the test...
r34954 Since the exact behavior depends on the shell, only check it returns non-zero.
$ HGDEMANDIMPORT=disable hg version -q 2>/dev/null || false
[1]
Jun Wu
hgweb: do not import uuid immediately to avoid its side effect...
r34644
#endif