[PATCH] changeset: add filename derived anchors to file diffs (and use them)
Søren Løvborg
sorenl at unity3d.com
Mon Feb 22 17:51:59 UTC 2016
> What I want is to make it possible (and easy!) for a user to correctly
> guess the link that it would need to manually create to open Kallithea
> on the right changeset on the right file. I plan to use this to let a
> user quickly start reviewing a file from TortosieHg.
Seems like it should be trivial for TortoiseHg to calculate a SHA-1, but
sure, you need to know how the encoding works.
> However I found that when the files have periods and slashes in them
Yes. The slash is invalid, the period is not. It would appear that you
haven't observed problems with periods, and what you're seeing is caused
by use of the slash character.
> I think it is unlikely that paths will have colons (since these are
> always relative paths)
Outside Windows, paths can contain colons just fine. Probably not too
common, but again, I would want to avoid weird edge cases.
But if readability is a priority, it sounds like we should just go with:
id = 'file:' + urllib.quote(filename, '').replace('%', ':')
Note empty string as second argument to urllib.quote, to ensure escaping
of slashes.
This will generate IDs which are always valid, unique and semi-readable,
e.g. 'file:kallithea:2Flib:2Futils.py' or 'file::3A:2F:25' - that's the
odd but valid filename ':/%'. ;-)
Best,
Søren
More information about the kallithea-general
mailing list