comparison mercurial/logcmdutil.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 1bf2b44c4007
children 6f4a481f182a 8f8fce2dd594
comparison
equal deleted inserted replaced
46548:0492002560f3 46549:9842c00f0252
843 # of the paths was not a file. Check to see if at least one of them 843 # of the paths was not a file. Check to see if at least one of them
844 # existed in history - in that case, we'll continue down the 844 # existed in history - in that case, we'll continue down the
845 # slowpath; otherwise, we can turn off the slowpath 845 # slowpath; otherwise, we can turn off the slowpath
846 if slowpath: 846 if slowpath:
847 for path in match.files(): 847 for path in match.files():
848 if path == b'.' or path in repo.store: 848 if not path or path in repo.store:
849 break 849 break
850 else: 850 else:
851 slowpath = False 851 slowpath = False
852 852
853 return match, pats, slowpath 853 return match, pats, slowpath