hg under /

Benoit Boissinot benoit.boissinot at ens-lyon.org
Sun Nov 13 11:41:34 UTC 2005


On Sun, Nov 13, 2005 at 12:39:02PM +0100, Benoit Boissinot wrote:
> On 11/13/05, Arun Sharma <arun at sharma-home.net> wrote:
> > # cd /
> > # hg init
> > # hg add etc/profile
> > abort: etc/profile not under root
> >
> > The attached change works for me.
> >
> >         -Arun
> >
> > diff -r 979c04997448 mercurial/util.py
> > --- a/mercurial/util.py Fri Sep 16 20:34:29 2005
> > +++ b/mercurial/util.py Sat Nov 12 18:47:34 2005
> > @@ -110,7 +110,10 @@
> >
> >  def canonpath(root, cwd, myname):
> >      """return the canonical path of myname, given cwd and root"""
> > -    rootsep = root + os.sep
> > +    if root == os.sep:
> > +        rootsep = os.sep
> > +    else:
> > +       rootsep = root + os.sep
> >      name = myname
> >      if not name.startswith(os.sep):
> >          name = os.path.join(root, cwd, name)
> >
> >

Can you test this fix ? (it works for me)

thanks,

Benoit

# HG changeset patch
# User Benoit Boissinot <benoit.boissinot at ens-lyon.org>
# Node ID f700a38beaf44d0a2da777d815084ddf87e9c6da
# Parent  17180ca33cb3b3bb53f3640cfb59f788b5c4dbc9
correct util.canonpath to handle root finishing with os.sep

diff -r 17180ca33cb3 -r f700a38beaf4 mercurial/util.py
--- a/mercurial/util.py	Sun Nov 13 12:31:42 2005 +0100
+++ b/mercurial/util.py	Sun Nov 13 12:37:43 2005 +0100
@@ -166,15 +166,14 @@
 
 def canonpath(root, cwd, myname):
     """return the canonical path of myname, given cwd and root"""
-    rootsep = root + os.sep
+    root = os.path.normpath(root)
     name = myname
     if not name.startswith(os.sep):
         name = os.path.join(root, cwd, name)
     name = os.path.normpath(name)
-    if name.startswith(rootsep):
-        return pconvert(name[len(rootsep):])
-    elif name == root:
-        return ''
+    if name.startswith(root):
+        name = name[len(root):].lstrip(os.sep)
+        return pconvert(name)
     else:
         raise Abort('%s not under root' % myname)
 



More information about the Mercurial mailing list