[PATCH 4 of 8] Fix for issue 1092 (hg add gives wrong result when filename case doesn't match)

Patrick Mézard pmezard at gmail.com
Fri May 2 06:04:53 CDT 2008


Paul Moore a écrit :
> # HG changeset patch
> # User "Paul Moore <p.f.moore at gmail.com>"
> # Date 1209573965 -3600
> # Node ID c7ddd7a0bf7b980bf39ccd206cf19ca86f95f281
> # Parent  5019b1549bd8859012b7954c649345d344149bec
> Fix for issue 1092 (hg add gives wrong result when filename case doesn't match)
> 
> In commands.add, use the fspath return value from cmdutil.walk, to add the
> file with the correct case.
> 
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -36,11 +36,11 @@
>          if exact:
>              if ui.verbose:
>                  ui.status(_('adding %s\n') % rel)
> -            names.append(abs)
> -            exacts[abs] = 1
> -        elif abs not in repo.dirstate:
> +            names.append(fsabs)
> +            exacts[fsabs] = 1
> +        elif fsabs not in repo.dirstate:

This is related to your remark about paths comparison, here you assume the dirstate is made of fspath entries. This is not enforced by current code. For instance dirstate.normal(fn) just stats and add the name as such in the mapping. I don't have a solution right now, just mentioning it.

This issue can probably arise through cmdline -> status -> dirstate.normal() calls because localrepo.status() does not return fspath.

>              ui.status(_('adding %s\n') % rel)
> -            names.append(abs)
> +            names.append(fsabs)
>      if not opts.get('dry_run'):
>          rejected = repo.add(names)
>          rejected = [p for p in rejected if p in exacts]



More information about the Mercurial-devel mailing list