Patchwork sparse: access status fields by name instead of deconstructing it

login
register
mail settings
Submitter via Mercurial-devel
Date July 9, 2017, 10:09 p.m.
Message ID <27c6b35d4637ae4bca2b.1499638179@martinvonz.svl.corp.google.com>
Download mbox | patch
Permalink /patch/22184/
State Accepted
Headers show

Comments

via Mercurial-devel - July 9, 2017, 10:09 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1499404838 25200
#      Thu Jul 06 22:20:38 2017 -0700
# Node ID 27c6b35d4637ae4bca2b78c6f2f2f06af0d47873
# Parent  9087f9997f42ce3035e97a03bce63852a266660e
sparse: access status fields by name instead of deconstructing it

The status tuples has had named fields for a few years now.
Gregory Szorc - July 9, 2017, 10:37 p.m.
On Sun, Jul 9, 2017 at 3:09 PM, Martin von Zweigbergk via Mercurial-devel <
mercurial-devel@mercurial-scm.org> wrote:

> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1499404838 25200
> #      Thu Jul 06 22:20:38 2017 -0700
> # Node ID 27c6b35d4637ae4bca2b78c6f2f2f06af0d47873
> # Parent  9087f9997f42ce3035e97a03bce63852a266660e
> sparse: access status fields by name instead of deconstructing it
>

Queued for default.


>
> The status tuples has had named fields for a few years now.
>
> diff --git a/mercurial/sparse.py b/mercurial/sparse.py
> --- a/mercurial/sparse.py
> +++ b/mercurial/sparse.py
> @@ -200,9 +200,8 @@
>      if not enabled or not repo.vfs.exists('tempsparse'):
>          return
>
> -    origstatus = repo.status()
> -    modified, added, removed, deleted, a, b, c = origstatus
> -    if modified or added or removed or deleted:
> +    s = repo.status()
> +    if s.modified or s.added or s.removed or s.deleted:
>          # Still have pending changes. Don't bother trying to prune.
>          return
>
> @@ -389,13 +388,11 @@
>      Will abort if a file with pending changes is being excluded or
> included
>      unless ``force`` is True.
>      """
> -    modified, added, removed, deleted, unknown, ignored, clean =
> origstatus
> -
>      # Verify there are no pending changes
>      pending = set()
> -    pending.update(modified)
> -    pending.update(added)
> -    pending.update(removed)
> +    pending.update(origstatus.modified)
> +    pending.update(origstatus.added)
> +    pending.update(origstatus.removed)
>      sparsematch = matcher(repo)
>      abort = False
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/mercurial/sparse.py b/mercurial/sparse.py
--- a/mercurial/sparse.py
+++ b/mercurial/sparse.py
@@ -200,9 +200,8 @@ 
     if not enabled or not repo.vfs.exists('tempsparse'):
         return
 
-    origstatus = repo.status()
-    modified, added, removed, deleted, a, b, c = origstatus
-    if modified or added or removed or deleted:
+    s = repo.status()
+    if s.modified or s.added or s.removed or s.deleted:
         # Still have pending changes. Don't bother trying to prune.
         return
 
@@ -389,13 +388,11 @@ 
     Will abort if a file with pending changes is being excluded or included
     unless ``force`` is True.
     """
-    modified, added, removed, deleted, unknown, ignored, clean = origstatus
-
     # Verify there are no pending changes
     pending = set()
-    pending.update(modified)
-    pending.update(added)
-    pending.update(removed)
+    pending.update(origstatus.modified)
+    pending.update(origstatus.added)
+    pending.update(origstatus.removed)
     sparsematch = matcher(repo)
     abort = False