[PATCH 4 of 8] bundle: refactor changegroup prune to be its own function

Peter Arrenbrecht peter.arrenbrecht at gmail.com
Tue Jun 18 12:19:07 CDT 2013


Hi Durham, are any details on your shallow repo extension available
somewhere?

Thanks,
--peter


On Fri, May 31, 2013 at 7:19 PM, Durham Goode <durham at fb.com> wrote:

> # HG changeset patch
> # User Durham Goode <durham at fb.com>
> # Date 1369961473 25200
> #      Thu May 30 17:51:13 2013 -0700
> # Node ID 036972b09c16295c000847ba359193858e7b3a4d
> # Parent  66c552d6910908070552d1a1c41d729932b8b111
> bundle: refactor changegroup prune to be its own function
>
> Moving the prune function to be a non-nested function allows extensions to
> control which revisions are allowed in the changegroup. For example, in my
> shallow repo extension I want to prevent filelogs from being added to the
> bundle.
>
> This also allows an extension to use a filelog implementation that doesn't
> have revlog.linkrev implemented.
>
> diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
> --- a/mercurial/changegroup.py
> +++ b/mercurial/changegroup.py
> @@ -296,6 +296,11 @@
>
>          yield self.close()
>
> +    # filter any nodes that claim to be part of the known set
> +    def prune(self, revlog, missing, commonrevs, source):
> +        rr, rl = revlog.rev, revlog.linkrev
> +        return [n for n in missing if rl(rr(n)) not in commonrevs]
> +
>      def generate(self, commonrevs, clnodes, fastpathlinkrev, source):
>          '''yield a sequence of changegroup chunks (strings)'''
>          repo = self._repo
> @@ -311,11 +316,6 @@
>          fnodes = {} # needed file nodes
>          changedfiles = set()
>
> -        # filter any nodes that claim to be part of the known set
> -        def prune(revlog, missing):
> -            rr, rl = revlog.rev, revlog.linkrev
> -            return [n for n in missing if rl(rr(n)) not in commonrevs]
> -
>          # Callback for the changelog, used to collect changed files and
> manifest
>          # nodes.
>          # Returns the linkrev node (identity in the changelog case).
> @@ -347,7 +347,7 @@
>
>          for f in changedfiles:
>              fnodes[f] = {}
> -        mfnodes = prune(mf, mfs)
> +        mfnodes = self.prune(mf, mfs, commonrevs, source)
>          for chunk in self.group(mfnodes, mf, lookupmf,
> units=_('manifests'),
>                                  reorder=reorder):
>              yield chunk
> @@ -377,7 +377,7 @@
>              def lookupfilelog(x):
>                  return linkrevnodes[x]
>
> -            filenodes = prune(filerevlog, linkrevnodes)
> +            filenodes = self.prune(filerevlog, linkrevnodes, commonrevs,
> source)
>              if filenodes:
>                  progress(msgbundling, i + 1, item=fname, unit=msgfiles,
>                           total=total)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20130618/1656d86e/attachment.html>


More information about the Mercurial-devel mailing list