comparison mercurial/verify.py @ 6762:f67d1468ac50

util: add sort helper
author Matt Mackall <mpm@selenic.com>
date Fri, 27 Jun 2008 18:28:45 -0500
parents e79a8f36c2a5
children c0bd7d8b69ef
comparison
equal deleted inserted replaced
6761:cb981fc955fb 6762:f67d1468ac50
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 node import nullid, short 8 from node import nullid, short
9 from i18n import _ 9 from i18n import _
10 import revlog 10 import revlog, util
11 11
12 def verify(repo): 12 def verify(repo):
13 lock = repo.lock() 13 lock = repo.lock()
14 try: 14 try:
15 return _verify(repo) 15 return _verify(repo)
137 exc(lr, _("reading manifest delta %s") % short(n), inst) 137 exc(lr, _("reading manifest delta %s") % short(n), inst)
138 138
139 ui.status(_("crosschecking files in changesets and manifests\n")) 139 ui.status(_("crosschecking files in changesets and manifests\n"))
140 140
141 if havemf: 141 if havemf:
142 nm = [] 142 for c, m in util.sort([(c, m) for m in mflinkrevs for c in mflinkrevs[m]]):
143 for m in mflinkrevs:
144 for c in mflinkrevs[m]:
145 nm.append((c, m))
146 nm.sort()
147 for c, m in nm:
148 err(c, _("changeset refers to unknown manifest %s") % short(m)) 143 err(c, _("changeset refers to unknown manifest %s") % short(m))
149 del mflinkrevs, nm 144 del mflinkrevs
150 145
151 fl = filelinkrevs.keys() 146 for f in util.sort(filelinkrevs):
152 fl.sort()
153 for f in fl:
154 if f not in filenodes: 147 if f not in filenodes:
155 lr = filelinkrevs[f][0] 148 lr = filelinkrevs[f][0]
156 err(lr, _("in changeset but not in manifest"), f) 149 err(lr, _("in changeset but not in manifest"), f)
157 del fl
158 150
159 if havecl: 151 if havecl:
160 fl = filenodes.keys() 152 for f in util.sort(filenodes):
161 fl.sort()
162 for f in fl:
163 if f not in filelinkrevs: 153 if f not in filelinkrevs:
164 try: 154 try:
165 lr = min([repo.file(f).linkrev(n) for n in filenodes[f]]) 155 lr = min([repo.file(f).linkrev(n) for n in filenodes[f]])
166 except: 156 except:
167 lr = None 157 lr = None
168 err(lr, _("in manifest but not in changeset"), f) 158 err(lr, _("in manifest but not in changeset"), f)
169 del fl
170 159
171 ui.status(_("checking files\n")) 160 ui.status(_("checking files\n"))
172 files = dict.fromkeys(filenodes.keys() + filelinkrevs.keys()).keys() 161 files = util.sort(util.unique(filenodes.keys() + filelinkrevs.keys()))
173 files.sort()
174 for f in files: 162 for f in files:
175 fl = repo.file(f) 163 fl = repo.file(f)
176 checklog(fl, f) 164 checklog(fl, f)
177 seen = {} 165 seen = {}
178 for i in fl: 166 for i in fl:
212 exc(lr, _("checking rename of %s") % short(n), inst, f) 200 exc(lr, _("checking rename of %s") % short(n), inst, f)
213 201
214 # cross-check 202 # cross-check
215 if f in filenodes: 203 if f in filenodes:
216 fns = [(mf.linkrev(l), n) for n,l in filenodes[f].items()] 204 fns = [(mf.linkrev(l), n) for n,l in filenodes[f].items()]
217 fns.sort() 205 for lr, node in util.sort(fns):
218 for lr, node in fns:
219 err(lr, _("%s in manifests not found") % short(node), f) 206 err(lr, _("%s in manifests not found") % short(node), f)
220 207
221 ui.status(_("%d files, %d changesets, %d total revisions\n") % 208 ui.status(_("%d files, %d changesets, %d total revisions\n") %
222 (len(files), len(cl), revisions)) 209 (len(files), len(cl), revisions))
223 if warnings[0]: 210 if warnings[0]: