Issue2096

Title The color extension does not work with --mq
Priority bug Status resolved
Superseder Nosy List brodie, cedric, danchr, djc, hgbot, krbullock
Assigned To Topics mq

Created on 2010-03-14.18:48:36 by cedric, last changed 2010-10-09.14:45:44 by mpm.

Messages
msg13098 (view) Author: hgbot Date: 2010-07-14.19:00:03
Fixed by http://hg.intevation.org/mercurial/crew/rev/d8d0fc3988ca
(color/progress: subclass ui instead of using wrapfunction (issue2096))
msg12982 (view) Author: brodie Date: 2010-07-02.17:56:12
I've posted a potential fix on the mailing list here: 
http://www.selenic.com/pipermail/mercurial-devel/2010-July/022423.html
msg12470 (view) Author: brodie Date: 2010-05-10.20:50:50
(Doing more research.)

On default/1.6 the problem is similar but slightly different. The color 
extension isn't using pushbuffer or popbuffer to capture output, but it is 
wrapping popbuffer, write, and write_err on ui to provide colorization. The 
copied ui that mqcommand() uses doesn't retain these wrappers.

Also relevant: http://selenic.com/hg/rev/2e8926e9cc32
msg12468 (view) Author: brodie Date: 2010-05-10.18:16:49
Or more precisely:

1. _colorstatuslike() calls ui.pushbuffer()
2. _colorstatuslike() calls mqcommand()
3. mqcommand() calls repo.mq.qrepo()
4. localrepo.__init__() copies ui and assigns it to qrepo.ui
5. mqcommand calls status() with this new ui object
6. _colorstatuslike() calls ui.popbuffer() and gets nothing back. status() 
wrote to the copied ui instead of the original one.
msg12467 (view) Author: brodie Date: 2010-05-10.17:45:12
The ui object in _colorstatuslike() is not the ui object being written to; 
pushing and popping its buffer gets nothing back.

I added some print statements in mqcommand() and _colorstatuslike(). You can 
see the three ui objects:

in _colorstatuslike():
    ui: <mercurial.ui.ui object at 0x82e77cc> [a]
    repo: <hgext.mq.mqrepo object at 0x82f26ec> [b]
    repo.ui: <mercurial.ui.ui object at 0x82e77cc> [b]
in mqcommand():
    ui: <mercurial.ui.ui object at 0x82e77cc> [a]
    repo: <hgext.mq.mqrepo object at 0x82f26ec> [b]
    repo.ui: <mercurial.ui.ui object at 0x82e77cc> [b]
    r: <hgext.mq.mqrepo object at 0x82fa98c> [c]
    r.ui: <mercurial.ui.ui object at 0x82faa4c> [c]

Because color is wrapping mqcommand and not status directly, it never sees 
[c], so push/popbuffer doesn't collect anything.

I'm not sure what the best fix would be.
msg12046 (view) Author: cedric Date: 2010-03-14.18:48:36
When both mq and the color extension are used, the output of commands
wrapped by mqcommand is not colorized, as demonstrated by the following script.


#!/bin/sh

cat <<EOF >test.hgrc
[ui]
username=foo@bar
[extensions]
color=
mq=
EOF
export HGRCPATH="$(pwd)/test.hgrc"

rm -rf testrepo
hg init testrepo
cd testrepo
hg init --mq
hg qnew foo
touch bar
echo "% status on main repo (colorized)"
hg stat
echo "% status on queue repo (not colorized)"
hg stat --mq
History
Date User Action Args
2010-10-09 14:45:44mpmsetstatus: testing -> resolved
nosy: djc, cedric, brodie, danchr, hgbot, krbullock
2010-07-14 19:00:03hgbotsetstatus: chatting -> testing
nosy: + hgbot
messages: + msg13098
2010-07-02 17:56:12brodiesetnosy: djc, cedric, brodie, danchr, krbullock
messages: + msg12982
2010-07-02 15:32:43krbullocksetnosy: + krbullock
2010-05-10 20:50:50brodiesetnosy: djc, cedric, brodie, danchr
messages: + msg12470
2010-05-10 18:16:49brodiesetnosy: djc, cedric, brodie, danchr
messages: + msg12468
2010-05-10 17:45:13brodiesetstatus: unread -> chatting
nosy: djc, cedric, brodie, danchr
messages: + msg12467
2010-03-15 21:20:27danchrsetnosy: + danchr
2010-03-15 08:31:19djcsetnosy: + djc, brodie
2010-03-14 18:48:36cedriccreate