comparison mercurial/localrepo.py @ 46549:9842c00f0252 stable

log: fix handling of root (or empty) path provided by matcher (issue6478) Since 27d6956d386b "match: use '' instead of '.' for root directory", '.' should be translated to ''. We can't blame repo.file() about this because an empty string is invalid as a file path, but I found at least two callers (_makematcher() and revset.filelog()) would crash because of this path[0]. So let's make repo.file() accept an empty string. path[0] == b'/' wouldn't work on Python 3 anyways.
author Yuya Nishihara <yuya@tcha.org>
date Tue, 02 Feb 2021 20:20:17 +0900
parents 085294a8c0e0
children 25392c48da8a
comparison
equal deleted inserted replaced
46548:0492002560f3 46549:9842c00f0252
1133 @interfaceutil.implementer(repository.ilocalrepositoryfilestorage) 1133 @interfaceutil.implementer(repository.ilocalrepositoryfilestorage)
1134 class revlogfilestorage(object): 1134 class revlogfilestorage(object):
1135 """File storage when using revlogs.""" 1135 """File storage when using revlogs."""
1136 1136
1137 def file(self, path): 1137 def file(self, path):
1138 if path[0] == b'/': 1138 if path.startswith(b'/'):
1139 path = path[1:] 1139 path = path[1:]
1140 1140
1141 return filelog.filelog(self.svfs, path) 1141 return filelog.filelog(self.svfs, path)
1142 1142
1143 1143
1144 @interfaceutil.implementer(repository.ilocalrepositoryfilestorage) 1144 @interfaceutil.implementer(repository.ilocalrepositoryfilestorage)
1145 class revlognarrowfilestorage(object): 1145 class revlognarrowfilestorage(object):
1146 """File storage when using revlogs and narrow files.""" 1146 """File storage when using revlogs and narrow files."""
1147 1147
1148 def file(self, path): 1148 def file(self, path):
1149 if path[0] == b'/': 1149 if path.startswith(b'/'):
1150 path = path[1:] 1150 path = path[1:]
1151 1151
1152 return filelog.narrowfilelog(self.svfs, path, self._storenarrowmatch) 1152 return filelog.narrowfilelog(self.svfs, path, self._storenarrowmatch)
1153 1153
1154 1154