mercurial/cmdutil.py
changeset 30703 5c85c93cdd61
parent 30695 f05ede08dcf7
child 30710 7e95e70bad57
--- 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)