comparison contrib/phabricator.py @ 34063:941c33cfde81

phabricator: standardize colors Previously, the `--confirm` text could have colors but the main `phabsend` does not. This patch adjusts the main command so it also has colors. A default color table was added so the colors are visible by default. Differential Revision: https://phab.mercurial-scm.org/D515
author Jun Wu <quark@fb.com>
date Thu, 24 Aug 2017 18:00:23 -0700
parents 088598153aa2
children 8b659b7388c0
comparison
equal deleted inserted replaced
34062:6c6169f71b8d 34063:941c33cfde81
57 ) 57 )
58 58
59 cmdtable = {} 59 cmdtable = {}
60 command = registrar.command(cmdtable) 60 command = registrar.command(cmdtable)
61 61
62 colortable = {
63 'phabricator.action.created': 'green',
64 'phabricator.action.skipped': 'magenta',
65 'phabricator.action.updated': 'magenta',
66 'phabricator.desc': '',
67 'phabricator.drev': 'bold',
68 'phabricator.node': '',
69 }
70
62 def urlencodenested(params): 71 def urlencodenested(params):
63 """like urlencode, but works with nested parameters. 72 """like urlencode, but works with nested parameters.
64 73
65 For example, if params is {'a': ['b', 'c'], 'd': {'e': 'f'}}, it will be 74 For example, if params is {'a': ['b', 'c'], 'd': {'e': 'f'}}, it will be
66 flattened to {'a[0]': 'b', 'a[1]': 'c', 'd[e]': 'f'} and then passed to 75 flattened to {'a[0]': 'b', 'a[1]': 'c', 'd[e]': 'f'} and then passed to
411 revision, diff = createdifferentialrevision( 420 revision, diff = createdifferentialrevision(
412 ctx, revid, lastrevid, oldnode, olddiff, actions) 421 ctx, revid, lastrevid, oldnode, olddiff, actions)
413 diffmap[ctx.node()] = diff 422 diffmap[ctx.node()] = diff
414 newrevid = int(revision[r'object'][r'id']) 423 newrevid = int(revision[r'object'][r'id'])
415 if revid: 424 if revid:
416 action = _('updated') 425 action = 'updated'
417 else: 426 else:
418 action = _('created') 427 action = 'created'
419 428
420 # Create a local tag to note the association, if commit message 429 # Create a local tag to note the association, if commit message
421 # does not have it already 430 # does not have it already
422 m = _differentialrevisiondescre.search(ctx.description()) 431 m = _differentialrevisiondescre.search(ctx.description())
423 if not m or int(m.group(1)) != newrevid: 432 if not m or int(m.group(1)) != newrevid:
426 date=None, local=True) 435 date=None, local=True)
427 else: 436 else:
428 # Nothing changed. But still set "newrevid" so the next revision 437 # Nothing changed. But still set "newrevid" so the next revision
429 # could depend on this one. 438 # could depend on this one.
430 newrevid = revid 439 newrevid = revid
431 action = _('skipped') 440 action = 'skipped'
432 441
433 ui.write(_('D%s: %s - %s: %s\n') % (newrevid, action, ctx, 442 actiondesc = ui.label(
434 ctx.description().split('\n')[0])) 443 {'created': _('created'),
444 'skipped': _('skipped'),
445 'updated': _('updated')}[action],
446 'phabricator.action.%s' % action)
447 drevdesc = ui.label('D%s' % newrevid, 'phabricator.drev')
448 nodedesc = ui.label(bytes(ctx), 'phabricator.node')
449 desc = ui.label(ctx.description().split('\n')[0], 'phabricator.desc')
450 ui.write(_('%s - %s - %s: %s\n') % (drevdesc, actiondesc, nodedesc,
451 desc))
435 drevids.append(newrevid) 452 drevids.append(newrevid)
436 lastrevid = newrevid 453 lastrevid = newrevid
437 454
438 # Update commit messages and remove tags 455 # Update commit messages and remove tags
439 if opts.get('amend'): 456 if opts.get('amend'):