Mercurial > hg
comparison mercurial/match.py @ 43715:5e1b0470cee7
match: remove explicitdir attribute
No one sets it or reads it anymore.
Differential Revision: https://phab.mercurial-scm.org/D7441
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 15 Nov 2019 14:50:13 -0800 |
parents | 0b7733719d21 |
children | 7eb701e355bd |
comparison
equal
deleted
inserted
replaced
43714:deacffd227e2 | 43715:5e1b0470cee7 |
---|---|
373 # Subscribers to these events must monkeypatch the matcher object. | 373 # Subscribers to these events must monkeypatch the matcher object. |
374 def bad(self, f, msg): | 374 def bad(self, f, msg): |
375 '''Callback from dirstate.walk for each explicit file that can't be | 375 '''Callback from dirstate.walk for each explicit file that can't be |
376 found/accessed, with an error message.''' | 376 found/accessed, with an error message.''' |
377 | 377 |
378 # If an explicitdir is set, it will be called when an explicitly listed | |
379 # directory is visited. | |
380 explicitdir = None | |
381 | |
382 # If an traversedir is set, it will be called when a directory discovered | 378 # If an traversedir is set, it will be called when a directory discovered |
383 # by recursive traversal is visited. | 379 # by recursive traversal is visited. |
384 traversedir = None | 380 traversedir = None |
385 | 381 |
386 @propertycache | 382 @propertycache |
790 | 786 |
791 class differencematcher(basematcher): | 787 class differencematcher(basematcher): |
792 '''Composes two matchers by matching if the first matches and the second | 788 '''Composes two matchers by matching if the first matches and the second |
793 does not. | 789 does not. |
794 | 790 |
795 The second matcher's non-matching-attributes (bad, explicitdir, | 791 The second matcher's non-matching-attributes (bad, traversedir) are ignored. |
796 traversedir) are ignored. | |
797 ''' | 792 ''' |
798 | 793 |
799 def __init__(self, m1, m2): | 794 def __init__(self, m1, m2): |
800 super(differencematcher, self).__init__() | 795 super(differencematcher, self).__init__() |
801 self._m1 = m1 | 796 self._m1 = m1 |
802 self._m2 = m2 | 797 self._m2 = m2 |
803 self.bad = m1.bad | 798 self.bad = m1.bad |
804 self.explicitdir = m1.explicitdir | |
805 self.traversedir = m1.traversedir | 799 self.traversedir = m1.traversedir |
806 | 800 |
807 def matchfn(self, f): | 801 def matchfn(self, f): |
808 return self._m1(f) and not self._m2(f) | 802 return self._m1(f) and not self._m2(f) |
809 | 803 |
860 | 854 |
861 | 855 |
862 def intersectmatchers(m1, m2): | 856 def intersectmatchers(m1, m2): |
863 '''Composes two matchers by matching if both of them match. | 857 '''Composes two matchers by matching if both of them match. |
864 | 858 |
865 The second matcher's non-matching-attributes (bad, explicitdir, | 859 The second matcher's non-matching-attributes (bad, traversedir) are ignored. |
866 traversedir) are ignored. | |
867 ''' | 860 ''' |
868 if m1 is None or m2 is None: | 861 if m1 is None or m2 is None: |
869 return m1 or m2 | 862 return m1 or m2 |
870 if m1.always(): | 863 if m1.always(): |
871 m = copy.copy(m2) | 864 m = copy.copy(m2) |
872 # TODO: Consider encapsulating these things in a class so there's only | 865 # TODO: Consider encapsulating these things in a class so there's only |
873 # one thing to copy from m1. | 866 # one thing to copy from m1. |
874 m.bad = m1.bad | 867 m.bad = m1.bad |
875 m.explicitdir = m1.explicitdir | |
876 m.traversedir = m1.traversedir | 868 m.traversedir = m1.traversedir |
877 return m | 869 return m |
878 if m2.always(): | 870 if m2.always(): |
879 m = copy.copy(m1) | 871 m = copy.copy(m1) |
880 return m | 872 return m |
885 def __init__(self, m1, m2): | 877 def __init__(self, m1, m2): |
886 super(intersectionmatcher, self).__init__() | 878 super(intersectionmatcher, self).__init__() |
887 self._m1 = m1 | 879 self._m1 = m1 |
888 self._m2 = m2 | 880 self._m2 = m2 |
889 self.bad = m1.bad | 881 self.bad = m1.bad |
890 self.explicitdir = m1.explicitdir | |
891 self.traversedir = m1.traversedir | 882 self.traversedir = m1.traversedir |
892 | 883 |
893 @propertycache | 884 @propertycache |
894 def _files(self): | 885 def _files(self): |
895 if self.isexact(): | 886 if self.isexact(): |
1026 | 1017 |
1027 | 1018 |
1028 class prefixdirmatcher(basematcher): | 1019 class prefixdirmatcher(basematcher): |
1029 """Adapt a matcher to work on a parent directory. | 1020 """Adapt a matcher to work on a parent directory. |
1030 | 1021 |
1031 The matcher's non-matching-attributes (bad, explicitdir, traversedir) are | 1022 The matcher's non-matching-attributes (bad, traversedir) are ignored. |
1032 ignored. | |
1033 | 1023 |
1034 The prefix path should usually be the relative path from the root of | 1024 The prefix path should usually be the relative path from the root of |
1035 this matcher to the root of the wrapped matcher. | 1025 this matcher to the root of the wrapped matcher. |
1036 | 1026 |
1037 >>> m1 = match(util.localpath(b'root/d/e'), b'f', [b'../a.txt', b'b.txt']) | 1027 >>> m1 = match(util.localpath(b'root/d/e'), b'f', [b'../a.txt', b'b.txt']) |
1110 | 1100 |
1111 | 1101 |
1112 class unionmatcher(basematcher): | 1102 class unionmatcher(basematcher): |
1113 """A matcher that is the union of several matchers. | 1103 """A matcher that is the union of several matchers. |
1114 | 1104 |
1115 The non-matching-attributes (bad, explicitdir, traversedir) are taken from | 1105 The non-matching-attributes (bad, traversedir) are taken from the first |
1116 the first matcher. | 1106 matcher. |
1117 """ | 1107 """ |
1118 | 1108 |
1119 def __init__(self, matchers): | 1109 def __init__(self, matchers): |
1120 m1 = matchers[0] | 1110 m1 = matchers[0] |
1121 super(unionmatcher, self).__init__() | 1111 super(unionmatcher, self).__init__() |
1122 self.explicitdir = m1.explicitdir | |
1123 self.traversedir = m1.traversedir | 1112 self.traversedir = m1.traversedir |
1124 self._matchers = matchers | 1113 self._matchers = matchers |
1125 | 1114 |
1126 def matchfn(self, f): | 1115 def matchfn(self, f): |
1127 for match in self._matchers: | 1116 for match in self._matchers: |