Patchwork context: simplify call to icase matcher in 'match()'

login
register
mail settings
Submitter Pierre-Yves David
Date March 16, 2017, 6:50 p.m.
Message ID <d980847dfbb24f633064.1489690212@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/19398/
State Accepted
Headers show

Comments

Pierre-Yves David - March 16, 2017, 6:50 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@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.
Yuya Nishihara - March 17, 2017, 12:37 p.m.
On Thu, 16 Mar 2017 11:50:12 -0700, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@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()'

Nice. Queued, thanks.

Patch

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: