Patchwork [5,of,5,V2] transplant: use "ui.extractchoices()" to show the list of available responses

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Nov. 28, 2013, 3:11 p.m.
Message ID <b9a4fcbb58975f518745.1385651492@juju>
Download mbox | patch
Permalink /patch/3188/
State Superseded
Headers show

Comments

Katsunori FUJIWARA - Nov. 28, 2013, 3:11 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1385651260 -32400
#      Fri Nov 29 00:07:40 2013 +0900
# Node ID b9a4fcbb58975f518745d4e9fb63ae5e502a9bf6
# Parent  93639c1024e62de1f9c21d0ce784c9f41e1e34c1
transplant: use "ui.extractchoices()" to show the list of available responses

Before this patch, transplant extension shows the list of available
responses by specific string, even though the prompt string passed to
"ui.promptchoice()" has enough (maybe i18n-ed) information.

This patch uses "ui.extractchoices()" to show the list of available
responses.

Patch

diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -451,15 +451,6 @@ 
 
 def browserevs(ui, repo, nodes, opts):
     '''interactively transplant changesets'''
-    def browsehelp(ui):
-        ui.write(_('y: transplant this changeset\n'
-                   'n: skip this changeset\n'
-                   'm: merge at this changeset\n'
-                   'p: show patch\n'
-                   'c: commit selected changesets\n'
-                   'q: cancel transplant\n'
-                   '?: show this help\n'))
-
     displayer = cmdutil.show_changeset(ui, repo, opts)
     transplants = []
     merges = []
@@ -477,7 +468,8 @@ 
         while not action:
             action = 'ynmpcq?'[ui.promptchoice(prompt)]
             if action == '?':
-                browsehelp(ui)
+                for c, t in ui.extractchoices(prompt)[1]:
+                    ui.write('%s: %s\n' % (c, t))
                 action = None
             elif action == 'p':
                 parent = repo.changelog.parents(node)[0]
diff --git a/tests/test-transplant.t b/tests/test-transplant.t
--- a/tests/test-transplant.t
+++ b/tests/test-transplant.t
@@ -493,13 +493,13 @@ 
   > EOF
   1:d11e3596cc1a
   apply changeset? [ynmpcq?]: unrecognized response
-  apply changeset? [ynmpcq?]: y: transplant this changeset
-  n: skip this changeset
+  apply changeset? [ynmpcq?]: y: yes, transplant this changeset
+  n: no, skip this changeset
   m: merge at this changeset
   p: show patch
   c: commit selected changesets
-  q: cancel transplant
-  ?: show this help
+  q: quit and cancel transplant
+  ?: ? (show this help)
   apply changeset? [ynmpcq?]: 4:a53251cdf717
   apply changeset? [ynmpcq?]:  (no-eol)
   $ hg heads --template "{node|short}\n"