comparison hgext/histedit.py @ 24199:4047982904f8

histedit: add a config allowing changing histedit rule line length limit Since many users are using terminals wider than 80 chars there should be an option to have longer lines in histedit editor. Even if the summary line is shorter than 80 chars after adding action line prefixes (like "pick 7c2fd3b9020c") it doesn't fit there anymore. Setting it to for example 110 would be a nice option to have.
author Mateusz Kwapich <mitrandir@fb.com>
date Wed, 21 Jan 2015 14:45:24 -0800
parents c3d13202144d
children cc5b46f5318d
comparison
equal deleted inserted replaced
24196:c3d13202144d 24199:4047982904f8
140 140
141 If you run ``hg histedit --outgoing`` on the clone then it is the same 141 If you run ``hg histedit --outgoing`` on the clone then it is the same
142 as running ``hg histedit 836302820282``. If you need plan to push to a 142 as running ``hg histedit 836302820282``. If you need plan to push to a
143 repository that Mercurial does not detect to be related to the source 143 repository that Mercurial does not detect to be related to the source
144 repo, you can add a ``--force`` option. 144 repo, you can add a ``--force`` option.
145
146 Histedit rule lines are truncated to 80 characters by default. You
147 can customise this behaviour by setting a different length in your
148 configuration file:
149
150 [histedit]
151 linelen = 120 # truncate rule lines at 120 characters
145 """ 152 """
146 153
147 try: 154 try:
148 import cPickle as pickle 155 import cPickle as pickle
149 pickle.dump # import now 156 pickle.dump # import now
841 summary = '' 848 summary = ''
842 if ctx.description(): 849 if ctx.description():
843 summary = ctx.description().splitlines()[0] 850 summary = ctx.description().splitlines()[0]
844 line = '%s %s %d %s' % (action, ctx, ctx.rev(), summary) 851 line = '%s %s %d %s' % (action, ctx, ctx.rev(), summary)
845 # trim to 80 columns so it's not stupidly wide in my editor 852 # trim to 80 columns so it's not stupidly wide in my editor
846 return util.ellipsis(line, 80) 853 maxlen = repo.ui.configint('histedit', 'linelen', default=80)
854 maxlen = max(maxlen, 22) # avoid truncating hash
855 return util.ellipsis(line, maxlen)
847 856
848 def ruleeditor(repo, ui, rules, editcomment=""): 857 def ruleeditor(repo, ui, rules, editcomment=""):
849 """open an editor to edit rules 858 """open an editor to edit rules
850 859
851 rules are in the format [ [act, ctx], ...] like in state.rules 860 rules are in the format [ [act, ctx], ...] like in state.rules