Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mercurial? #186

Closed
Daniel15 opened this issue Jul 20, 2016 · 7 comments
Closed

Mercurial? #186

Daniel15 opened this issue Jul 20, 2016 · 7 comments

Comments

@Daniel15
Copy link

Do you have instructions on how to configure this project to be used with Mercurial rather than Git?

@OJFord
Copy link
Member

OJFord commented Jul 29, 2016

That would be dependent upon mercurial diffs being line-compatible with git's; I don't know if that's the case?

I've never used mercurial (or, therefore, tested this) - but you could try:

[extensions]
hgext.extdiff =
[extdiff]
cmd.dsf = diff-so-fancy | less --tabs=4 -RFX

@Daniel15
Copy link
Author

Daniel15 commented Aug 5, 2016

Thanks for the info! I just tried that, which gave me this:

sh: diff-so-fancy | less --tabs=4 -RFX: command not found

Seems like it's trying to run the whole thing as a command, rather than treating | as a pipe. I tried removing the pipe to less and just doing:

cmd.dsf = diff-so-fancy

But then it just sat there forever, without doing anything.

I ended up just creating a hg-diff-fancy shell alias, which is working fine for me:

hg-diff-fancy='hg diff --color=always | diff-so-fancy | less -FR'

@Daniel15 Daniel15 closed this as completed Aug 5, 2016
@OJFord
Copy link
Member

OJFord commented Aug 5, 2016

Seems like it's trying to run the whole thing as a command

Hm, actually the example at the bottom of this page does make it seem like pipes aren't supported for some reason.

I tried removing the pipe ... But then it just sat there forever

That would suggest that git/hg diffs aren't compatible; so it chokes on the input. So it's interesting that you were able to create an

hg-diff-fancy shell alias, which is working fine
I'm not sure what's going on there then.

Still, at least it works I suppose! I might look into this at some point, see if I can make it work without needing a shell-level alias so we can document it as known-working (if unsupported and may break) with mercurial.

@Daniel15
Copy link
Author

Daniel15 commented Aug 5, 2016

I think Mercurial diffs are compatible with Git diffs (that is, they're in the same format). Not sure if that's the default configuration, but it's how it seems to be configured internally at Facebook.

@OJFord
Copy link
Member

OJFord commented Aug 6, 2016

Looked into this a little bit, it seems both are based on GNU's "Unified Format", which makes sense. Git seems to extend it a little bit though, so if you run into issues with your current command, you may want to try adding --git to hg diff.

@srsudar
Copy link
Contributor

srsudar commented Jul 28, 2020

With the help of some people that are much more expert in hg than I am, I arrived at this alias that uses diff-so-fancy with a normal hg diff invocation. I was warned that this might break some consumers of the diff output that neglect to set HGPLAIN=1, but I haven't encountered any such shortcomings thus far.

Adding this to my .hgrc gives me diff-so-fancy output in response to hg diff:

[alias]
diff = !HGPLAIN=1 $HG diff --pager=on --config pager.pager=diff-so-fancy

@scottchiefbaker
Copy link
Contributor

@srsudar I'd love a PR in our Pro Tips section with Mercurial stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants