[PATCH 4 of 4] record: add '--darcs' option to behave like 'darcs record'

Kirill Smelkov kirr at mns.spb.ru
Thu Dec 27 07:48:39 CST 2007


# HG changeset patch
# User Kirill Smelkov <kirr at mns.spb.ru>
# Date 1198762489 -10800
# Node ID da7e928f3469491ea54df80cef2b31dcd488d6fb
# Parent  5ce7ac984fd1c257ebf52063079bc049dd05f35f
record: add '--darcs' option to behave like 'darcs record'

rationale: I used to use Darcs a lot, so it is more convenient to just
rationale: press 'y' or 'n' instead of constantly pressing 'n'+Enter, when
rationale: recording a patch.

diff --git a/hgext/record.py b/hgext/record.py
--- a/hgext/record.py
+++ b/hgext/record.py
@@ -226,7 +226,7 @@ def parsepatch(fp):
         state = newstate
     return p.finished()
 
-def filterpatch(ui, chunks):
+def filterpatch(ui, chunks, opts):
     chunks = list(chunks)
     chunks.reverse()
     seen = {}
@@ -247,7 +247,10 @@ def filterpatch(ui, chunks):
         if resp_file[0] is not None:
             return resp_file[0]
         while True:
-            r = (ui.prompt(query + _(' [Ynsfdaq?] '), '(?i)[Ynsfdaq?]?$')
+            uiprompt = ui.prompt
+            if opts['darcs']:
+                uiprompt = ui.prompt_key    # mimic darcs behaviour
+            r = (uiprompt(query + _(' [Ynsfdaq?] '), '(?i)[Ynsfdaq?]?$')
                  or 'y').lower()
             if r == '?':
                 c = record.__doc__.find('y - record this change')
@@ -339,7 +342,7 @@ def record(ui, repo, *pats, **opts):
                    match=match, changes=changes, opts=diffopts, fp=fp)
         fp.seek(0)
 
-        chunks = filterpatch(ui, parsepatch(fp))
+        chunks = filterpatch(ui, parsepatch(fp), opts)
         del fp
 
         contenders = {}
@@ -410,6 +413,7 @@ cmdtable = {
         (record,
          [('A', 'addremove', None,
            _('mark new/missing files as added/removed before committing')),
+          ('', 'darcs', None, _('try to mimic "darcs record"')),
          ] + commands.walkopts + commands.commitopts + commands.commitopts2,
          _('hg record [OPTION]... [FILE]...')),
 }


More information about the Mercurial-devel mailing list