[PATCH 3 of 5] record: change interface of dorecord to accept new filters
Laurent Charignon
lcharignon at fb.com
Thu Mar 12 17:00:43 CDT 2015
# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1426117178 25200
# Wed Mar 11 16:39:38 2015 -0700
# Node ID eb5ff33e1774cd9897c61919dbc8484eab1705b8
# Parent 88ab688a80aab8383de31f6742bb0aaba5ccee0d
record: change interface of dorecord to accept new filters
This makes it easier to add different filtering logic (record /crecord ...)
diff --git a/hgext/record.py b/hgext/record.py
--- a/hgext/record.py
+++ b/hgext/record.py
@@ -66,7 +66,8 @@
mq.refresh(ui, repo, **opts)
# backup all changed files
- cmdutil.dorecord(ui, repo, committomq, 'qrefresh', True, *pats, **opts)
+ cmdutil.dorecord(ui, repo, committomq, 'qrefresh', True,
+ cmdutil.recordfilter, *pats, **opts)
# This command registration is replaced during uisetup().
@command('qrecord',
@@ -91,7 +92,8 @@
opts['checkname'] = False
mq.new(ui, repo, patch, *pats, **opts)
- cmdutil.dorecord(ui, repo, committomq, 'qnew', False, *pats, **opts)
+ cmdutil.dorecord(ui, repo, committomq, 'qnew', False,
+ cmdutil.recordfilter, *pats, **opts)
def qnew(origfn, ui, repo, patch, *args, **opts):
if opts['interactive']:
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -19,7 +19,11 @@
def parsealiases(cmd):
return cmd.lstrip("^").split("|")
-def dorecord(ui, repo, commitfunc, cmdsuggest, backupall, *pats, **opts):
+def recordfilter(ui, fp):
+ return patch.filterpatch(ui, patch.parsepatch(fp))
+
+def dorecord(ui, repo, commitfunc, cmdsuggest, backupall,
+ filterfn, *pats, **opts):
import merge as mergemod
if not ui.interactive():
raise util.Abort(_('running non-interactively, use %s instead') %
@@ -61,7 +65,7 @@
# 1. filter patch, so we have intending-to apply subset of it
try:
- chunks = patch.filterpatch(ui, patch.parsepatch(fp))
+ chunks = filterfn(ui, fp)
except patch.PatchError, err:
raise util.Abort(_('error parsing patch: %s') % err)
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1425,7 +1425,8 @@
"""
if opts.get('interactive'):
opts.pop('interactive')
- cmdutil.dorecord(ui, repo, commit, 'commit', False, *pats, **opts)
+ cmdutil.dorecord(ui, repo, commit, 'commit', False,
+ cmdutil.recordfilter, *pats, **opts)
return
if opts.get('subrepos'):
More information about the Mercurial-devel
mailing list