Problems with an own patch against Mercurial Queues
Dr Rainer Woitok
rainer.woitok at gmail.com
Tue Dec 19 12:43:03 UTC 2017
Greetings,
for quite some time I have applied the following little patch to Mercur-
ial, because I think a message containing the word "error" is in fact an
error message and should thus go to standard error:
$ cat .hg/patches/MqMessage | grep -v '^#"
Redirect error message from stdout to stderr.
diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -1488,7 +1488,7 @@
top = self.applied[-1].name
if ret[0] and ret[0] > 1:
msg = _("errors during apply, please fix and qrefresh %s\n")
- self.ui.write(msg % top)
+ self.ui.warn(msg % top)
else:
self.ui.write(_("now at: %s\n") % top)
return ret[0]
$
This patch worked for me until I recently updated my Mercurial clone
from "https://www.mercurial-scm.org/repo/hg-stable". After that the
message in question was sent to standard output regardless of my patch,
even though the patch itself still applies cleanly. From the perspect-
ive of my patch the "first bad" changeset is
$ hg log -r qparent -T '{node}'
27481162780894fb82e4b2f679f967a3a86cbc3b
while the "last good" changeset is
$ hg log -r qparent^ -T '{node}'
ee9243715c59c62c9a2619d7957f2dc159d1373b
While I can see that this "first bad" changeset corrects some problem
with the pager, it is not at all clear to me whether now ignoring the
change my patch introduces is a new bug or a new feature :-)
This is the script I'm using to test my patch:
$ cat ../Tests/mercurial/MqMessage.sh
#! /bin/ksh
mkdir /tmp/test
cd /tmp/test
export HGRCPATH=$PWD/.hgrc PS4=' $ '
set -x
cat > .hgrc <<EOF # Enable Mercurial Queues extension.
[extensions]
mq =
[ui]
color = no
EOF
hg init repo
cd repo
echo a > file
hg com -Am File
cat file
hg init --mq
hg qnew p1 # Create patch 1.
echo 1 >| file
hg qrefresh
hg commit --mq -m p1
cat file
hg qpop
hg qnew p2 # Create patch 2 in front of patch 1.
echo 2 >| file
hg qrefresh
hg commit --mq -m p2
hg qpush > out # Try to apply patch 1, which should fail.
cat out
set +x
cd /tmp
rm -rf test
$
Running this script with the patch applied on top of the "last good"
changeset yields:
$ hg log -r qparent -T '{node}'
ee9243715c59c62c9a2619d7957f2dc159d1373b
$ ../Tests/mercurial/MqMessage.sh
$ >.hgrc
$ <<EOF
$ cat
$ hg init repo
$ cd repo
$ >file
$ echo a
$ hg com -Am File
adding file
$ cat file
a
$ hg init --mq
$ hg qnew p1
$ >|file
$ echo 1
$ hg qrefresh
$ hg commit --mq -m p1
$ cat file
1
$ hg qpop
popping p1 patch queue now empty
$ hg qnew p2
$ >|file
$ echo 2
$ hg qrefresh
$ hg commit --mq -m p2
$ >out
$ hg qpush
patching file file
Hunk #1 FAILED at 0
1 out of 1 hunks FAILED -- saving rejects to file file.rej
patch failed, unable to continue (try -v)
patch failed, rejects left in working directory
errors during apply, please fix and qrefresh p1
$ cat out
applying p1
$ set +x
$
As you can see above the message in question did NOT go into file "out"
but was sent to standard error, as it should.
But running the same test script with the patch applied on top of the
"first bad" changeset yields:
$ hg log -r qparent -T '{node}'
27481162780894fb82e4b2f679f967a3a86cbc3b
$ ../Tests/mercurial/MqMessage.sh
$ >.hgrc
$ <<EOF
$ cat
$ hg init repo
$ cd repo
$ >file
$ echo a
$ hg com -Am File
adding file
$ cat file
a
$ hg init --mq
$ hg qnew p1
$ >|file
$ echo 1
$ hg qrefresh
$ hg commit --mq -m p1
$ cat file
1
$ hg qpop
popping p1
patch queue now empty
$ hg qnew p2
$ >|file
$ echo 2
$ hg qrefresh
$ hg commit --mq -m p2
$ >out
$ hg qpush
patching file file
Hunk #1 FAILED at 0
1 out of 1 hunks FAILED -- saving rejects to file file.rej
patch failed, unable to continue (try -v)
patch failed, rejects left in working directory
$ cat out
applying p1
errors during apply, please fix and qrefresh p1
$ set +x
$
You can see that now the error message was sent to file "out" rather
than to standard error.
Slightly puzzled,
Rainer
PS: Since I'm not subscribed to the "mercurial-devel" list, please try
hard to reply to both, the "mercurial-devel" list and yours truly :-)
More information about the Mercurial-devel
mailing list