# HG changeset patch # User Gregory Szorc # Date 1538501496 25200 # Node ID 41e2633bcd0068643e48ef86d20bb1a7b63026c3 # Parent 41263df08109747354ccae5c53dd975e26dd376c wireprotov2: extract file object emission to own function An upcoming commit will introduce another caller. Differential Revision: https://phab.mercurial-scm.org/D4980 diff -r 41263df08109 -r 41e2633bcd00 mercurial/wireprotov2server.py --- a/mercurial/wireprotov2server.py Mon Oct 08 18:17:12 2018 -0700 +++ b/mercurial/wireprotov2server.py Tue Oct 02 10:31:36 2018 -0700 @@ -975,6 +975,35 @@ return fl +def emitfilerevisions(revisions, fields): + for revision in revisions: + d = { + b'node': revision.node, + } + + if b'parents' in fields: + d[b'parents'] = [revision.p1node, revision.p2node] + + followingmeta = [] + followingdata = [] + + if b'revision' in fields: + if revision.revision is not None: + followingmeta.append((b'revision', len(revision.revision))) + followingdata.append(revision.revision) + else: + d[b'deltabasenode'] = revision.basenode + followingmeta.append((b'delta', len(revision.delta))) + followingdata.append(revision.delta) + + if followingmeta: + d[b'fieldsfollowing'] = followingmeta + + yield d + + for extra in followingdata: + yield extra + @wireprotocommand( 'filedata', args={ @@ -1026,33 +1055,8 @@ b'totalitems': len(nodes), } - for revision in revisions: - d = { - b'node': revision.node, - } - - if b'parents' in fields: - d[b'parents'] = [revision.p1node, revision.p2node] - - followingmeta = [] - followingdata = [] - - if b'revision' in fields: - if revision.revision is not None: - followingmeta.append((b'revision', len(revision.revision))) - followingdata.append(revision.revision) - else: - d[b'deltabasenode'] = revision.basenode - followingmeta.append((b'delta', len(revision.delta))) - followingdata.append(revision.delta) - - if followingmeta: - d[b'fieldsfollowing'] = followingmeta - - yield d - - for extra in followingdata: - yield extra + for o in emitfilerevisions(revisions, fields): + yield o @wireprotocommand( 'heads',