Mercurial > public > mercurial-scm > hg-stable
diff mercurial/cmdutil.py @ 30703:5c85c93cdd61
cmdutil: add special string that ignores rest of text
Similar to git, we add a special string:
HG: ------------------------ >8 ------------------------
that means anything below it is ignored in a commit message.
This is helpful for integrating with third-party tools that display the
author | Sean Farley <sean@farley.io> |
---|---|
date | Sat, 31 Dec 2016 15:36:36 -0600 |
parents | f05ede08dcf7 |
children | 7e95e70bad57 |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Sat May 14 20:52:44 2016 +0900 +++ b/mercurial/cmdutil.py Sat Dec 31 15:36:36 2016 -0600 @@ -49,6 +49,10 @@ ) stringio = util.stringio +# special string such that everything below this line will be ingored in the +# editor text +_linebelow = "^HG: ------------------------ >8 ------------------------$" + def ishunk(x): hunkclasses = (crecordmod.uihunk, patch.recordhunk) return isinstance(x, hunkclasses) @@ -2767,6 +2771,13 @@ editortext = repo.ui.edit(committext, ctx.user(), ctx.extra(), editform=editform, pending=pending) + + # strip away anything below this special string (used for editors that want + # to display the diff) + stripbelow = re.search(_linebelow, editortext, flags=re.MULTILINE) + if stripbelow: + editortext = editortext[:stripbelow.start()] + text = re.sub("(?m)^HG:.*(\n|$)", "", editortext) os.chdir(olddir)