Mercurial > hg-stable
changeset 6750:fb42030d79d6
add __len__ and __iter__ methods to repo and revlog
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 26 Jun 2008 14:35:50 -0500 |
parents | 51b0e799352f |
children | 7424a75f919a |
files | contrib/dumprevlog hgext/acl.py hgext/churn.py hgext/graphlog.py hgext/hgk.py hgext/keyword.py hgext/mq.py hgext/notify.py hgext/win32text.py mercurial/bundlerepo.py mercurial/changelog.py mercurial/cmdutil.py mercurial/commands.py mercurial/copies.py mercurial/dirstate.py mercurial/hbisect.py mercurial/hgweb/webcommands.py mercurial/hgweb/webutil.py mercurial/localrepo.py mercurial/repair.py mercurial/revlog.py mercurial/verify.py tests/test-parseindex |
diffstat | 23 files changed, 103 insertions(+), 96 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/dumprevlog Thu Jun 26 14:35:50 2008 -0500 +++ b/contrib/dumprevlog Thu Jun 26 14:35:50 2008 -0500 @@ -12,7 +12,7 @@ binopen = lambda fn: open(fn, 'rb') r = revlog.revlog(binopen, f) print "file:", f - for i in xrange(r.count()): + for i in r: n = r.node(i) p = r.parents(n) d = r.revision(n)
--- a/hgext/acl.py Thu Jun 26 14:35:50 2008 -0500 +++ b/hgext/acl.py Thu Jun 26 14:35:50 2008 -0500 @@ -118,7 +118,5 @@ ui.debug(_('acl: changes have source "%s" - skipping\n') % source) return - start = repo.changelog.rev(bin(node)) - end = repo.changelog.count() - for rev in xrange(start, end): + for rev in xrange(repo[node].rev(), len(repo)): c.check(repo.changelog.node(rev))
--- a/hgext/churn.py Thu Jun 26 14:35:50 2008 -0500 +++ b/hgext/churn.py Thu Jun 26 14:35:50 2008 -0500 @@ -91,7 +91,7 @@ cl = repo.changelog if not revs: - revs = range(0, cl.count()) + revs = range(len(cl)) nr_revs = len(revs) cur_rev = 0
--- a/hgext/graphlog.py Thu Jun 26 14:35:50 2008 -0500 +++ b/hgext/graphlog.py Thu Jun 26 14:35:50 2008 -0500 @@ -89,7 +89,7 @@ assert start_rev >= stop_rev curr_rev = start_rev revs = [] - filerev = repo.file(path).count() - 1 + filerev = len(repo.file(path)) - 1 while filerev >= 0: fctx = repo.filectx(path, fileid=filerev) @@ -198,7 +198,7 @@ revs = revrange(repo, rev_opt) return (max(revs), min(revs)) else: - return (repo.changelog.count() - 1, 0) + return (len(repo) - 1, 0) def graphlog(ui, repo, path=None, **opts): """show revision history alongside an ASCII revision graph
--- a/hgext/hgk.py Thu Jun 26 14:35:50 2008 -0500 +++ b/hgext/hgk.py Thu Jun 26 14:35:50 2008 -0500 @@ -175,7 +175,7 @@ # you can specify a commit to stop at by starting the sha1 with ^ def revtree(ui, args, repo, full="tree", maxnr=0, parents=False): def chlogwalk(): - count = repo.changelog.count() + count = len(repo) i = count l = [0] * 100 chunk = 100
--- a/hgext/keyword.py Thu Jun 26 14:35:50 2008 -0500 +++ b/hgext/keyword.py Thu Jun 26 14:35:50 2008 -0500 @@ -178,6 +178,7 @@ notify = self.ui.debug else: # kwexpand/kwshrink ctx = self.repo['.'] + mf = ctx.manifest() notify = self.ui.note candidates = [f for f in files if self.iskwfile(f, ctx.flags)] if candidates:
--- a/hgext/mq.py Thu Jun 26 14:35:50 2008 -0500 +++ b/hgext/mq.py Thu Jun 26 14:35:50 2008 -0500 @@ -2319,7 +2319,7 @@ # we might as well use it, but we won't save it. # update the cache up to the tip - self._updatebranchcache(partial, start, cl.count()) + self._updatebranchcache(partial, start, len(cl)) return partial
--- a/hgext/notify.py Thu Jun 26 14:35:50 2008 -0500 +++ b/hgext/notify.py Thu Jun 26 14:35:50 2008 -0500 @@ -269,11 +269,11 @@ node = bin(node) ui.pushbuffer() if hooktype == 'changegroup': - start = repo.changelog.rev(node) - end = repo.changelog.count() + start = repo[node].rev() + end = len(repo) count = end - start for rev in xrange(start, end): - n.node(repo.changelog.node(rev)) + n.node(repo[node].rev()) n.diff(node, repo.changelog.tip()) else: count = 1
--- a/hgext/win32text.py Thu Jun 26 14:35:50 2008 -0500 +++ b/hgext/win32text.py Thu Jun 26 14:35:50 2008 -0500 @@ -98,7 +98,7 @@ def forbidnewline(ui, repo, hooktype, node, newline, **kwargs): halt = False - for rev in xrange(repo.changelog.rev(bin(node)), repo.changelog.count()): + for rev in xrange(repo[node].rev(), len(repo)): c = repo[rev] for f in c.files(): if f not in c:
--- a/mercurial/bundlerepo.py Thu Jun 26 14:35:50 2008 -0500 +++ b/mercurial/bundlerepo.py Thu Jun 26 14:35:50 2008 -0500 @@ -34,7 +34,7 @@ for chunk in changegroup.chunkiter(bundlefile): pos = bundlefile.tell() yield chunk, pos - len(chunk) - n = self.count() + n = len(self) prev = None for chunk, start in chunkpositer(): size = len(chunk)
--- a/mercurial/changelog.py Thu Jun 26 14:35:50 2008 -0500 +++ b/mercurial/changelog.py Thu Jun 26 14:35:50 2008 -0500 @@ -82,7 +82,7 @@ "delay visibility of index updates to other readers" self._realopener = self.opener self.opener = self._delayopener - self._delaycount = self.count() + self._delaycount = len(self) self._delaybuf = [] self._delayname = None @@ -108,7 +108,7 @@ # if we're doing an initial clone, divert to another file if self._delaycount == 0: self._delayname = fp.name - if not self.count(): + if not len(self): # make sure to truncate the file mode = mode.replace('a', 'w') return self._realopener(name + ".a", mode) @@ -192,4 +192,4 @@ list.sort() l = [hex(manifest), user, parseddate] + list + ["", desc] text = "\n".join(l) - return self.addrevision(text, transaction, self.count(), p1, p2) + return self.addrevision(text, transaction, len(self), p1, p2)
--- a/mercurial/cmdutil.py Thu Jun 26 14:35:50 2008 -0500 +++ b/mercurial/cmdutil.py Thu Jun 26 14:35:50 2008 -0500 @@ -126,7 +126,7 @@ if revrangesep in revs[0]: start, end = revs[0].split(revrangesep, 1) start = revfix(repo, start, 0) - end = revfix(repo, end, repo.changelog.count() - 1) + end = revfix(repo, end, len(repo) - 1) else: start = revfix(repo, revs[0], None) elif len(revs) == 2: @@ -151,7 +151,7 @@ if revrangesep in spec: start, end = spec.split(revrangesep, 1) start = revfix(repo, start, 0) - end = revfix(repo, end, repo.changelog.count() - 1) + end = revfix(repo, end, len(repo) - 1) step = start > end and -1 or 1 for rev in xrange(start, end+step, step): if rev in seen: @@ -988,7 +988,7 @@ m = match(repo, pats, opts) follow = opts.get('follow') or opts.get('follow_first') - if repo.changelog.count() == 0: + if not len(repo): return [], m if follow: @@ -1007,9 +1007,9 @@ if not slowpath: # Only files, no patterns. Check the history of each file. def filerevgen(filelog, node): - cl_count = repo.changelog.count() + cl_count = len(repo) if node is None: - last = filelog.count() - 1 + last = len(filelog) - 1 else: last = filelog.rev(node) for i, window in increasing_windows(last, nullrev): @@ -1032,7 +1032,7 @@ minrev, maxrev = min(revs), max(revs) for file_, node in iterfiles(): filelog = repo.file(file_) - if filelog.count() == 0: + if not len(filelog): if node is None: # A zero count may be a directory or deleted file, so # try to find matching entries on the slow path. @@ -1058,8 +1058,7 @@ # The slow path checks files modified in every changeset. def changerevgen(): - for i, window in increasing_windows(repo.changelog.count()-1, - nullrev): + for i, window in increasing_windows(len(repo) - 1, nullrev): for j in xrange(i - window, i + 1): yield j, change(j)[3]
--- a/mercurial/commands.py Thu Jun 26 14:35:50 2008 -0500 +++ b/mercurial/commands.py Thu Jun 26 14:35:50 2008 -0500 @@ -773,7 +773,7 @@ r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_) ui.write(" rev offset length base linkrev" + " nodeid p1 p2\n") - for i in xrange(r.count()): + for i in r: node = r.node(i) try: pp = r.parents(node) @@ -787,7 +787,7 @@ """dump an index DAG as a .dot file""" r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_) ui.write("digraph G {\n") - for i in xrange(r.count()): + for i in r: node = r.node(i) pp = r.parents(node) ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i)) @@ -1762,7 +1762,7 @@ if opts['copies'] and opts['rev']: endrev = max(cmdutil.revrange(repo, opts['rev'])) + 1 else: - endrev = repo.changelog.count() + endrev = len(repo) rcache = {} ncache = {} def getrenamed(fn, rev): @@ -1774,7 +1774,7 @@ rcache[fn] = {} ncache[fn] = {} fl = repo.file(fn) - for i in xrange(fl.count()): + for i in fl: node = fl.node(i) lr = fl.linkrev(node) renamed = fl.renamed(node) @@ -2794,7 +2794,7 @@ that repository becomes the current tip. The "tip" tag is special and cannot be renamed or assigned to a different changeset. """ - cmdutil.show_changeset(ui, repo, opts).show(nullrev+repo.changelog.count()) + cmdutil.show_changeset(ui, repo, opts).show(len(repo) - 1) def unbundle(ui, repo, fname1, *fnames, **opts): """apply one or more changegroup files
--- a/mercurial/copies.py Thu Jun 26 14:35:50 2008 -0500 +++ b/mercurial/copies.py Thu Jun 26 14:35:50 2008 -0500 @@ -67,7 +67,7 @@ # - quit when interesting revs is zero cl = repo.changelog - working = cl.count() # pseudo rev for the working directory + working = len(cl) # pseudo rev for the working directory if a is None: a = working if b is None:
--- a/mercurial/dirstate.py Thu Jun 26 14:35:50 2008 -0500 +++ b/mercurial/dirstate.py Thu Jun 26 14:35:50 2008 -0500 @@ -384,7 +384,7 @@ def rebuild(self, parent, files): self.clear() for f in files: - if 'x' in files.flag(f): + if 'x' in files.flags(f): self._map[f] = ('n', 0777, -1, 0, 0) else: self._map[f] = ('n', 0666, -1, 0, 0)
--- a/mercurial/hbisect.py Thu Jun 26 14:35:50 2008 -0500 +++ b/mercurial/hbisect.py Thu Jun 26 14:35:50 2008 -0500 @@ -20,12 +20,12 @@ badrev = min([changelog.rev(n) for n in bad]) goodrevs = [changelog.rev(n) for n in good] # build ancestors array - ancestors = [[]] * (changelog.count() + 1) # an extra for [-1] + ancestors = [[]] * (len(changelog) + 1) # an extra for [-1] # clear good revs from array for node in goodrevs: ancestors[node] = None - for rev in xrange(changelog.count(), -1, -1): + for rev in xrange(len(changelog), -1, -1): if ancestors[rev] is None: for prev in clparents(rev): ancestors[prev] = None
--- a/mercurial/hgweb/webcommands.py Thu Jun 26 14:35:50 2008 -0500 +++ b/mercurial/hgweb/webcommands.py Thu Jun 26 14:35:50 2008 -0500 @@ -110,7 +110,7 @@ qw = query.lower().split() def revgen(): - for i in xrange(cl.count() - 1, 0, -100): + for i in xrange(len(cl) - 1, 0, -100): l = [] for j in xrange(max(0, i - 100), i + 1): ctx = web.repo[j] @@ -168,7 +168,7 @@ if 'rev' in req.form: hi = req.form['rev'][0] else: - hi = web.repo.changelog.count() - 1 + hi = len(web.repo) - 1 try: ctx = web.repo[hi] except RepoError: @@ -205,7 +205,7 @@ maxchanges = shortlog and web.maxshortchanges or web.maxchanges cl = web.repo.changelog - count = cl.count() + count = len(cl) pos = ctx.rev() start = max(0, pos - maxchanges + 1) end = min(count, start + maxchanges) @@ -409,7 +409,7 @@ yield l cl = web.repo.changelog - count = cl.count() + count = len(cl) start = max(0, count - web.maxchanges) end = min(count, start + web.maxchanges) @@ -498,7 +498,7 @@ fctx = webutil.filectx(web.repo, req) f = fctx.path() fl = fctx.filelog() - count = fl.count() + count = len(fl) pagelen = web.maxshortchanges pos = fctx.filerev() start = max(0, pos - pagelen + 1) @@ -579,7 +579,7 @@ rev = webutil.changectx(web.repo, req).rev() bg_height = 39 - max_rev = web.repo.changelog.count() - 1 + max_rev = len(web.repo) - 1 revcount = min(max_rev, int(req.form.get('revcount', [25])[0])) revnode = web.repo.changelog.node(rev) revnode_hex = hex(revnode) @@ -588,7 +588,7 @@ lessrev = max(0, rev - revcount / 2) maxchanges = web.maxshortchanges or web.maxchanges - count = web.repo.changelog.count() + count = len(web.repo) changenav = webutil.revnavgen(rev, maxchanges, count, web.repo.changectx) tree = list(graphmod.graph(web.repo, rev, rev - revcount))
--- a/mercurial/hgweb/webutil.py Thu Jun 26 14:35:50 2008 -0500 +++ b/mercurial/hgweb/webutil.py Thu Jun 26 14:35:50 2008 -0500 @@ -112,12 +112,11 @@ return util.canonpath(repo.root, '', path) def changectx(repo, req): + changeid = "tip" if 'node' in req.form: changeid = req.form['node'][0] elif 'manifest' in req.form: changeid = req.form['manifest'][0] - else: - changeid = repo.changelog.count() - 1 try: ctx = repo[changeid]
--- a/mercurial/localrepo.py Thu Jun 26 14:35:50 2008 -0500 +++ b/mercurial/localrepo.py Thu Jun 26 14:35:50 2008 -0500 @@ -122,6 +122,16 @@ return context.workingctx(self) return context.changectx(self, changeid) + def __nonzero__(self): + return True + + def __len__(self): + return len(self.changelog) + + def __iter__(self): + for i in xrange(len(self)): + yield i + def url(self): return 'file:' + self.root @@ -368,7 +378,7 @@ return self.nodetagscache.get(node, []) def _branchtags(self, partial, lrev): - tiprev = self.changelog.count() - 1 + tiprev = len(self) - 1 if lrev != tiprev: self._updatebranchcache(partial, lrev+1, tiprev+1) self._writebranchcache(partial, self.changelog.tip(), tiprev) @@ -413,8 +423,7 @@ try: last, lrev = lines.pop(0).split(" ", 1) last, lrev = bin(last), int(lrev) - if not (lrev < self.changelog.count() and - self.changelog.node(lrev) == last): # sanity check + if lrev >= len(self) or self[lrev].node() != last: # invalidate the cache raise ValueError('invalidating branch cache (tip differs)') for l in lines: @@ -834,7 +843,7 @@ # check in files new = {} changed = [] - linkrev = self.changelog.count() + linkrev = len(self) commit.sort() for f in commit: self.ui.note(f + "\n") @@ -1638,7 +1647,7 @@ # Nor do we know which filenodes are missing. msng_filenode_set = {} - junk = mnfst.index[mnfst.count() - 1] # Get around a bug in lazyindex + junk = mnfst.index[len(mnfst) - 1] # Get around a bug in lazyindex junk = None # A changeset always belongs to itself, so the changenode lookup @@ -1838,7 +1847,7 @@ # Go through all our files in order sorted by name. for fname in changedfiles: filerevlog = self.file(fname) - if filerevlog.count() == 0: + if not len(filerevlog): raise util.Abort(_("empty or missing revlog for %s") % fname) # Toss out the filenodes that the recipient isn't really # missing. @@ -1889,10 +1898,10 @@ def identity(x): return x - def gennodelst(revlog): - for r in xrange(0, revlog.count()): - n = revlog.node(r) - if revlog.linkrev(n) in revset: + def gennodelst(log): + for r in log: + n = log.node(r) + if log.linkrev(n) in revset: yield n def changed_file_collector(changedfileset): @@ -1924,7 +1933,7 @@ for fname in changedfiles: filerevlog = self.file(fname) - if filerevlog.count() == 0: + if not len(filerevlog): raise util.Abort(_("empty or missing revlog for %s") % fname) nodeiter = gennodelst(filerevlog) nodeiter = list(nodeiter) @@ -1953,7 +1962,7 @@ """ def csmap(x): self.ui.debug(_("add changeset %s\n") % short(x)) - return cl.count() + return len(cl) def revmap(x): return cl.rev(x) @@ -1976,11 +1985,11 @@ trp = weakref.proxy(tr) # pull off the changeset group self.ui.status(_("adding changesets\n")) - cor = cl.count() - 1 + cor = len(cl) - 1 chunkiter = changegroup.chunkiter(source) if cl.addgroup(chunkiter, csmap, trp) is None and not emptyok: raise util.Abort(_("received changelog group is empty")) - cnr = cl.count() - 1 + cnr = len(cl) - 1 changesets = cnr - cor # pull off the manifest group @@ -2000,11 +2009,11 @@ break self.ui.debug(_("adding %s revisions\n") % f) fl = self.file(f) - o = fl.count() + o = len(fl) chunkiter = changegroup.chunkiter(source) if fl.addgroup(chunkiter, revmap, trp) is None: raise util.Abort(_("received file revlog group is empty")) - revisions += fl.count() - o + revisions += len(fl) - o files += 1 # make changelog see real files again
--- a/mercurial/repair.py Thu Jun 26 14:35:50 2008 -0500 +++ b/mercurial/repair.py Thu Jun 26 14:35:50 2008 -0500 @@ -23,7 +23,7 @@ """find out the filelogs affected by the strip""" files = {} - for x in xrange(striprev, repo.changelog.count()): + for x in xrange(striprev, len(repo)): for name in repo[x].files(): if name in files: continue @@ -37,7 +37,7 @@ """return the nodes that have to be saved before the strip""" def collectone(revlog): extra = [] - startrev = count = revlog.count() + startrev = count = len(revlog) # find the truncation point of the revlog for i in xrange(0, count): node = revlog.node(i) @@ -84,7 +84,7 @@ tostrip = {striprev: 1} saveheads = {} savebases = [] - for r in xrange(striprev + 1, cl.count()): + for r in xrange(striprev + 1, len(cl)): parents = cl.parentrevs(r) if parents[0] in tostrip or parents[1] in tostrip: # r is a descendant of striprev
--- a/mercurial/revlog.py Thu Jun 26 14:35:50 2008 -0500 +++ b/mercurial/revlog.py Thu Jun 26 14:35:50 2008 -0500 @@ -515,9 +515,11 @@ def tip(self): return self.node(len(self.index) - 2) - def count(self): + def __len__(self): return len(self.index) - 1 - + def __iter__(self): + for i in xrange(len(self)): + yield i def rev(self, node): try: return self.nodemap[node] @@ -620,12 +622,11 @@ lowestrev = nullrev if (lowestrev == nullrev) and (heads is None): # We want _all_ the nodes! - return ([self.node(r) for r in xrange(0, self.count())], - [nullid], list(self.heads())) + return ([self.node(r) for r in self], [nullid], list(self.heads())) if heads is None: # All nodes are ancestors, so the latest ancestor is the last # node. - highestrev = self.count() - 1 + highestrev = len(self) - 1 # Set ancestors to None to signal that every node is an ancestor. ancestors = None # Set heads to an empty dictionary for later discovery of heads @@ -754,15 +755,15 @@ as if they had no children """ if start is None and stop is None: - count = self.count() + count = len(self) if not count: return [nullid] ishead = [1] * (count + 1) index = self.index - for r in xrange(count): + for r in self: e = index[r] ishead[e[5]] = ishead[e[6]] = 0 - return [self.node(r) for r in xrange(count) if ishead[r]] + return [self.node(r) for r in self if ishead[r]] if start is None: start = nullid @@ -774,7 +775,7 @@ heads = {startrev: 1} parentrevs = self.parentrevs - for r in xrange(startrev + 1, self.count()): + for r in xrange(startrev + 1, len(self)): for p in parentrevs(r): if p in reachable: if r not in stoprevs: @@ -789,7 +790,7 @@ """find the children of a given node""" c = [] p = self.rev(node) - for r in range(p + 1, self.count()): + for r in range(p + 1, len(self)): prevs = [pr for pr in self.parentrevs(r) if pr != nullrev] if prevs: for pr in prevs: @@ -818,8 +819,8 @@ if str(rev) != id: raise ValueError if rev < 0: - rev = self.count() + rev - if rev < 0 or rev >= self.count(): + rev = len(self) + rev + if rev < 0 or rev >= len(self): raise ValueError return self.node(rev) except (ValueError, OverflowError): @@ -982,7 +983,7 @@ df = self.opener(self.datafile, 'w') try: calc = self._io.size - for r in xrange(self.count()): + for r in self: start = self.start(r) + (r + 1) * calc length = self.length(r) fp.seek(start) @@ -995,7 +996,7 @@ fp = self.opener(self.indexfile, 'w', atomictemp=True) self.version &= ~(REVLOGNGINLINEDATA) self._inline = False - for i in xrange(self.count()): + for i in self: e = self._io.packentry(self.index[i], self.node, self.version, i) fp.write(e) @@ -1031,7 +1032,7 @@ if node in self.nodemap: return node - curr = self.count() + curr = len(self) prev = curr - 1 base = self.base(prev) offset = self.end(prev) @@ -1146,7 +1147,7 @@ """ #track the base of the current delta log - r = self.count() + r = len(self) t = r - 1 node = None @@ -1265,13 +1266,13 @@ trust that the caller has saved the revisions that shouldn't be removed and that it'll readd them after this truncation. """ - if self.count() == 0: + if len(self) == 0: return if isinstance(self.index, lazyindex): self._loadindexmap() - for rev in xrange(0, self.count()): + for rev in self: if self.index[rev][4] >= minlink: break else: @@ -1292,15 +1293,15 @@ # then reset internal state in memory to forget those revisions self._cache = None self._chunkcache = None - for x in xrange(rev, self.count()): + for x in xrange(rev, len(self)): del self.nodemap[self.node(x)] del self.index[rev:-1] def checksize(self): expected = 0 - if self.count(): - expected = max(0, self.end(self.count() - 1)) + if len(self): + expected = max(0, self.end(len(self) - 1)) try: f = self.opener(self.datafile) @@ -1321,10 +1322,10 @@ di = actual - (i * s) if self._inline: databytes = 0 - for r in xrange(self.count()): + for r in self: databytes += max(0, self.length(r)) dd = 0 - di = actual - self.count() * s - databytes + di = actual - len(self) * s - databytes except IOError, inst: if inst.errno != errno.ENOENT: raise
--- a/mercurial/verify.py Thu Jun 26 14:35:50 2008 -0500 +++ b/mercurial/verify.py Thu Jun 26 14:35:50 2008 -0500 @@ -65,13 +65,13 @@ havecl = havemf = 1 seen = {} repo.ui.status(_("checking changesets\n")) - if repo.changelog.count() == 0 and repo.manifest.count() > 1: + if not len(repo) and len(repo.manifest): havecl = 0 err(0, _("empty or missing 00changelog.i")) else: checksize(repo.changelog, "changelog") - for i in xrange(repo.changelog.count()): + for i in repo: changesets += 1 n = repo.changelog.node(i) l = repo.changelog.linkrev(n) @@ -101,18 +101,18 @@ seen = {} repo.ui.status(_("checking manifests\n")) - if repo.changelog.count() > 0 and repo.manifest.count() == 0: + if len(repo) and not len(repo.manifest): havemf = 0 err(0, _("empty or missing 00manifest.i")) else: checkversion(repo.manifest, "manifest") checksize(repo.manifest, "manifest") - for i in xrange(repo.manifest.count()): + for i in repo.manifest: n = repo.manifest.node(i) l = repo.manifest.linkrev(n) - if l < 0 or (havecl and l >= repo.changelog.count()): + if l < 0 or (havecl and l >= len(repo)): err(None, _("bad link (%d) at manifest revision %d") % (l, i)) if n in neededmanifests: @@ -182,19 +182,19 @@ checkversion(fl, f) checksize(fl, f) - if fl.count() == 0: + if not len(fl): err(filelinkrevs[f][0], _("empty or missing revlog"), f) continue seen = {} nodes = {nullid: 1} - for i in xrange(fl.count()): + for i in fl: revisions += 1 n = fl.node(i) flr = fl.linkrev(n) if flr < 0 or (havecl and flr not in filelinkrevs.get(f, [])): - if flr < 0 or flr >= repo.changelog.count(): + if flr < 0 or flr >= len(repo): err(None, _("rev %d point to nonexistent changeset %d") % (i, flr), f) else: @@ -245,7 +245,7 @@ rp = fl.renamed(n) if rp: fl2 = repo.file(rp[0]) - if fl2.count() == 0: + if not len(fl2): err(flr, _("empty or missing copy source revlog %s:%s") % (rp[0], short(rp[1])), f) elif rp[1] == nullid:
--- a/tests/test-parseindex Thu Jun 26 14:35:50 2008 -0500 +++ b/tests/test-parseindex Thu Jun 26 14:35:50 2008 -0500 @@ -44,8 +44,8 @@ return wrapper cl = changelog.changelog(opener('.hg/store')) -print cl.count(), 'revisions:' -for r in xrange(cl.count()): +print len(cl), 'revisions:' +for r in cl: print short(cl.node(r)) EOF