ui: fix crash by non-interactive prompt echo for user name
Since we've dropped a str cast at write() by
f04bd381e8c0, ui.prompt() should
convert default to '' if it is None. Otherwise, write() would fail with
"TypeError: object of type 'NoneType' has no len()".
This patch includes the tests for both interactive and non-interactive cases
because "ui.askusername" was never tested.
zeroconf: forward all arguments passed to ui.configitems() wrapper
f43988e5954c added 'ignoresub' argument to ui.configitems(), but zeroconf
wrapper wasn't updated. It caused the following crash:
Traceback (most recent call last):
File "bin/hg", line 43, in <module>
mercurial.dispatch.run()
File "lib/python/mercurial/dispatch.py", line 54, in run
sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
File "lib/python/mercurial/dispatch.py", line 120, in dispatch
ret = _runcatch(req)
File "lib/python/mercurial/dispatch.py", line 191, in _runcatch
return _dispatch(req)
File "lib/python/mercurial/dispatch.py", line 924, in _dispatch
cmdpats, cmdoptions)
File "lib/python/mercurial/dispatch.py", line 681, in runcommand
ret = _runcommand(ui, options, cmd, d)
File "lib/python/mercurial/extensions.py", line 195, in closure
return func(*(args + a), **kw)
File "lib/python/hgext/zeroconf/__init__.py", line 180, in cleanupafterdispatch
return orig(ui, options, cmd, cmdfunc)
File "lib/python/mercurial/dispatch.py", line 1055, in _runcommand
return checkargs()
File "lib/python/mercurial/dispatch.py", line 1015, in checkargs
return cmdfunc()
File "lib/python/mercurial/dispatch.py", line 921, in <lambda>
d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
File "lib/python/mercurial/util.py", line 991, in check
return func(*args, **kwargs)
File "lib/python/mercurial/commands.py", line 5405, in paths
pathitems = sorted(ui.paths.iteritems())
File "lib/python/mercurial/util.py", line 723, in __get__
result = self.func(obj)
File "lib/python/mercurial/ui.py", line 619, in paths
return paths(self)
File "lib/python/mercurial/ui.py", line 1099, in __init__
for name, loc in ui.configitems('paths', ignoresub=True):
File "lib/python/mercurial/extensions.py", line 195, in closure
return func(*(args + a), **kw)
TypeError: configitems() got an unexpected keyword argument 'ignoresub'
We have no test coverage for zeroconf, so I've added a minimal test that
could reproduce this problem.
run-tests: warn about symlinks to non hg scripts
If you symlink /usr/bin/true to /something/hg and try to run
--with-hg=/something/hg, run-tests will end up running /usr/bin/hg,
not /usr/bin/true.
tests: make chunk header of external diff glob-ed for portability
Before this patch, some tests using external "diff" command via
extdiff extension fail on Solaris, because system standard "diff" (=
/usr/bin/diff) on Solaris always generates chunk headers below:
- "@@ -1,0 +1,nnnn @@" for added file
- "@@ -1,nnnn +1,0 @@" for removed file
even though "diff" on Linux generates:
- "@@ -0,0 +1,nnnn @@" for added file
- "@@ -1,nnnn +0,0 @@" for removed file
This patch makes chunk header of external diff glob-ed for portability
of tests.
"hg diff" output follows Linux style, and there are many such diff
output lines in existing tests. This is reason why this patch doesn't
add check-code.py any rule to detect such diff output in tests.
This patch is a part of making tests using external "diff" portable,
and test-subrepo-deep-nested-change.t isn't yet portable even after
this patch.
tests: make chunk header of external diff glob-ed for portability
Before this patch, some tests using external "diff" command via
extdiff extension fail on Solaris, because system standard "diff" (=
/usr/bin/diff) on Solaris always formats chunk header in the style
below:
@@ -X.x +Y.y @@
even though "diff" on Linux sometimes omits ".x" and/or ".y" in it.
This patch makes chunk header of external diff glob-ed for portability
of tests, and adds check-code.py rules to detect such diff output in
tests.
This patch also changes "hg diff" output in test-subrepo-git to
simplify detection rules, even though it is certainly portable because
these lines are generated by "git" command.
This patch is a part of making tests using external "diff" portable,
and tests below aren't yet portable even after this patch.
test-largefiles-update.t
test-subrepo-deep-nested-change.t
tests: make timezone in diff output glob-ed for portability
Before this patch, some tests using external "diff" command via
extdiff extension fail on Solaris, because system standard "diff" (=
/usr/bin/diff) on Solaris doesn't display timezone for timestamp of
each files in diff output.
This patch makes timezone in external diff output glob-ed for
portability of tests, and adds check-code.py a rule to detect such
tests: omit -p for external diff via extdiff extension for portability
Before this patch, some tests using external "diff" command via
extdiff extension fail on Solaris, because "-p" (show which C function
each change is in) option isn't supported by system standard "diff" on
Solaris, even though extdiff passes it to external "diff" by default.
Fortunately, this non-portable option isn't important for (current, at
least) tests using external "diff" command via extdiff extension.
This patch omits "-p" for external "diff" command via extdiff
extension for portability of tests, and adds check-code.py a rule to
detect invocation of "diff" with "-p".
Newly added check-code.py rule examines only lines generated by
external "diff" with "-r", because strict examination might
misidentify "hg diff -p" or other complicated lines consisting of
"diff" string as wrong one.
This patch is a part of making tests using external "diff" portable,
and tests below aren't yet portable even after this patch.
test-graft.t
test-largefiles-update.t
test-subrepo-deep-nested-change.t
update: check command line before modifying repo
A failed command should not have any effect on the repo.