[PATCH 1 of 2 STABLE] label: enforce the lack of leading or trailing white space

Boris Feld boris.feld at octobus.net
Mon Feb 12 16:19:26 UTC 2018


# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1518448171 -3600
#      Mon Feb 12 16:09:31 2018 +0100
# Branch stable
# Node ID 23d835f2d32dfc2aac772a443d2061a57a8aa997
# Parent  7b2b82f891bf6355ed87c06ed9198bfcd033fe7d
# EXP-Topic noname
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 23d835f2d32d
label: enforce the lack of leading or trailing white space

In practice, all commands create label are currently striping external white
space. Let us enforce this logic at a lower level before starting to rely on
it elsewhere.

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -267,6 +267,8 @@ def checknewlabel(repo, lbl, kind):
         raise error.Abort(_("cannot use an integer as a name"))
     except ValueError:
         pass
+    if lbl.strip() != lbl:
+        raise error.Abort(_("leading or trailing whitespace in name %r") % lbl)
 
 def checkfilename(f):
     '''Check that the filename f is an acceptable filename for a tracked file'''


More information about the Mercurial-devel mailing list