# HG changeset patch # User FUJIWARA Katsunori # Date 1416389714 -32400 # Node ID 22e00674d17e8344abf27a0619dae371bebd9f83 # Parent bf8c3172255ccd83af6a283c58592783a9aaf3aa subrepo: replace direct file APIs around "readlines" by "vfs.tryreadlines" This patch also replaces "self._getstorehashcachepath" (building absolute path up) by "self._getstorehashcachename" (building relative path up), because "vfs.tryreadlines" requires relative path. This patch makes "_readstorehashcache()" return "[]" (returned by "vfs.tryreadlines()"), when cache file doesn't exist, even though "_readstorehashcache()" returned '' (empty string) in such case before this patch. "_readstorehashcache()" is invoked only by the code path below in "_storeclean()": for filehash in self._readstorehashcache(path): if filehash != itercache.next(): clean = False break In this case, "[]" and '' don't differ from each other, because both of them cause avoiding iteration of "for loop". diff -r bf8c3172255c -r 22e00674d17e mercurial/subrepo.py --- a/mercurial/subrepo.py Wed Nov 19 18:35:14 2014 +0900 +++ b/mercurial/subrepo.py Wed Nov 19 18:35:14 2014 +0900 @@ -572,15 +572,8 @@ def _readstorehashcache(self, remotepath): '''read the store hash cache for a given remote repository''' - cachefile = self._getstorehashcachepath(remotepath) - if not os.path.exists(cachefile): - return '' - fd = open(cachefile, 'r') - try: - pullstate = fd.readlines() - finally: - fd.close() - return pullstate + cachefile = _getstorehashcachename(remotepath) + return self._cachestorehashvfs.tryreadlines(cachefile, 'r') def _cachestorehash(self, remotepath): '''cache the current store hash