mercurial/cmdutil.py
changeset 38047 dabc2237963c
parent 37958 14f4449711b8
child 38160 c974320d20b9
--- a/mercurial/cmdutil.py	Thu May 17 15:33:28 2018 -0700
+++ b/mercurial/cmdutil.py	Thu May 17 23:11:24 2018 -0700
@@ -197,17 +197,21 @@
     return oldwrite
 
 def filterchunks(ui, originalhunks, usecurses, testfile, operation=None):
-    if usecurses:
-        if testfile:
-            recordfn = crecordmod.testdecorator(testfile,
-                                                crecordmod.testchunkselector)
-        else:
-            recordfn = crecordmod.chunkselector
-
-        return crecordmod.filterpatch(ui, originalhunks, recordfn, operation)
-
-    else:
-        return patch.filterpatch(ui, originalhunks, operation)
+    try:
+        if usecurses:
+            if testfile:
+                recordfn = crecordmod.testdecorator(
+                    testfile, crecordmod.testchunkselector)
+            else:
+                recordfn = crecordmod.chunkselector
+
+            return crecordmod.filterpatch(ui, originalhunks, recordfn,
+                                          operation)
+    except crecordmod.fallbackerror as e:
+        ui.warn('%s\n' % e.message)
+        ui.warn(_('falling back to text mode\n'))
+
+    return patch.filterpatch(ui, originalhunks, operation)
 
 def recordfilter(ui, originalhunks, operation=None):
     """ Prompts the user to filter the originalhunks and return a list of