Bug 3712 - On Windows diff in subrepos is shown without colors
Summary: On Windows diff in subrepos is shown without colors
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: color (show other bugs)
Version: earlier
Hardware: PC Windows
: normal bug
Assignee: Bugzilla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-27 03:07 UTC by Alexey Sergeev
Modified: 2017-11-01 18:05 UTC (History)
5 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey Sergeev 2012-11-27 03:07 UTC
Color extension is enabled in mercurial configuration file. So when you change files in repository and use 'hg diff' all changes are highlighted with colors. When you add changes in sub-repository and enter 'hg diff' from main repository folder all the diffrerences in sub repositories are shown without colors.
Comment 1 Matt Mackall 2012-11-27 14:56 UTC
Do you have color enabled globally or just in the main repo?

Do you have any reason to think your issue is Windows-specific?
Comment 2 Alexey Sergeev 2012-11-28 02:08 UTC
I have color enabled globally. I'm using Windows that's why I posted bug only for Windows, I don't know whether this bug is reproducible on *nix systems.
Comment 3 Matt Mackall 2012-11-28 15:19 UTC
Ok, adding some people who might have ideas.

Can you test if the problem exists with 2.3.x, please?
Comment 4 FUJIWARA Katsunori 2012-11-29 01:00 UTC
I can reproduce this issue with Mercurial 2.4(64bit) on Windows7.

Below versions can colorize diff of subrepo well on same environment:

  - Mercurial 2.3(64bit)
  - Mercurial 2.3.2 bundled with TortoiseHg(64bit)

diff of subrepo is not colorized, even though color extension is
enabled in .hg/hgrc of subrepository.

in all cases, diff of parent is colorized well.

(In reply to comment #3)
Comment 5 Alexey Sergeev 2012-11-29 01:43 UTC
Mercurial 2.3 on Windows x64 is working correctly.
Comment 6 FUJIWARA Katsunori 2012-11-29 01:55 UTC
I found cause of this issue.

Colorization is achieved by overriding the class of "ui" object
at command dispatching.

    http://selenic.com/repo/hg/file/e853d27956fb/hgext/color.py#l358

But "diff()" of hgsubrepo passes "self._repo.ui" to
"cmdutil.diffordiffstat()": it is created from "baseui" of parent
repo, and plain one.

So, output of "cmdutil.diffordiffstat()" for subrepo is not colorized.

"status()" of hgsubrepo doesn't take "ui" argument, too. But it
works well for colorization of subrepo status, because "status()"
of hgsubrepo only returns status information: writing out is done
with colorized "ui" on the caller side.

I'll post the patch to fix this issue by adding "ui" argument
to "diff()" of subrepo.

BTW, trigger of this issue is 573bec4ab7ba: it's mine :-<
Comment 7 HG Bot 2012-12-03 15:31 UTC
Fixed by http://selenic.com/repo/hg/rev/0c10cf819146
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
subrepo: add argument to "diff()" to pass "ui" of caller side (issue3712) (API)

Color extension achieves colorization by overriding the class of
"ui" object just before command execution.

Before this patch, "diff()" of abstractsubrepo and classes
derived from it has no "ui" argument, so "diff()" of hgsubrepo
uses "self._repo.ui" to invoke "cmdutil.diffordiffstat()".

For separation of configuration between repositories, revision
573bec4ab7ba changed the initialization source of "self._repo.ui"
from "ui"(overridden) to "baseui"(plain) of parent repository.
And this caused break of colorization.

This patch adds "ui" argument to "diff()" of abstractsubrepo and
classes derived from it to pass "ui" object of caller side.

(please test the fix)