D5186: help: when replacing placeholders in help files, insert indented text

yuja (Yuya Nishihara) phabricator at mercurial-scm.org
Wed Oct 24 07:45:37 EDT 2018


yuja added a comment.


  > - a/mercurial/help.py +++ b/mercurial/help.py @@ -391,6 +391,12 @@ single documentation block and use it to overwrite the marker in doc. """ entries = [] +    markerindent = 0 +    markerpos = doc.find(marker) +    if markerpos >= 0: +        newlinepos = doc.rfind('\n', 0, markerpos) +        if newlinepos >= 0: +            markerindent = markerpos - newlinepos - 1
  
  Perhaps, it's simpler to use re.sub() instead of doc.replace(...), something
  like:
  
    markerre = re.compile(br'^(\s*)%s' % re.escape(marker), re.MULTILINE)
    markerre.sub(builditemsdoc, doc)

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5186

To: valentin.gatienbaron, #hg-reviewers
Cc: yuja, mercurial-devel


More information about the Mercurial-devel mailing list