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