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

gitAndTools.git-remote-hg: 0.2 -> 1.0.0 #59332

Closed
wants to merge 2 commits into from

Conversation

erosennin
Copy link
Contributor

Motivation for this change

git-remote-hg-0.2 is broken with recent versions of Mercurial:

$ hg init test-hg
$ cd test-hg
$ touch README
$ hg add
$ hg commit -m 'Add readme'
$ cd ..
$ git clone hg::test-hg test-git
Cloning into 'test-git'...
Traceback (most recent call last):
  File "/nix/store/5m6xvmcqq5j248i90hnrga7pal6wm3yr-git-remote-hg-0.2-e716a9e1a9e460a45663694ba4e9e8894a8452b2/bin/.git-remote-hg-wrapped", line 1333, in <module>
    sys.exit(main(sys.argv))
  File "/nix/store/5m6xvmcqq5j248i90hnrga7pal6wm3yr-git-remote-hg-0.2-e716a9e1a9e460a45663694ba4e9e8894a8452b2/bin/.git-remote-hg-wrapped", line 1317, in main
    do_import(parser)
  File "/nix/store/5m6xvmcqq5j248i90hnrga7pal6wm3yr-git-remote-hg-0.2-e716a9e1a9e460a45663694ba4e9e8894a8452b2/bin/.git-remote-hg-wrapped", line 729, in do_import
    export_bookmark(repo, bmark)
  File "/nix/store/5m6xvmcqq5j248i90hnrga7pal6wm3yr-git-remote-hg-0.2-e716a9e1a9e460a45663694ba4e9e8894a8452b2/bin/.git-remote-hg-wrapped", line 613, in export_bookmark
    export_ref(repo, bmark, 'bookmarks', head)
  File "/nix/store/5m6xvmcqq5j248i90hnrga7pal6wm3yr-git-remote-hg-0.2-e716a9e1a9e460a45663694ba4e9e8894a8452b2/bin/.git-remote-hg-wrapped", line 486, in export_ref
    revs = gitrange(repo, tip, head)
  File "/nix/store/5m6xvmcqq5j248i90hnrga7pal6wm3yr-git-remote-hg-0.2-e716a9e1a9e460a45663694ba4e9e8894a8452b2/bin/.git-remote-hg-wrapped", line 453, in gitrange
    pending = set([int(b)])
TypeError: int() argument must be a string or a number, not 'changectx'
fatal: stream ends early
fast-import: dumping crash report to /tmp/test-git/.git/fast_import_crash_16959
fatal: error while running fast-import
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@erosennin
Copy link
Contributor Author

Should probably be also backported to 19.03.

Copy link
Contributor

@worldofpeace worldofpeace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above minor comments.

This appears to be a python application https://github.com/mnauw/git-remote-hg/blob/master/setup.py.
So we should be using buildPythonApplication and fetching with fetchPypi.

https://pypi.org/project/git-remote-hg/

You should also document the upstream source changes in the commit msg.

@@ -22,7 +22,7 @@ stdenv.mkDerivation rec {

postInstall = ''
wrapProgram $out/bin/git-remote-hg \
--prefix PYTHONPATH : "$(echo ${mercurial}/lib/python*/site-packages):$(echo ${mercurial.python}/lib/python*/site-packages)${stdenv.lib.concatMapStrings (x: ":$(echo ${x}/lib/python*/site-packages)") mercurial.pythonPackages or []}"
--set PYTHONPATH "$(echo ${mercurial}/lib/python*/site-packages):$(echo ${mercurial.python}/lib/python*/site-packages)${stdenv.lib.concatMapStrings (x: ":$(echo ${x}/lib/python*/site-packages)") mercurial.pythonPackages or []}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buildPython* should be able to wrap this when you put the runtime deps in propagatedBuildInputs.

Copy link
Contributor Author

@erosennin erosennin Apr 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is, setup.py is currently broken, because it tries to fetch the version from a git tag and fails. We can patch it though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buildPython* should be able to wrap this when you put the runtime deps in propagatedBuildInputs.

This package depends on mercurial, which is built with buildPythonApplication. Will it still work?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is, setup.py is currently broken, because it tries to fetch the version from a git tag and fails. We can patch it though.

Yeah they're many packages that take a much better approach that they could have used as an example. Patching and submitting it upstream would be preferred.

But if it's too much of a hassle, you can use format = "other"; and just use the Makefile as normally.

https://nixos.org/nixpkgs/manual/#python 9.14.2.2.1.1. buildPythonPackage parameters

This package depends on mercurial, which is built with buildPythonApplication. Will it still work?

Think so.

@erosennin
Copy link
Contributor Author

Wow, thanks for such a thorough review. :)

…b2 -> 1.0.0

Changed the upstream repo to https://github.com/mnauw/git-remote-hg:

- looks the most alive at the moment, the last commit is from March 2019;
- https://pypi.org/project/git-remote-hg/ points to this repo as well;
- Debian uses it too:
  https://salsa.debian.org/debian/git-remote-hg/blob/e769897119850979d590b758791b7d7b36db3c41/setup.py#L45
@erosennin
Copy link
Contributor Author

Refectored to use buildPythonApplication.

asciidoc xmlto docbook_xsl docbook_xml_dtd_45 libxslt libxml2
];
nativeBuildInputs = [ asciidoc xmlto docbook_xsl docbook_xml_dtd_45 libxslt libxml2 ];
propagatedBuildInputs = [ mercurial ];

doCheck = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the tests are going to be problematic. They mostly pass but one or two of them fail. What's worse, the failures are different with different versions of Git and Mercurial. I'll have to look into it.


doCheck = false;

installFlags = "HOME=\${out} install-doc";
patches = [
./patches/./no-dynamic-git-version.patch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
./patches/./no-dynamic-git-version.patch
./patches/no-dynamic-git-version.patch

Use buildPythonApplication, organize build inputs.
@erosennin
Copy link
Contributor Author

Already done in #57730.

@erosennin erosennin closed this Sep 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants