comparison hgext/extdiff.py @ 27680:c750245c6b85

extdiff: factor out list of common options
author Yuya Nishihara <yuya@tcha.org>
date Mon, 04 Jan 2016 22:13:46 +0900
parents 56b2bcea2529
children 174069440929
comparison
equal deleted inserted replaced
27679:6822f9382b4c 27680:c750245c6b85
268 return 1 268 return 1
269 finally: 269 finally:
270 ui.note(_('cleaning up temp directory\n')) 270 ui.note(_('cleaning up temp directory\n'))
271 shutil.rmtree(tmproot) 271 shutil.rmtree(tmproot)
272 272
273 @command('extdiff', 273 extdiffopts = [
274 [('p', 'program', '',
275 _('comparison program to run'), _('CMD')),
276 ('o', 'option', [], 274 ('o', 'option', [],
277 _('pass option to comparison program'), _('OPT')), 275 _('pass option to comparison program'), _('OPT')),
278 ('r', 'rev', [], _('revision'), _('REV')), 276 ('r', 'rev', [], _('revision'), _('REV')),
279 ('c', 'change', '', _('change made by revision'), _('REV')), 277 ('c', 'change', '', _('change made by revision'), _('REV')),
280 ('', 'patch', None, _('compare patches for two revisions')) 278 ('', 'patch', None, _('compare patches for two revisions'))
281 ] + commands.walkopts + commands.subrepoopts, 279 ] + commands.walkopts + commands.subrepoopts
280
281 @command('extdiff',
282 [('p', 'program', '', _('comparison program to run'), _('CMD')),
283 ] + extdiffopts,
282 _('hg extdiff [OPT]... [FILE]...'), 284 _('hg extdiff [OPT]... [FILE]...'),
283 inferrepo=True) 285 inferrepo=True)
284 def extdiff(ui, repo, *pats, **opts): 286 def extdiff(ui, repo, *pats, **opts):
285 '''use external program to diff repository (or selected files) 287 '''use external program to diff repository (or selected files)
286 288
366 # Decoding the string to a Unicode string here (using the 368 # Decoding the string to a Unicode string here (using the
367 # right encoding) prevents that. 369 # right encoding) prevents that.
368 mydiff.__doc__ = doc.decode(encoding.encoding) 370 mydiff.__doc__ = doc.decode(encoding.encoding)
369 return mydiff 371 return mydiff
370 cmdtable[cmd] = (save(cmdline), 372 cmdtable[cmd] = (save(cmdline),
371 cmdtable['extdiff'][1][1:], 373 extdiffopts[:],
372 _('hg %s [OPTION]... [FILE]...') % cmd) 374 _('hg %s [OPTION]... [FILE]...') % cmd)