[PATCH] record: add '--darcs' option to behave like 'darcs record'
Kirill Smelkov
kirr at mns.spb.ru
Wed Dec 26 09:29:14 UTC 2007
# HG changeset patch
# User Kirill Smelkov <kirr at mns.spb.ru>
# Date 1198661345 -10800
# Node ID a3305696c5008d7875c85c63993cd66c886b3cae
# Parent 1f9d5f4d519ce4b2f6b82c0f7da85b2a4f99348c
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,11 @@ def filterpatch(ui, chunks):
if resp_file[0] is not None:
return resp_file[0]
while True:
- r = (ui.prompt(query + _(' [Ynsfdaq?] '), '[Ynsfdaq?]?$',
+ uiprompt = ui.prompt
+ if opts['darcs']:
+ uiprompt = ui.prompt_key # mimic darcs behaviour
+
+ r = (uiprompt(query + _(' [Ynsfdaq?] '), '[Ynsfdaq?]?$',
matchflags=re.I) or 'y').lower()
if r == '?':
c = record.__doc__.find('y - record this change')
@@ -339,7 +343,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 +414,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