-
Notifications
You must be signed in to change notification settings - Fork 161
Add basic mercurial support #197
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
Add basic mercurial support #197
Conversation
The 'pypy3-test' failure appears to be due to the (rather old) version of mercurial that lacks the '--terse' flag. I'm curious what the project's stance is toward either requiring a newer version of mercurial, or trying to adapt the code to lack of "collapsing" directories. Specifically, I used the terse option to meet the behavior of the git function that: "If a whole directory is ignored, don't return all files inside of it." As far as I can tell old versions of mercurial just don't do that at all. So if you're interested in these patches I'd like to know what direction you think it worth pursuing. I have not checked the reason for the failure of test, 3.5, macos-latest yet. |
Hey @phlogistonjohn thank you so much for this PR! I added 9929af6 in which I extracted a lot of code into its own module. I should have done this much, much earlier, and the fact that the code was all over the place probably made your life quite a bit harder. And although there is still some code in places that I would like to be elsewhere, this change should make it a lot easier for additional VCSs to be implemented. The change still needs cleaning up, but your code looks excellent—thank you! I'll look into the PyPy thingamajig as well. That image has persistently given me trouble. |
This behaviour is a performance thing. Calling Git once to get a list of all files is much quicker than calling Git every time you need to figure out whether something is ignored or not. I suspect the same would also be true for Mercurial. I'm perfectly happy with requiring newer versions of Mercurial. |
ae69fcc
to
baf471c
Compare
Interestingly, the opposite is true. The version of Mercurial is too new. On Fedora, I have Mercurial version 4.9, and everything works fine. But when I do The test is: @hg
@posix
def test_all_files_hg_ignored_contains_newline(hg_repository):
"""File names that contain newlines are also ignored."""
(hg_repository / "hello\nworld.pyc").touch()
project = Project(hg_repository)
assert Path("hello\nworld.pyc").absolute() not in project.all_files() I manually redid the test, and this is the output:
Not using the |
1b5b49e
to
d61f740
Compare
Typically the underscore indicates that a function is "private" and not meant to be used outside of the module. This function is meant to be used outside of _util.py thus the rename. Signed-off-by: John Mulligan <jmulligan@redhat.com>
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Signed-off-by: John Mulligan <jmulligan@redhat.com>
This is a minimal but sufficient change to make the too usable in the small mercurial repo I am testing against. Signed-off-by: John Mulligan <jmulligan@redhat.com>
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Copy and modify some of the git specific tests to ensure that mercurial (hg) repos behave similarly when it comes to ignoring files. Signed-off-by: John Mulligan <jmulligan@redhat.com>
Using the strategy pattern for this makes reading and using the code a lot easier.
Updated documentation to reflect the changes to VCS. Also added John Mulligan as author and copyright holder.
This flag is causing some grief in later versions of Mercurial. Signed-off-by: Carmen Bianca Bakker <carmenbianca.bakker@liferay.com>
d61f740
to
44fea39
Compare
Signed-off-by: Carmen Bianca Bakker <carmenbianca.bakker@liferay.com>
In order to be ready to check this solution, I'm trying to restore the environment I've used while I found the #97 and working on the #99.
I know I'm probably missing something, but I'm not a Python guy, so I don't know where to check. Hints? |
@marcoXbresciani Not really sure. Following remarks:
|
Hello @carmenbianca,
Thank you. |
Maybe you can try Powershell instead of cmd.exe as a sanity check? I don't know. I haven't used Windows in forever :x |
Still no luck. Can't understand why it doesn't work anymore. :(
I've even installed that
If you have any idea, please help. |
Seems working: instead of using |
It seems your solution does not consider the .hgtags file and sees it as "unlicensed". Am I missing some configuration pieces?
|
@marcoXbresciani Glad you got it working.
The file is missing a copyright header. If |
IMO .hgtags should probably be handled like .hgingore and .gitignore. It's going to be very common in any mercurial project that does releases with tags. It slipped my mind when I added the initial code though. The file contains meta-data meant for the VCS rather than the code but is tracked with the rest of history as a file. |
|
Ah, you're right of course. I was misremembering and thinking of the .git and .hg dirs themselves not the -ignore files. |
In the meanwhile I got the REUSE compliance for my little project by just adding a |
Fixes #99 as far as running the tool on a couple of repos of my own went.
I won't claim that this is comprehensive support for Mercurial as compared to the current git support but it got the tool working for me and generating sensible reports (vs checking my build artifacts). I did try to add some tests as far as code paths that seemed relevant to running
hg
versusgit
goes.I could probably add a few more tests if needed but I am not sure what you would think are tests that really need a specific check when run using mercurial versus git.