[PATCH] Fix hg copy name sanitation (was [BUG] hg copy accepting paths that are broken)

Matt Mackall mpm at selenic.com
Fri Sep 9 16:55:27 CDT 2005


On Fri, Sep 09, 2005 at 03:53:31PM -0400, Daniel Santa Cruz wrote:
> On 9/9/05, Bryan O'Sullivan <bos at serpentine.com> wrote:
> > On Fri, 2005-09-09 at 12:09 -0400, Daniel Santa Cruz wrote:
> > > Running hg from tip under windows:
> 
> This patch does not fix the orinigal post.  The original post is about
> hg accepting bad paths in "hg copy".  This patch fixes the fact that
> paths had to use [/] as pathsep, and would not work with window's [\]
> pathsep.  I'm not sure if this is a good way to fix the issue, and I'm
> not sure if the other references to "f" below the proposed fixes also
> need "sanitizing"
> 
> Daniel
> 
> diff -r ea90162e210c mercurial/dirstate.py
> --- a/mercurial/dirstate.py     Fri Sep 09 00:09:31 2005
> +++ b/mercurial/dirstate.py     Fri Sep 09 15:48:59 2005
> @@ -138,12 +138,12 @@
>          self.markdirty()
>          for f in files:
>              if state == "r":
> -                self.map[f] = ('r', 0, 0, 0)
> +                self.map[util.pconvert(f)] = ('r', 0, 0, 0)
>              else:
>                  s = os.stat(os.path.join(self.root, f))
>                  st_size = kw.get('st_size', s.st_size)
>                  st_mtime = kw.get('st_mtime', s.st_mtime)
> -                self.map[f] = (state, s.st_mode, st_size, st_mtime)
> +                self.map[util.pconvert(f)] = (state, s.st_mode,
> st_size, st_mtime)
>              if self.copies.has_key(f):
>                  del self.copies[f]

This is probably the wrong level to sanitize paths. It should instead
happen at the OS <-> core interface (os.listdir, etc) and the core <->
user interface.

-- 
Mathematics is the supreme nostalgia of our time.


More information about the Mercurial mailing list