D4977: debugcommands: support wrapping long lines
indygreg (Gregory Szorc)
phabricator at mercurial-scm.org
Fri Oct 12 08:15:31 UTC 2018
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
If a line within a block is indented more than the line that came before,
we automatically concatenate it with the previous line. This allows us to
pretty format data. This will make tests easier to read.
At some point we may just want to evaluate entire blocks as Python
code or something, as even with this change, things aren't perfect, as we
can't e.g. have formatting like:
foo eval:[
True
]
But this is strictly better than before, where we couldn't wrap long lines.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D4977
AFFECTED FILES
mercurial/debugcommands.py
CHANGE DETAILS
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -2829,6 +2829,7 @@
def _parsewirelangblocks(fh):
activeaction = None
blocklines = []
+ lastindent = 0
for line in fh:
line = line.rstrip()
@@ -2845,14 +2846,22 @@
activeaction = line
blocklines = []
+ lastindent = 0
continue
# Else we start with an indent.
if not activeaction:
raise error.Abort(_('indented line outside of block'))
- blocklines.append(line)
+ indent = len(line) - len(line.lstrip())
+
+ # If this line is indented more than the last line, concatenate it.
+ if indent > lastindent and blocklines:
+ blocklines[-1] += line.lstrip()
+ else:
+ blocklines.append(line)
+ lastindent = indent
# Flush last block.
if activeaction:
To: indygreg, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list