mercurial/wireprotov2server.py
changeset 40391 abbd077965c0
parent 40329 ed55a0077490
child 40692 f83cea7f54d7
--- a/mercurial/wireprotov2server.py	Fri Oct 19 14:59:03 2018 +0200
+++ b/mercurial/wireprotov2server.py	Fri Oct 19 15:38:25 2018 +0200
@@ -984,7 +984,9 @@
 
     return fl
 
-def emitfilerevisions(revisions, fields):
+def emitfilerevisions(repo, path, revisions, fields):
+    clnode = repo.changelog.node
+
     for revision in revisions:
         d = {
             b'node': revision.node,
@@ -993,6 +995,15 @@
         if b'parents' in fields:
             d[b'parents'] = [revision.p1node, revision.p2node]
 
+        if b'linknode' in fields:
+            # TODO by creating the filectx against a specific file revision
+            # instead of changeset, linkrev() is always used. This is wrong for
+            # cases where linkrev() may refer to a hidden changeset. We need an
+            # API for performing linkrev adjustment that takes this into
+            # account.
+            fctx = repo.filectx(path, fileid=revision.node)
+            d[b'linknode'] = clnode(fctx.introrev())
+
         followingmeta = []
         followingdata = []
 
@@ -1052,7 +1063,7 @@
             'type': 'set',
             'default': set,
             'example': {b'parents', b'revision'},
-            'validvalues': {b'parents', b'revision'},
+            'validvalues': {b'parents', b'revision', b'linknode'},
         },
         'path': {
             'type': 'bytes',
@@ -1091,7 +1102,7 @@
         b'totalitems': len(nodes),
     }
 
-    for o in emitfilerevisions(revisions, fields):
+    for o in emitfilerevisions(repo, path, revisions, fields):
         yield o
 
 def filesdatacapabilities(repo, proto):
@@ -1113,7 +1124,8 @@
             'type': 'set',
             'default': set,
             'example': {b'parents', b'revision'},
-            'validvalues': {b'firstchangeset', b'parents', b'revision'},
+            'validvalues': {b'firstchangeset', b'linknode', b'parents',
+                            b'revision'},
         },
         'pathfilter': {
             'type': 'dict',
@@ -1202,7 +1214,7 @@
                                         revisiondata=b'revision' in fields,
                                         assumehaveparentrevisions=haveparents)
 
-        for o in emitfilerevisions(revisions, fields):
+        for o in emitfilerevisions(repo, path, revisions, fields):
             yield o
 
 @wireprotocommand(