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

login
register
mail settings
Submitter Boris Feld
Date Feb. 12, 2018, 4:19 p.m.
Message ID <23d835f2d32dfc2aac77.1518452366@FB>
Download mbox | patch
Permalink /patch/27670/
State Superseded
Headers show

Comments

Boris Feld - Feb. 12, 2018, 4:19 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@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.

Patch

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'''