[PATCH] changeset: add filename derived anchors to file diffs (and use them)

Angel Ezquerra angel.ezquerra at gmail.com
Mon Feb 22 21:47:56 UTC 2016


On Mon, Feb 22, 2016 at 6:51 PM, Søren Løvborg <sorenl at unity3d.com> wrote:
>> 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

Hi again Soren,

I'm sorry but your suggestion does not work. I just tried it. I really
think that the problem is caused by both periods and forward slashes.
When I remove them (as in my modified proposal) it works fine.

Cheers,

Angel


More information about the kallithea-general mailing list