[PATCH 2 of 2 V2] revset: skip old style lookup if external whitespace are detected

Feld Boris boris.feld at octobus.net
Thu Mar 1 19:34:21 UTC 2018


On 27/02/2018 10:47, Yuya Nishihara wrote:
> On Mon, 26 Feb 2018 21:42:01 -0500, Matt Harbison wrote:
>> On Mon, 26 Feb 2018 05:45:03 -0500, Feld Boris <boris.feld at octobus.net>
>> wrote:
>>> On 13/02/2018 12:47, Yuya Nishihara wrote:
>>>> On Mon, 12 Feb 2018 18:00:52 +0100, Boris Feld wrote:
>>>>> # HG changeset patch
>>>>> # User Boris Feld <boris.feld at octobus.net>
>>>>> # Date 1518448909 -3600
>>>>> #      Mon Feb 12 16:21:49 2018 +0100
>>>>> # Node ID b0f45e1376e2d0f32023e197c51802bc21c60490
>>>>> # Parent  f02fd7ca256d044c4a51c3f3fc0ecaf95d23e03d
>>>>> # EXP-Topic noname
>>>>> # Available At https://bitbucket.org/octobus/mercurial-devel/
>>>>> #              hg pull https://bitbucket.org/octobus/mercurial-devel/
>>>>> -r b0f45e1376e2
>>>>> revset: skip old style lookup if external whitespace are detected
>>>>>
>>>>> Since label cannot contains leading or trailing whitespace we can skip
>>>>> looking
>>>>> for them.
>> I meant to chime in the first time I saw this, but this isn't necessarily
>> true.  I converted a bzr repo a few weeks ago, and it carried over not
>> only trailing spaces, but LF in the middle of the tag name.  That made the
>> .hgtags file... entertaining.  That can be fixed, but there might be such
>> labels in the wild.
> Ugh, I didn't know that, thanks. So we can't assume existing "names" have no
> leading/trailing spaces, even though we can enforce that for new ones.

The logic for reading tags from disk is explicitly splitting on 
new-lines and stripping external whitespaces:

https://www.mercurial-scm.org/repo/hg/file/tip/mercurial/tags.py#l226
https://www.mercurial-scm.org/repo/hg/file/tip/mercurial/tags.py#l290

Because of this, the rest of code is guaranteed that tags do not have 
external whitespace or new lines. Same applies to bookmarks. Branches go 
through the extra field logic who have a lot of similar limitation.

@Maat, could you check if you can list such tags and reference them in a 
revset? It not, I think we can safely consider them as invalid and file 
a bug to fix the issue in convert and stick to the current assumption 
that symbols cannot contain such special characters.


More information about the Mercurial-devel mailing list