[PATCH 1 of 6] py3: use startswith() instead of slicing to detect leading whitespace

Yuya Nishihara yuya at tcha.org
Sun Mar 4 21:41:36 UTC 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1520195085 18000
#      Sun Mar 04 15:24:45 2018 -0500
# Node ID f7cd53c5127f248f5d075ad28b6be82558b7c35d
# Parent  6bacb2f663cb07f58bb493db5f21ae321d5a2e06
py3: use startswith() instead of slicing to detect leading whitespace

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -158,7 +158,7 @@ def _formatparse(write, inst):
     if len(inst.args) > 1:
         write(_("hg: parse error at %s: %s\n") %
               (pycompat.bytestr(inst.args[1]), inst.args[0]))
-        if (inst.args[0][0] == ' '):
+        if inst.args[0].startswith(' '):
             write(_("unexpected leading whitespace\n"))
     else:
         write(_("hg: parse error: %s\n") % inst.args[0])


More information about the Mercurial-devel mailing list