[PATCH 3 of 4] changegroup: collect manifest and file nodes for shallow clone

Benoit Boissinot benoit.boissinot at ens-lyon.org
Wed Aug 11 09:11:29 CDT 2010


On Tue, Aug 10, 2010 at 06:38:55PM +0530, Vishakh H wrote:
> # HG changeset patch
> # User Vishakh H <vsh426 at gmail.com>
> # Date 1281445635 -19800
> # Node ID fad9bbac7eea83282c1d807213702dc048fe3d34
> # Parent  24bc8a82d4f7b4cff194b96c0e0c1601563b6eee
> changegroup: collect manifest and file nodes for shallow clone
> 
> if the changegroup is being calculated for shallow clone then collect
> changedfiles and manifests when changelog node is needed in the shallow clone.
> 
> diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
> --- a/mercurial/changegroup.py
> +++ b/mercurial/changegroup.py
> @@ -56,13 +56,14 @@
>      "HG10GZ": ("HG10GZ", lambda: zlib.compressobj()),
>  }
>  
> -def collector(cl, mmfs, files):
> +def collector(cl, mmfs, files, sh_cl=None):

we tend to not like underscores

>      # Gather information about changeset nodes going out in a bundle.
>      # We want to gather manifests needed and filelogs affected.
>      def collect(node):
>          c = cl.read(node)
> -        files.update(c[3])
> -        mmfs.setdefault(c[0], node)
> +        if not sh_cl or node in sh_cl:
> +            files.update(c[3])
> +            mmfs.setdefault(c[0], node)
>      return collect

just put the test on top of the function with an early return:

def collect():
   if sh_cl is None or node in sh_cl:
       return
   ...

that way you avoid an unnecessary changelog read

-- 
:wq


More information about the Mercurial-devel mailing list