Windows people: please help check idea for a new Mercurial repository layout

Adrian Buehlmann adrian at cadifra.com
Sun Jun 15 11:26:16 CDT 2008


On 15.06.2008 17:42, Matt Mackall wrote:
> On Sun, 2008-06-15 at 10:48 +0200, Adrian Buehlmann wrote:
> [deleted mostly unread]
> 
> Adrian, chill. I haven't made any sort of decision on what the solution
> is. I've merely suggested that \\?\ is worth considering. In particular
> it might be a good quick hack for people who need something that works
> today.

It's not even that. A simple good quick hack would be to prepend a dot
to every path component and use an additional requires entry.
So Windows folks could get along with Issue793.

Maybe something like this (just a quick hack, very lightly tested):

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -15,7 +15,7 @@

 class localrepository(repo.repository):
     capabilities = util.set(('lookup', 'changegroupsubset'))
-    supported = ('revlogv1', 'store')
+    supported = ('revlogv1', 'store', 'dotpath')

     def __init__(self, parentui, path=None, create=0):
         repo.repository.__init__(self)
@@ -30,7 +30,7 @@
                 if not os.path.exists(path):
                     os.mkdir(path)
                 os.mkdir(self.path)
-                requirements = ["revlogv1"]
+                requirements = ["revlogv1", "dotpath"]
                 if parentui.configbool('format', 'usestore', True):
                     os.mkdir(os.path.join(self.path, "store"))
                     requirements.append("store")
@@ -78,6 +78,11 @@
                 mode = None
         except OSError:
             mode = None
+
+        if "dotpath" in requirements:
+            self.dotpath = util.dotpath
+        else:
+            self.dotpath = lambda p: p

         self._createmode = mode
         self.opener.createmode = mode
@@ -486,7 +491,7 @@
     def file(self, f):
         if f[0] == '/':
             f = f[1:]
-        return filelog.filelog(self.sopener, f)
+        return filelog.filelog(self.sopener, self.dotpath(f))

     def changectx(self, changeid=None):
         return context.changectx(self, changeid)
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -905,6 +905,12 @@
         dir = os.path.join(dir, lpart)

     return ''.join(result)
+
+def dotpath(path):
+    '''Encode path to allow storing Windows reserved filenames
+    (e.g. 'nul', 'aux', 'prn', etc.)
+    path must be relative and using '/' as path separator'''
+    return '.' + path.replace('/', '/.')

 def checkexec(path):
     """

"Offcial" Mercurials on such a repo would give:

> hg verify
abort: requirement 'dotpath' not supported!

> What I have decided is that I'm not going to change the repo layout
> twice to fix two different stupid Windows annoyances. Any proposed
> solution must fix both.

If you don't want hashing, then there won't be a repo layout change for
the long paths anyway.

If you don't want to encode reserved filenames, then the shell
will even be unable to delete repos with reserved filenames.

I have just done a short quick scan for explorer alternatives which
might be able to deal with \\?\.. paths. I found none. I suspect
this is because Windows people want to use the recycle bin for deleting
stuff anyway, and that is a shell component again.

So, at least, if you wan't \\?\.. paths, you would have to provide
a command that can delete a repo. Users would then still have to
use hg for copying and backup (clone and bundle).

And you would have to tell them not to drag repos around with
explorer.





More information about the Mercurial mailing list