##// END OF EJS Templates
store: change handling of decoding errors
Matt Mackall -
r6900:def492d1 default
parent child Browse files
Show More
@@ -2066,7 +2066,7 b' class localrepository(repo.repository):'
2066 2066 total_bytes = 0
2067 2067 # get consistent snapshot of repo, lock during scan
2068 2068 lock = self.lock()
2069 for name, size in self.store.walk():
2069 for name, ename, size in self.store.walk():
2070 2070 entries.append((name, size))
2071 2071 total_bytes += size
2072 2072 return entries, total_bytes
@@ -5,7 +5,6 b''
5 5 # This software may be used and distributed according to the terms
6 6 # of the GNU General Public License, incorporated herein by reference.
7 7
8 from i18n import _
9 8 import os, stat, osutil, util
10 9
11 10 def _buildencodefun():
@@ -59,7 +58,7 b' class basicstore:'
59 58 return os.path.join(self.path, f)
60 59
61 60 def _walk(self, relpath, recurse):
62 '''yields (filename, size)'''
61 '''yields (unencoded, encoded, size)'''
63 62 path = os.path.join(self.path, relpath)
64 63 striplen = len(self.path) + len(os.sep)
65 64 prefix = path[striplen:]
@@ -71,16 +70,17 b' class basicstore:'
71 70 for f, kind, st in osutil.listdir(p, stat=True):
72 71 fp = os.path.join(p, f)
73 72 if kind == stat.S_IFREG and f[-2:] in ('.d', '.i'):
74 l.append((util.pconvert(fp[striplen:]), st.st_size))
73 n = util.pconvert(fp[striplen:])
74 l.append((n, n, st.st_size))
75 75 elif kind == stat.S_IFDIR and recurse:
76 76 visit.append(fp)
77 77 return util.sort(l)
78 78
79 def datafiles(self, reporterror=None):
79 def datafiles(self):
80 80 return self._walk('data', True)
81 81
82 82 def walk(self):
83 '''yields (direncoded filename, size)'''
83 '''yields (unencoded, encoded, size)'''
84 84 # yield data files first
85 85 for x in self.datafiles():
86 86 yield x
@@ -99,14 +99,13 b' class encodedstore(basicstore):'
99 99 op.createmode = self.createmode
100 100 self.opener = lambda f, *args, **kw: op(self.encodefn(f), *args, **kw)
101 101
102 def datafiles(self, reporterror=None):
103 for f, size in self._walk('data', True):
102 def datafiles(self):
103 for a, b, size in self._walk('data', True):
104 104 try:
105 yield decodefilename(f), size
105 a = decodefilename(a)
106 106 except KeyError:
107 if not reporterror:
108 raise
109 reporterror(_("cannot decode filename '%s'") % f)
107 a = None
108 yield a, b, size
110 109
111 110 def join(self, f):
112 111 return os.path.join(self.path, self.encodefn(f))
@@ -160,8 +160,10 b' def _verify(repo):'
160 160 ui.status(_("checking files\n"))
161 161
162 162 storefiles = {}
163 for f, size in repo.store.datafiles(lambda m: err(None, m)):
164 if size > 0:
163 for f, f2, size in repo.store.datafiles():
164 if not f:
165 err(None, _("cannot decode filename '%s'") % f2)
166 elif size > 0:
165 167 storefiles[f] = True
166 168
167 169 files = util.sort(util.unique(filenodes.keys() + filelinkrevs.keys()))
General Comments 0
You need to be logged in to leave comments. Login now