Patchwork D8998: git: make dirstate actually support listclean parameter

login
register
mail settings
Submitter phabricator
Date Sept. 7, 2020, 9:31 p.m.
Message ID <differential-rev-PHID-DREV-ifbess4f3leirroifs6i-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47107/
State Superseded
Headers show

Comments

phabricator - Sept. 7, 2020, 9:31 p.m.
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8998

AFFECTED FILES
  hgext/git/dirstate.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/hgext/git/dirstate.py b/hgext/git/dirstate.py
--- a/hgext/git/dirstate.py
+++ b/hgext/git/dirstate.py
@@ -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,20 @@ 
                     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,