[PATCH 2 of 3] merge: abort on file/directory case folding collisions (issue4892)

Augie Fackler raf at durin42.com
Wed Oct 14 09:30:33 CDT 2015


On Wed, Oct 14, 2015 at 10:58:48AM +0200, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski at unity3d.com>
> # Date 1444688185 -7200
> #      Tue Oct 13 00:16:25 2015 +0200
> # Node ID 3a03a1042b79d1c84b7cfa32defb5508afb35502
> # Parent  b7a28c7c17f4e0888ed0d90f6a35284aa44444e6
> merge: abort on file/directory case folding collisions (issue4892)

Taking these, thanks. Will read and discuss patch 3 (which is an RFC) shortly.

>
> File/directory case folding collisions cannot be represented on case folding
> systems and have to fail.
>
> To detect this and abort early, utilize that for file/directory collisions, a
> sorted list of case folded manifest names will have the colliding directory
> right after the file.
>
> (This could perhaps be optimized, but this way of doing it also has
> directory/directory case folding in mind ... which however not is handled yet.)
>
> diff --git a/mercurial/merge.py b/mercurial/merge.py
> --- a/mercurial/merge.py
> +++ b/mercurial/merge.py
> @@ -436,6 +436,17 @@ def _checkcollision(repo, wmf, actions):
>                               % (f, foldmap[fold]))
>          foldmap[fold] = f
>
> +    # check case-folding of directories
> +    foldprefix = unfoldprefix = lastfull = ''
> +    for fold, f in sorted(foldmap.items()):
> +        if fold.startswith(foldprefix) and not f.startswith(unfoldprefix):
> +            # the folded prefix matches but actual casing is different
> +            raise error.Abort(_("case-folding collision between "
> +                                "%s and directory of %s") % (lastfull, f))
> +        foldprefix = fold + '/'
> +        unfoldprefix = f + '/'
> +        lastfull = f
> +
>  def manifestmerge(repo, wctx, p2, pa, branchmerge, force, partial,
>                    acceptremote, followcopies):
>      """
> diff --git a/tests/test-casecollision-merge.t b/tests/test-casecollision-merge.t
> --- a/tests/test-casecollision-merge.t
> +++ b/tests/test-casecollision-merge.t
> @@ -212,7 +212,7 @@ Directory/file case-folding collision:
>    $ hg ci -Aqm1
>
>    $ hg merge 0
> -  abort: Not a directory: '$TESTTMP/directory-casing/aA/a'
> +  abort: case-folding collision between Aa and directory of aA/a
>    [255]
>  (note: no collision between 0 and 00 or 000/f)
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list