comparison hgext/histedit.py @ 27203:b6a0f0895a25

histedit: add torule method to histedit action objects To make histedit action objects responsible for understanding the format of their action lines we are adding a torule method which for a histedit action will return a string which can be saved in histedit state or shown in text editor when editing the plan.
author Mateusz Kwapich <mitrandir@fb.com>
date Wed, 02 Dec 2015 12:19:01 -0800
parents 2226cd4f32ed
children 6b77e749af4a
comparison
equal deleted inserted replaced
27202:2226cd4f32ed 27203:b6a0f0895a25
356 try: 356 try:
357 self.node = repo[ha].node() 357 self.node = repo[ha].node()
358 except error.RepoError: 358 except error.RepoError:
359 raise error.Abort(_('unknown changeset %s listed') 359 raise error.Abort(_('unknown changeset %s listed')
360 % ha[:12]) 360 % ha[:12])
361
362 def torule(self):
363 """build a histedit rule line for an action
364
365 by default lines are in the form:
366 <hash> <rev> <summary>
367 """
368 ctx = self.repo[self.node]
369 summary = ''
370 if ctx.description():
371 summary = ctx.description().splitlines()[0]
372 line = '%s %s %d %s' % (self.verb, ctx, ctx.rev(), summary)
373 # trim to 75 columns by default so it's not stupidly wide in my editor
374 # (the 5 more are left for verb)
375 maxlen = self.repo.ui.configint('histedit', 'linelen', default=80)
376 maxlen = max(maxlen, 22) # avoid truncating hash
377 return util.ellipsis(line, maxlen)
361 378
362 def constraints(self): 379 def constraints(self):
363 """Return a set of constrains that this action should be verified for 380 """Return a set of constrains that this action should be verified for
364 """ 381 """
365 return set([_constraints.noduplicates, _constraints.noother]) 382 return set([_constraints.noduplicates, _constraints.noother])