Mercurial > public > mercurial-scm > hg
comparison mercurial/subrepo.py @ 23369:22e00674d17e
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".
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Wed, 19 Nov 2014 18:35:14 +0900 |
parents | 115af8de76a4 |
children | 6cfa7a73b6e7 |
comparison
equal
deleted
inserted
replaced
23368:bf8c3172255c | 23369:22e00674d17e |
---|---|
570 def _cachestorehashvfs(self): | 570 def _cachestorehashvfs(self): |
571 return scmutil.vfs(self._repo.join('cache/storehash')) | 571 return scmutil.vfs(self._repo.join('cache/storehash')) |
572 | 572 |
573 def _readstorehashcache(self, remotepath): | 573 def _readstorehashcache(self, remotepath): |
574 '''read the store hash cache for a given remote repository''' | 574 '''read the store hash cache for a given remote repository''' |
575 cachefile = self._getstorehashcachepath(remotepath) | 575 cachefile = _getstorehashcachename(remotepath) |
576 if not os.path.exists(cachefile): | 576 return self._cachestorehashvfs.tryreadlines(cachefile, 'r') |
577 return '' | |
578 fd = open(cachefile, 'r') | |
579 try: | |
580 pullstate = fd.readlines() | |
581 finally: | |
582 fd.close() | |
583 return pullstate | |
584 | 577 |
585 def _cachestorehash(self, remotepath): | 578 def _cachestorehash(self, remotepath): |
586 '''cache the current store hash | 579 '''cache the current store hash |
587 | 580 |
588 Each remote repo requires its own store hash cache, because a subrepo | 581 Each remote repo requires its own store hash cache, because a subrepo |