[PATCH 3 of 3] archive: support 'wdir()'

Yuya Nishihara yuya at tcha.org
Mon Jun 15 10:46:09 CDT 2015


On Mon, 15 Jun 2015 00:28:59 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison at yahoo.com>
> # Date 1434328768 14400
> #      Sun Jun 14 20:39:28 2015 -0400
> # Node ID 18d376a661ffabe8121ab5d57b245f4f347f8cd1
> # Parent  f5f5e4ae488d9cae8111e9a212f647ed1430a019
> archive: support 'wdir()'

> diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
> --- a/mercurial/subrepo.py
> +++ b/mercurial/subrepo.py
> @@ -751,8 +751,8 @@
>      def archive(self, archiver, prefix, match=None):
>          self._get(self._state + ('hg',))
>          total = abstractsubrepo.archive(self, archiver, prefix, match)
> -        rev = self._state[1]
> -        ctx = self._repo[rev]
> +        ctx = self._getctx()
> +
>          for subpath in ctx.substate:
>              s = subrepo(ctx, subpath)
>              submatch = matchmod.narrowmatcher(subpath, match)
> @@ -918,18 +918,13 @@
>  
>      @annotatesubrepoerror
>      def files(self):
> -        rev = self._state[1]
> -        ctx = self._repo[rev]
> -        return ctx.manifest().keys()
> +        return self._getctx().manifest().keys()
>  
>      def filedata(self, name):
> -        rev = self._state[1]
> -        return self._repo[rev][name].data()
> +        return self._getctx()[name].data()
>  
>      def fileflags(self, name):
> -        rev = self._state[1]
> -        ctx = self._repo[rev]
> -        return ctx.flags(name)
> +        return self._getctx().flags(name)

Can't we switch to the hgsubrepo object representing wdir?

If I understand it, archive() knows if it is wdir or not, but it tests the
same thing for each function call.

  archive() tests if ctx.rev() is None,
    then, archive() calls files(),
      files() tests if ctx.rev() is None,
    then, archive() calls fileflags(),
      fileflags() tests if ctx.rev() is None,
      ...


More information about the Mercurial-devel mailing list