tests/pdiff
author |
Raphaël Gomès <rgomes@octobus.net> |
|
Mon, 20 Sep 2021 15:16:10 +0200 |
branch | stable |
changeset 48017 |
ff2304dd3ba9 |
parent 33611 |
a2b55ee62803
|
permissions |
-rwxr-xr-x |
patchbomb: fix traceback on outgoing when not specifying revisions
A user reported that `hg email -n -o` raised with the following traceback:
```
** unknown exception encountered, please report by visiting
** https://mercurial-scm.org/wiki/BugTracker
** Python 3.8.12 (default, Sep 13 2021, 22:12:54) [GCC 7.5.0]
** Mercurial Distributed SCM (version 5.9.1)
** Extensions loaded: patchbomb
Traceback (most recent call last):
File "/usr/pkg/bin/hg", line 61, in <module>
dispatch.run()
File "/usr/pkg/lib/python3.8/site-packages/mercurial/dispatch.py", line 144, in run
status = dispatch(req)
File "/usr/pkg/lib/python3.8/site-packages/mercurial/dispatch.py", line 250, in dispatch
status = _rundispatch(req)
File "/usr/pkg/lib/python3.8/site-packages/mercurial/dispatch.py", line 294, in _rundispatch
ret = _runcatch(req) or 0
File "/usr/pkg/lib/python3.8/site-packages/mercurial/dispatch.py", line 470, in _runcatch
return _callcatch(ui, _runcatchfunc)
File "/usr/pkg/lib/python3.8/site-packages/mercurial/dispatch.py", line 480, in _callcatch
return scmutil.callcatch(ui, func)
File "/usr/pkg/lib/python3.8/site-packages/mercurial/scmutil.py", line 153, in callcatch
return func()
File "/usr/pkg/lib/python3.8/site-packages/mercurial/dispatch.py", line 460, in _runcatchfunc
return _dispatch(req)
File "/usr/pkg/lib/python3.8/site-packages/mercurial/dispatch.py", line 1273, in _dispatch
return runcommand(
File "/usr/pkg/lib/python3.8/site-packages/mercurial/dispatch.py", line 918, in runcommand
ret = _runcommand(ui, options, cmd, d)
File "/usr/pkg/lib/python3.8/site-packages/mercurial/dispatch.py", line 1285, in _runcommand
return cmdfunc()
File "/usr/pkg/lib/python3.8/site-packages/mercurial/dispatch.py", line 1271, in <lambda>
d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
File "/usr/pkg/lib/python3.8/site-packages/mercurial/util.py", line 1886, in check
return func(*args, **kwargs)
File "/usr/pkg/lib/python3.8/site-packages/hgext/patchbomb.py", line 817, in email
revs = _getoutgoing(repo, dest, revs)
File "/usr/pkg/lib/python3.8/site-packages/hgext/patchbomb.py", line 537, in _getoutgoing
safe_paths = [urlutil.hidepassword(p.rawloc) for p in paths]
File "/usr/pkg/lib/python3.8/site-packages/hgext/patchbomb.py", line 537, in <listcomp>
safe_paths = [urlutil.hidepassword(p.rawloc) for p in paths]
File "/usr/pkg/lib/python3.8/site-packages/mercurial/utils/urlutil.py", line 501, in get_push_paths
msg %= dest
TypeError: %b requires a bytes-like object, or an object that implements __bytes__, not 'NoneType'
```
This is due to patchbomb passing `[None]` in the `dests` parameter of the
multi-paths outgoing function, we fix this in this change and add a
non-regression test.
Differential Revision: https://phab.mercurial-scm.org/D11456
#!/bin/sh
# Script to get stable diff output on any platform.
#
# Output of this script is almost equivalent to GNU diff with "-Nru".
#
# Use this script as "hg pdiff" via extdiff extension with preparation
# below in test scripts:
#
# $ cat >> $HGRCPATH <<EOF
# > [extdiff]
# > pdiff = sh "$RUNTESTDIR/pdiff"
# > EOF
filediff(){
# USAGE: filediff file1 file2 [header]
# compare with /dev/null if file doesn't exist (as "-N" option)
file1="$1"
if test ! -f "$file1"; then
file1=/dev/null
fi
file2="$2"
if test ! -f "$file2"; then
file2=/dev/null
fi
if cmp -s "$file1" "$file2" 2> /dev/null; then
# Return immediately, because comparison isn't needed. This
# also avoids redundant message of diff like "No differences
# encountered" (on Solaris)
return
fi
if test -n "$3"; then
# show header only in recursive case
echo "$3"
fi
# replace "/dev/null" by corresponded filename (as "-N" option)
diff -u "$file1" "$file2" |
sed "s@^--- /dev/null\(.*\)\$@--- $1\1@" |
sed "s@^\+\+\+ /dev/null\(.*\)\$@+++ $2\1@"
# in this case, files differ from each other
return 1
}
if test -d "$1" -o -d "$2"; then
# ensure comparison in dictionary order
(
if test -d "$1"; then (cd "$1" && find . -type f); fi
if test -d "$2"; then (cd "$2" && find . -type f); fi
) |
sed 's@^\./@@g' | sort | uniq |
while read file; do
filediff "$1/$file" "$2/$file" "diff -Nru $1/$file $2/$file"
done
# TODO: there is no portable way for current while-read based
# implementation to return 1 at detecting changes.
#
# On bash and dash, assignment to variable inside while-block
# doesn't affect outside, because inside while-block is executed
# in sub-shell. BTW, it affects outside while-block on ksh (as sh
# on Solaris).
else
filediff "$1" "$2"
fi