changeset 45422:601e3658216d

git: make dirstate actually support listclean parameter As far as I can tell listignored and listunknown should already work. I'm vexed that there doesn't seem to be a way to get clean files out of the pygit2 status method, but this at least makes things work better. Differential Revision: https://phab.mercurial-scm.org/D8998
author Augie Fackler <raf@durin42.com>
date Mon, 07 Sep 2020 17:14:59 -0400
parents 0c6b2cc9a7bb
children d4cf80341589
files hgext/git/dirstate.py
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/git/dirstate.py	Mon Sep 07 17:13:45 2020 -0400
+++ b/hgext/git/dirstate.py	Mon Sep 07 17:14:59 2020 -0400
@@ -129,6 +129,7 @@
             return False
 
     def status(self, match, subrepos, ignored, clean, unknown):
+        listignored, listclean, listunknown = ignored, clean, unknown
         # TODO handling of clean files - can we get that from git.status()?
         modified, added, removed, deleted, unknown, ignored, clean = (
             [],
@@ -168,6 +169,22 @@
                     b'unhandled case: status for %r is %r' % (path, status)
                 )
 
+        if listclean:
+            observed = set(
+                modified + added + removed + deleted + unknown + ignored
+            )
+            index = self.git.index
+            index.read()
+            for entry in index:
+                path = pycompat.fsencode(entry.path)
+                if not match(path):
+                    continue
+                if path in observed:
+                    continue  # already in some other set
+                if path[-1] == b'/':
+                    continue  # directory
+                clean.append(path)
+
         # TODO are we really always sure of status here?
         return (
             False,