[PATCH 2 of 2] Enforce unixish patch names everywhere

Patrick Mezard pmezard at gmail.com
Wed Jan 17 14:34:22 CST 2007


# HG changeset patch
# User Patrick Mezard <pmezard at gmail.com>
# Date 1169068839 -3600
# Node ID 5ae302330962a9f88f6f1a9f86442f95ca0d5019
# Parent  bbdba01cce28a329de71380441935c198cda5069
Enforce unixish patch names everywhere.

This will break compatibility with win32 patch repositories already containing patches in subdirectories. Could be corrected by manually doctoring the series file to replace backslashes with slashes.

diff -r bbdba01cce28 -r 5ae302330962 hgext/mq.py
--- a/hgext/mq.py	Wed Jan 17 22:19:36 2007 +0100
+++ b/hgext/mq.py	Wed Jan 17 22:20:39 2007 +0100
@@ -116,6 +116,9 @@ class queue:
                 comment = l[h:]
             patch = patch.strip()
             if patch:
+                if patch!=normname(patch):
+                    raise util.Abort(_('%s is not a valid patch name in %s') %
+                                     (patch, self.join(self.series_path)))
                 if patch in self.series:
                     raise util.Abort(_('%s appears more than once in %s') %
                                      (patch, self.join(self.series_path)))
@@ -1299,6 +1302,9 @@ class queue:
         if (len(files) > 1 or len(rev) > 1) and patchname:
             raise util.Abort(_('option "-n" not valid when importing multiple '
                                'patches'))
+        if patchname and patchname!=normname(patchname):
+            raise util.Abort(_('%s is not a valid patch name' % patchname))
+                               
         i = 0
         added = []
         if rev:
@@ -1361,7 +1367,7 @@ class queue:
                 if filename == '-':
                     raise util.Abort(_('-e is incompatible with import from -'))
                 if not patchname:
-                    patchname = normname(filename)
+                    patchname = filename
                 if not os.path.isfile(self.join(patchname)):
                     raise util.Abort(_("patch %s does not exist") % patchname)
             else:
@@ -1375,10 +1381,11 @@ class queue:
                 except IOError:
                     raise util.Abort(_("unable to read %s") % patchname)
                 if not patchname:
-                    patchname = normname(os.path.basename(filename))
+                    patchname = os.path.basename(filename)
                 checkfile(patchname)
                 patchf = self.opener(patchname, "w")
                 patchf.write(text)
+            patchname = normname(patchname)
             checkseries(patchname)
             index = self.full_series_end() + i
             self.full_series[index:index] = [patchname]


More information about the Mercurial-devel mailing list