linkrev: take a revision number rather than a hash
authorMatt Mackall <mpm@selenic.com>
Wed, 12 Nov 2008 15:19:14 -0600
changeset 7361 9fe97eea5510
parent 7360 42f1b8cb9a60
child 7362 6db4a2ccef3a
linkrev: take a revision number rather than a hash
contrib/dumprevlog
mercurial/cmdutil.py
mercurial/commands.py
mercurial/context.py
mercurial/hgweb/webcommands.py
mercurial/hgweb/webutil.py
mercurial/localrepo.py
mercurial/repair.py
mercurial/revlog.py
mercurial/verify.py
--- a/contrib/dumprevlog	Thu Nov 13 10:11:32 2008 +0100
+++ b/contrib/dumprevlog	Wed Nov 12 15:19:14 2008 -0600
@@ -17,7 +17,7 @@
         p = r.parents(n)
         d = r.revision(n)
         print "node:", node.hex(n)
-        print "linkrev:", r.linkrev(n)
+        print "linkrev:", r.linkrev(i)
         print "parents:", node.hex(p[0]), node.hex(p[1])
         print "length:", len(d)
         print "-start-"
--- a/mercurial/cmdutil.py	Thu Nov 13 10:11:32 2008 +0100
+++ b/mercurial/cmdutil.py	Wed Nov 12 15:19:14 2008 -0600
@@ -1017,7 +1017,7 @@
                 revs = []
                 for j in xrange(i - window, i + 1):
                     n = filelog.node(j)
-                    revs.append((filelog.linkrev(n),
+                    revs.append((filelog.linkrev(j),
                                  follow and filelog.renamed(n)))
                 revs.reverse()
                 for rev in revs:
--- a/mercurial/commands.py	Thu Nov 13 10:11:32 2008 +0100
+++ b/mercurial/commands.py	Wed Nov 12 15:19:14 2008 -0600
@@ -829,7 +829,7 @@
         except:
             pp = [nullid, nullid]
         ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
-                i, r.start(i), r.length(i), r.base(i), r.linkrev(node),
+                i, r.start(i), r.length(i), r.base(i), r.linkrev(i),
             short(node), short(pp[0]), short(pp[1])))
 
 def debugindexdot(ui, file_):
@@ -1833,7 +1833,7 @@
             fl = repo.file(fn)
             for i in fl:
                 node = fl.node(i)
-                lr = fl.linkrev(node)
+                lr = fl.linkrev(i)
                 renamed = fl.renamed(node)
                 rcache[fn][lr] = renamed
                 if renamed:
@@ -2053,7 +2053,7 @@
         if not filenodes:
             raise util.Abort(_("'%s' not found in manifest!") % file_)
         fl = repo.file(file_)
-        p = [repo.lookup(fl.linkrev(fn)) for fn in filenodes]
+        p = [repo.lookup(fl.linkrev(fl.rev(fn))) for fn in filenodes]
     else:
         p = [cp.node() for cp in ctx.parents()]
 
--- a/mercurial/context.py	Thu Nov 13 10:11:32 2008 +0100
+++ b/mercurial/context.py	Wed Nov 12 15:19:14 2008 -0600
@@ -200,7 +200,7 @@
             if '_changectx' in self.__dict__:
                 self._changeid = self._changectx.rev()
             else:
-                self._changeid = self._filelog.linkrev(self._filenode)
+                self._changeid = self._filelog.linkrev(self._filerev)
             return self._changeid
         elif name == '_filenode':
             if '_fileid' in self.__dict__:
@@ -263,9 +263,9 @@
             return self._changectx.rev()
         if '_changeid' in self.__dict__:
             return self._changectx.rev()
-        return self._filelog.linkrev(self._filenode)
+        return self._filelog.linkrev(self._filerev)
 
-    def linkrev(self): return self._filelog.linkrev(self._filenode)
+    def linkrev(self): return self._filelog.linkrev(self._filerev)
     def node(self): return self._changectx.node()
     def user(self): return self._changectx.user()
     def date(self): return self._changectx.date()
@@ -647,7 +647,7 @@
     def rev(self):
         if '_changectx' in self.__dict__:
             return self._changectx.rev()
-        return self._filelog.linkrev(self._filenode)
+        return self._filelog.linkrev(self._filerev)
 
     def data(self): return self._repo.wread(self._path)
     def renamed(self):
--- a/mercurial/hgweb/webcommands.py	Thu Nov 13 10:11:32 2008 +0100
+++ b/mercurial/hgweb/webcommands.py	Wed Nov 12 15:19:14 2008 -0600
@@ -526,13 +526,13 @@
         if not numrevs: # file doesn't exist at all
             raise
         rev = webutil.changectx(web.repo, req).rev()
-        first = fl.linkrev(fl.node(0))
+        first = fl.linkrev(0)
         if rev < first: # current rev is from before file existed
             raise
         frev = numrevs - 1
-        while fl.linkrev(fl.node(frev)) > rev:
+        while fl.linkrev(frev) > rev:
             frev -= 1
-        fctx = web.repo.filectx(f, fl.linkrev(fl.node(frev)))
+        fctx = web.repo.filectx(f, fl.linkrev(frev))
 
     count = fctx.filerev() + 1
     pagelen = web.maxshortchanges
--- a/mercurial/hgweb/webutil.py	Thu Nov 13 10:11:32 2008 +0100
+++ b/mercurial/hgweb/webutil.py	Wed Nov 12 15:19:14 2008 -0600
@@ -126,7 +126,7 @@
         ctx = repo[changeid]
     except RepoError:
         man = repo.manifest
-        ctx = repo[man.linkrev(man.lookup(changeid))]
+        ctx = repo[man.linkrev(man.rev(man.lookup(changeid)))]
 
     return ctx
 
--- a/mercurial/localrepo.py	Thu Nov 13 10:11:32 2008 +0100
+++ b/mercurial/localrepo.py	Wed Nov 12 15:19:14 2008 -0600
@@ -1703,7 +1703,7 @@
                 # If a 'missing' manifest thinks it belongs to a changenode
                 # the recipient is assumed to have, obviously the recipient
                 # must have that manifest.
-                linknode = cl.node(mnfst.linkrev(n))
+                linknode = cl.node(mnfst.linkrev(mnfst.rev(n)))
                 if linknode in has_cl_set:
                     has_mnfst_set[n] = 1
             prune_parents(mnfst, has_mnfst_set, msng_mnfst_set)
@@ -1769,7 +1769,7 @@
             # assume the recipient must have, then the recipient must have
             # that filenode.
             for n in msngset:
-                clnode = cl.node(filerevlog.linkrev(n))
+                clnode = cl.node(filerevlog.linkrev(filerevlog.rev(n)))
                 if clnode in has_cl_set:
                     hasset[n] = 1
             prune_parents(filerevlog, hasset, msngset)
@@ -1892,9 +1892,8 @@
 
         def gennodelst(log):
             for r in log:
-                n = log.node(r)
-                if log.linkrev(n) in revset:
-                    yield n
+                if log.linkrev(r) in revset:
+                    yield log.node(r)
 
         def changed_file_collector(changedfileset):
             def collect_changed_files(clnode):
@@ -1905,7 +1904,7 @@
 
         def lookuprevlink_func(revlog):
             def lookuprevlink(n):
-                return cl.node(revlog.linkrev(n))
+                return cl.node(revlog.linkrev(revlog.rev(n)))
             return lookuprevlink
 
         def gengroup():
--- a/mercurial/repair.py	Thu Nov 13 10:11:32 2008 +0100
+++ b/mercurial/repair.py	Wed Nov 12 15:19:14 2008 -0600
@@ -41,8 +41,7 @@
         startrev = count = len(revlog)
         # find the truncation point of the revlog
         for i in xrange(0, count):
-            node = revlog.node(i)
-            lrev = revlog.linkrev(node)
+            lrev = revlog.linkrev(i)
             if lrev >= link:
                 startrev = i + 1
                 break
@@ -51,7 +50,7 @@
         # (we have to manually save these guys)
         for i in xrange(startrev, count):
             node = revlog.node(i)
-            lrev = revlog.linkrev(node)
+            lrev = revlog.linkrev(i)
             if lrev < link:
                 extra.append((node, cl.node(lrev)))
 
--- a/mercurial/revlog.py	Thu Nov 13 10:11:32 2008 +0100
+++ b/mercurial/revlog.py	Wed Nov 12 15:19:14 2008 -0600
@@ -500,8 +500,8 @@
             raise LookupError(node, self.indexfile, _('no node'))
     def node(self, rev):
         return self.index[rev][7]
-    def linkrev(self, node):
-        return self.index[self.rev(node)][4]
+    def linkrev(self, rev):
+        return self.index[rev][4]
     def parents(self, node):
         d = self.index[self.rev(node)][5:7]
         return (self.node(d[0]), self.node(d[1]))
--- a/mercurial/verify.py	Thu Nov 13 10:11:32 2008 +0100
+++ b/mercurial/verify.py	Wed Nov 12 15:19:14 2008 -0600
@@ -70,7 +70,7 @@
             warn(_("warning: `%s' uses revlog format 0") % name)
 
     def checkentry(obj, i, node, seen, linkrevs, f):
-        lr = obj.linkrev(node)
+        lr = obj.linkrev(obj.rev(node))
         if lr < 0 or (havecl and lr not in linkrevs):
             t = "unexpected"
             if lr < 0 or lr >= len(cl):
@@ -135,7 +135,7 @@
                 elif f != "/dev/null":
                     fns = filenodes.setdefault(f, {})
                     if fn not in fns:
-                        fns[fn] = n
+                        fns[fn] = i
         except Exception, inst:
             exc(lr, _("reading manifest delta %s") % short(n), inst)
 
@@ -155,7 +155,8 @@
         for f in util.sort(filenodes):
             if f not in filelinkrevs:
                 try:
-                    lr = min([repo.file(f).linkrev(n) for n in filenodes[f]])
+                    fl = repo.file(f)
+                    lr = min([fl.linkrev(fl.rev(n)) for n in filenodes[f]])
                 except:
                     lr = None
                 err(lr, _("in manifest but not in changeset"), f)