Patchwork [4,of,8,sparse,V2] sparse: use self instead of repo.dirstate

login
register
mail settings
Submitter Gregory Szorc
Date July 11, 2017, 4:57 a.m.
Message ID <ee818b5e70b42f4bd656.1499749023@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/22216/
State Accepted
Headers show

Comments

Gregory Szorc - July 11, 2017, 4:57 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1499553731 25200
#      Sat Jul 08 15:42:11 2017 -0700
# Node ID ee818b5e70b42f4bd65605c5872d06e5bc0a0bb5
# Parent  ec1d258a7940fd3104d7cf001150d69e6c4da0ce
sparse: use self instead of repo.dirstate

"self" here is the dirstate instance. I'm pretty confident that self
and repo.dirstate will be the exact same object. So remove a dependency
on repo by just looking at self.
via Mercurial-devel - July 11, 2017, 5:51 a.m.
On Mon, Jul 10, 2017 at 9:57 PM, Gregory Szorc <gregory.szorc@gmail.com> wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1499553731 25200
> #      Sat Jul 08 15:42:11 2017 -0700
> # Node ID ee818b5e70b42f4bd65605c5872d06e5bc0a0bb5
> # Parent  ec1d258a7940fd3104d7cf001150d69e6c4da0ce
> sparse: use self instead of repo.dirstate

I already queued V1 of this and the next patch (so you may see
divergence), thanks.

>
> "self" here is the dirstate instance. I'm pretty confident that self
> and repo.dirstate will be the exact same object. So remove a dependency
> on repo by just looking at self.

Tests agree with that. I added a temporary check that "dirstate is
self" and tests passed.

>
> diff --git a/hgext/sparse.py b/hgext/sparse.py
> --- a/hgext/sparse.py
> +++ b/hgext/sparse.py
> @@ -265,10 +265,9 @@ def _setupdirstate(ui):
>              repo = self.repo
>              sparsematch = sparse.matcher(repo)
>              if not sparsematch.always():
> -                dirstate = repo.dirstate
>                  for f in args:
>                      if (f is not None and not sparsematch(f) and
> -                        f not in dirstate):
> +                        f not in self):
>                          raise error.Abort(_("cannot add '%s' - it is outside "
>                                              "the sparse checkout") % f,
>                                            hint=hint)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/hgext/sparse.py b/hgext/sparse.py
--- a/hgext/sparse.py
+++ b/hgext/sparse.py
@@ -265,10 +265,9 @@  def _setupdirstate(ui):
             repo = self.repo
             sparsematch = sparse.matcher(repo)
             if not sparsematch.always():
-                dirstate = repo.dirstate
                 for f in args:
                     if (f is not None and not sparsematch(f) and
-                        f not in dirstate):
+                        f not in self):
                         raise error.Abort(_("cannot add '%s' - it is outside "
                                             "the sparse checkout") % f,
                                           hint=hint)