[PATCH] context: simplify call to icase matcher in 'match()'

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Mar 16 18:50:12 UTC 2017


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1489617482 25200
#      Wed Mar 15 15:38:02 2017 -0700
# Node ID d980847dfbb24f63306441d86a75741df851d3ee
# Parent  a5bad127128d8f60060be53d161acfa7a32a17d5
# EXP-Topic cleanup
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r d980847dfbb2
context: simplify call to icase matcher in 'match()'

The two function takes the very same arguments. We make this clearer and less
error prone by dispatching on the function only and having a single call point
in the code.

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1525,15 +1525,13 @@ class workingctx(committablectx):
 
         # Only a case insensitive filesystem needs magic to translate user input
         # to actual case in the filesystem.
+        matcherfunc = matchmod.match
         if not util.fscasesensitive(r.root):
-            return matchmod.icasefsmatcher(r.root, r.getcwd(), pats,
-                                           include, exclude, default, r.auditor,
-                                           self, listsubrepos=listsubrepos,
-                                           badfn=badfn)
-        return matchmod.match(r.root, r.getcwd(), pats,
-                              include, exclude, default,
-                              auditor=r.auditor, ctx=self,
-                              listsubrepos=listsubrepos, badfn=badfn)
+            matcherfunc = matchmod.icasefsmatcher
+        return matcherfunc(r.root, r.getcwd(), pats,
+                           include, exclude, default,
+                           auditor=r.auditor, ctx=self,
+                           listsubrepos=listsubrepos, badfn=badfn)
 
     def _filtersuspectsymlink(self, files):
         if not files or self._repo.dirstate._checklink:


More information about the Mercurial-devel mailing list