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
things I don't like about the json <--> hg conversion code #12342
Comments
comment:1
Let me add to the list: I don't think these commands are documented anywhere (except in comments at the top of the scripts). They might be mentioned in the top-level README, and they should definitely be in the installation guide. |
comment:2
The first thing I find is that this code is really bad
I'm sitting here forever trying to figure out how to use the code based on reading the parser stuff (since there's no guide or other documentation about what to do and the "make "), and finally I discover a naked try/except and that there is an alternative parser, which has completely different behavior. Confusing. In fact, argparse isn't even in sage-4.8 yet (it should be in 5.0). |
Attachment: hg_json.gz |
comment:4
Good morning and happy Chinese New Year from Singapore! Thanks for making this followup ticket, as my code could certainly be improved. The main reason I didn't explain the command line usage of Looking at your new code, minor comment about exceptions: # this is legacy syntax which is removed in Python 3
raise ExceptionType, "message"
except ExceptionType, e
# this is the currently recommended syntax
raise ExceptionType("message")
except ExceptionType as e I see a lot of the former syntax in Sage. The Python website tells me that "well-written 2.x code can be a lot like 3.x code", meaning, I guess, that much of the Python 3 syntax is already standard in 2.6 and 2.7 and we should use it. So I usually try to do this, but maybe it's too early to start planning for Python 3 in Sage? After all we only just got 2.7 in in Sage 5.0. Anyway, you said you're going to work on this yourself, but if you want me to help with anything just let me know. I'll be keeping an eye on this ticket. |
comment:5
Hi, I wrote this script hg_json, which does something very useful standalone -- it swaps between having a .hg directory and having a .hg.json file. The hard work is all done by the code you had already written. Thoughts? I hope not to work much more on this ticket, and that you (Kini) could somehow finish it. We need to come up with a workflow. Maybe can have an option to sdist, e.g.,
which replaces all .hg repos by .hg.json files... for now (maybe removes binaries, e.g., that gfortran spkg), and when someday we switch to git, it will do the analogous thing. Then Sage's own build system will be smart enough to deal with the .hg.json files, so that a tarball built using --paranoid will build fine with no further changes. Now, that would be nice, right? |
comment:6
git has a beautiful command called
If you plan on switching to git anytime soon, I recommend we just drop this ticket for now and work on getting I timed
Tests performed on a VirtualBox VM running on a 4-core i5-2500K @ 4.5 GHz with 8 GB of RAM. In summary: So obviously we should try to compress our "paranoid source archive" with lrzip if at all possible (it actually compresses down to less than half the size of the git repository itself!). We don't need to ship this with sage unless you want all users to be able to produce paranoid source archives. Users who want the source archive will of course need to install lrzip themselves. |
comment:7
The attachment [https://github.com/sagemath/sage/files/ticket12342/hg_json.gz does not work on
Or perhaps there is something wrong with |
comment:8
William, can you comment on my suggestion to abandon this until we switch to git, and the reasoning behind my suggestion? |
comment:9
Replying to @kini:
I'm fine with you abandoning this, but I hope it gets done. There is no telling when we will actually switch to git. I hope somebody does finish this ticket. |
comment:12
Now we have switched to git.. |
Reviewer: Marc Mezzarobba |
There should have been a usage message detailing the options.
There really are no tests at all of this. The ticket mercurial --> plain text --> mercurial #3052 where it was introduced talked about the challenge of writing tests, but then seemed to conclude with totally giving up. This is not acceptable. I'm totally opposed to ever introducing code into Sage that does anything useful if it doesn't have tests. If it isn't, tested then it will definitely be broken soon enough. This is exactly the sort of code that is likely to break too, due to Mercurial making some format change, us switching away from Mercurial etc. With no tests, the brokeness of this code could go unnoticed even if we switched all of sage to git.
The name bundle.json for the JSON hg repo could clash with an existing file, and is confusing, since it doesn't mention hg at all. It would be much better to use .hg_bundle.json, since by starting with ".hg" it's clear it is something that is reserved for Mercurial usage.
This code needs to be refactored. A bare minimum functionality for this should have been something like:
Then the other functionality could be built on that. As it is, just doing the conversion either way runs a bunch of code in the middle of a for loop (over spkg's). Currently the most basic functionality (which could be easily tested) is obfuscated; if it were available other people could easily build tools on top of it to do what they need (e.g., with their own hg repos).
Maybe I'm doing something wrong, but there are no directions, and if one can't just do "make text-expand" from a bare tarball, then there should be an immediate error message to that effect.
Anyway, needs work.
Component: distribution
Reviewer: Marc Mezzarobba
Issue created by migration from https://trac.sagemath.org/ticket/12342
The text was updated successfully, but these errors were encountered: