[PATCH 2 of 3 v3] bundle2: part handler for processing .hgtags fnodes mappings

Pierre-Yves David pierre-yves.david at ens-lyon.org
Wed Jun 3 02:07:18 CDT 2015



On 06/02/2015 08:26 PM, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc at gmail.com>
> # Date 1433215402 25200
> #      Mon Jun 01 20:23:22 2015 -0700
> # Node ID 651b11ad04814e4cd3b097b88a0ad0e3f5ab1c3c
> # Parent  a0a8ceb536058a1647d8282f75d2ca82617d68c8
> bundle2: part handler for processing .hgtags fnodes mappings
>
> .hgtags fnodes cache entries can be expensive to compute, especially
> if there are hundreds of even thousands of them. This patch implements
> support for receiving a bundle2 part that contains a mapping of
> changeset to .hgtags fnodes.
>
> An upcoming patch will teach the server to send this part, allowing
> clients to bypass having to redundantly compute these values.
>
> A number of tests changed due to the client advertising the "hgtagsfnodes"
> capability.
>
> diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
> --- a/mercurial/bundle2.py
> +++ b/mercurial/bundle2.py
> @@ -155,9 +155,9 @@ import obsolete
>   import pushkey
>   import url
>   import re
>
> -import changegroup, error
> +import changegroup, error, tags
>   from i18n import _
>
>   _pack = struct.pack
>   _unpack = struct.unpack
> @@ -1109,8 +1109,9 @@ capabilities = {'HG20': (),
>                   'listkeys': (),
>                   'pushkey': (),
>                   'digests': tuple(sorted(util.DIGESTS.keys())),
>                   'remote-changegroup': ('http', 'https'),
> +                'hgtagsfnodes': (),
>                  }
>
>   def getrepocaps(repo, allowpushback=False):
>       """return the bundle2 capabilities for a given repo
> @@ -1359,4 +1360,25 @@ def handlepushkeyreply(op, inpart):
>       """retrieve the result of a pushkey request"""
>       ret = int(inpart.params['new'])
>       partid = int(inpart.params['in-reply-to'])
>       op.records.add('obsmarkers', {'new': ret}, partid)
> +
> + at parthandler('hgtagsfnodes')
> +def handlehgtagsfnodes(op, inpart):
> +    """Applies .hgtags fnodes cache entries to the local repo.
> +
> +    Payload is pairs of 20 byte changeset nodes and filenodes.
> +    """
> +    cache = tags.hgtagsfnodescache(op.repo.unfiltered())
> +
> +    count = 0
> +    while True:
> +        node = inpart.read(20)
> +        fnode = inpart.read(20)
> +        if len(node) < 20 or len(fnode) < 20:
> +            op.ui.debug('received incomplete .hgtags fnodes data, ignoring\n')

Can I get you to send a follow up patch that rephrased 'ignoring' as the 
first word in the line? I think having the action mercurial is taking at 
the first word help browsing through the debug output.

Also, should we have an harder failure when the part is mandatory?

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list