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

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Nov. 28, 2013, 3:11 p.m.
Message ID <0056d0328e28e20df118.1385651489@juju>
Download mbox | patch
Permalink /patch/3187/
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 0056d0328e28e20df118ecdcd1e058cbe65c0ddc
# Parent  2b4399a017a613c97a8c0489b267209b1684d208
record: use "ui.extractchoices()" to get the list of available responses

Before this patch, record extension gets the list of available
responses from online help document of "hg record" in the tricky way,
even though the value passed to "ui.promptchoice()" has enough (maybe
i18n-ed) information.

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

Patch

diff --git a/hgext/record.py b/hgext/record.py
--- a/hgext/record.py
+++ b/hgext/record.py
@@ -7,7 +7,7 @@ 
 
 '''commands to interactively select changes for commit/qrefresh'''
 
-from mercurial.i18n import gettext, _
+from mercurial.i18n import _
 from mercurial import cmdutil, commands, extensions, hg, patch
 from mercurial import util
 import copy, cStringIO, errno, os, re, shutil, tempfile
@@ -286,21 +286,18 @@ 
             resps = _('[Ynesfdaq?]'
                       '$$ &Yes, record this change'
                       '$$ &No, skip this change'
-                      '$$ &Edit the change manually'
+                      '$$ &Edit this change manually'
                       '$$ &Skip remaining changes to this file'
                       '$$ Record remaining changes to this &file'
                       '$$ &Done, skip remaining changes and files'
                       '$$ Record &all changes to all remaining files'
                       '$$ &Quit, recording no changes'
-                      '$$ &?')
+                      '$$ &? (display help)')
             r = ui.promptchoice("%s %s" % (query, resps))
             ui.write("\n")
             if r == 8: # ?
-                doc = gettext(record.__doc__)
-                c = doc.find('::') + 2
-                for l in doc[c:].splitlines():
-                    if l.startswith('      '):
-                        ui.write(l.strip(), '\n')
+                for c, t in ui.extractchoices(resps)[1]:
+                    ui.write('%s - %s\n' % (c, t.lower()))
                 continue
             elif r == 0: # yes
                 ret = True
diff --git a/tests/test-record.t b/tests/test-record.t
--- a/tests/test-record.t
+++ b/tests/test-record.t
@@ -673,15 +673,15 @@ 
   diff --git a/subdir/f1 b/subdir/f1
   1 hunks, 1 lines changed
   examine changes to 'subdir/f1'? [Ynesfdaq?] 
-  y - record this change
-  n - skip this change
+  y - yes, record this change
+  n - no, skip this change
   e - edit this change manually
   s - skip remaining changes to this file
   f - record remaining changes to this file
   d - done, skip remaining changes and files
   a - record all changes to all remaining files
   q - quit, recording no changes
-  ? - display help
+  ? - ? (display help)
   examine changes to 'subdir/f1'? [Ynesfdaq?] 
   abort: user quit
   [255]