comparison 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
comparison
equal deleted inserted replaced
30702:7e4f431206cd 30703:5c85c93cdd61
46 templatekw, 46 templatekw,
47 templater, 47 templater,
48 util, 48 util,
49 ) 49 )
50 stringio = util.stringio 50 stringio = util.stringio
51
52 # special string such that everything below this line will be ingored in the
53 # editor text
54 _linebelow = "^HG: ------------------------ >8 ------------------------$"
51 55
52 def ishunk(x): 56 def ishunk(x):
53 hunkclasses = (crecordmod.uihunk, patch.recordhunk) 57 hunkclasses = (crecordmod.uihunk, patch.recordhunk)
54 return isinstance(x, hunkclasses) 58 return isinstance(x, hunkclasses)
55 59
2765 repo.dirstate.write(tr) 2769 repo.dirstate.write(tr)
2766 pending = tr and tr.writepending() and repo.root 2770 pending = tr and tr.writepending() and repo.root
2767 2771
2768 editortext = repo.ui.edit(committext, ctx.user(), ctx.extra(), 2772 editortext = repo.ui.edit(committext, ctx.user(), ctx.extra(),
2769 editform=editform, pending=pending) 2773 editform=editform, pending=pending)
2774
2775 # strip away anything below this special string (used for editors that want
2776 # to display the diff)
2777 stripbelow = re.search(_linebelow, editortext, flags=re.MULTILINE)
2778 if stripbelow:
2779 editortext = editortext[:stripbelow.start()]
2780
2770 text = re.sub("(?m)^HG:.*(\n|$)", "", editortext) 2781 text = re.sub("(?m)^HG:.*(\n|$)", "", editortext)
2771 os.chdir(olddir) 2782 os.chdir(olddir)
2772 2783
2773 if finishdesc: 2784 if finishdesc:
2774 text = finishdesc(text) 2785 text = finishdesc(text)