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

Hg support #16

Open
ezequielo opened this issue Sep 10, 2015 · 9 comments
Open

Hg support #16

ezequielo opened this issue Sep 10, 2015 · 9 comments

Comments

@ezequielo
Copy link

Hi,

I would like to know if there is any plan of giving support for mercurial (hg). Would it be difficult to implement this upgrade in a fork and then try to submit the code to the original project.

At my organization, we use Bitbucket + hg and we would love to introduce something like a pep8/coverage checked for a diff, and this is the most interesting tool I have seen so far.

Thanks

@Bachmann1234
Copy link
Owner

Ive considered hg support but as I don't really use HG I did not pursue it too far.

Ill try to investigate the work involved again. It should totally be possible.

@Bachmann1234
Copy link
Owner

yeah, this would be a decent amount of work but should be possible. I might be able to work on this but I cannot promise anything in the near term. PRs welcome if you or someone else takes this on.

@ezequielo
Copy link
Author

Well, I havent really delve into code so I'm not sure how to change it right now. I guess I would have to add the hg diff part and maybe perform some little changes in other files. Can you give me more details about how it works and what files should be updated? thanks

@Bachmann1234
Copy link
Owner

Sure

So at a high level this is how diff cover works.

Using the subprocess module diff-cover runs git commands to get the diff and find out information the project.

By parsing that output and comparing it to the output of a quality command like pep8 or a coverage report it can give the status of the lines that changed by ignoring the lines that have not.

It relies on the following commands.

git rev-parse --show-toplevel --encoding=utf-8
git diff <branch>..head --no-ext-diff
git diff --no-ext-diff
git diff --cached --no-ext-diff

So to create a way to do this with merc you would have to figure out rough equivelents of hese commands and be able to parse the output of those commands ( you might save time with the --git flag when running hg diff)

At a code level you would need hg versions of the GitDiffReporter in diff_reporter.py some a hg version of the GitPathTool in git_path.py (or generalize it to work with hg and git) and an hg version of the GitDiffTool

Then I think you just need an -hg switch in the commands themselves and read that to decide what instances of these objects to use.

If you think you are up for that let me know. Obviously I can support.

If you don't think you will be able to thats totally ok :-)

At the very least, do you know what the equivalent versions of those git commands would be in hg? Im not even sure hg has the same staging idea that git does.

Here is what I came up with

git rev-parse --show-toplevel --encoding=utf-8 - > hg root
git diff <branch>..head --no-ext-diff -> hg diff -r "ancestor(<branch>, .)"
git diff --no-ext-diff -> hg diff --git
git diff --cached --no-ext-diff -> ?

But I have not used hg very much.

@schinckel
Copy link

What does git diff --cached do?

@Bachmann1234
Copy link
Owner

I believe it's the same as git diff --staged

@schinckel
Copy link

Ah, gotcha. There's no direct equivalent in mercurial: but only in the sense there is no staging area: hg diff is (AIUI) the same. But I guess that makes it that there's no direct equivalent to git diff.

(I'm interested in doing some of this porting, although I'm not sure that our process will match up totally: hg doesn't yet have native squashing of commits, so it's likely that a diff-cover process will need to work at the PR level, rather than the commit level).

@Bachmann1234
Copy link
Owner

Makes sense. Go for it!

The most common use case I know of is basically diffing PRS anyway

@marklagendijk
Copy link

marklagendijk commented Oct 23, 2018

Because of the lacking mercurial support I created an alternative tool, using Node.js, diff-test-coverage.
Supported coverage report formats:

  • lcov
  • cobertura
  • clover
  • jacoco
  • golang-cover

Supported source control systems:

  • Git
  • Mercurial
  • Anything else that produces unified diffs.

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