[PATCH] mq: qrefresh ignore sub-repo state if sub-repo not included in patch

alexraynepe196 at gmail.com alexraynepe196 at gmail.com
Tue Dec 13 04:51:22 UTC 2022


# HG changeset patch
# User alexrayne
# Date 1670906453 -10800
#      Tue Dec 13 07:40:53 2022 +0300
# Node ID db8bcd71fd1c51de0c62c2e54bd84d7dabb1bc23
# Parent  e78a4168646426c7f9b9364d9d19cabc24cad9ea
mq: qrefresh ignore sub-repo state if sub-repo not included in patch.

* if patch not contains sub-repo states, so no need check them. Former, was false-aware about dirty subrepos when try qrefresh,
        even if patch contains only WC files, not affected by subs. This claims to do useless work on cleanup sub-repos, unrelated to patch.

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -1897,10 +1897,6 @@
             cparents = repo.changelog.parents(top)
             patchparent = self.qparents(repo, top)
 
-            inclsubs = checksubstate(repo, patchparent)
-            if inclsubs:
-                substatestate = repo.dirstate.get_entry(b'.hgsubstate')
-
             ph = patchheader(self.join(patchfn), self.plainmode)
             diffopts = self.diffopts(
                 {b'git': opts.get(b'git')}, patchfn, plain=True
@@ -1981,6 +1977,27 @@
             allmatches = set(cm + ca + cr + cd)
             refreshchanges = [x.intersection(allmatches) for x in (mm, aa, dd)]
 
+            if {b'.hgsub',b'.hgsubstate'} & (mm|aa):
+                inclsubs = True
+            else:
+                inclsubs = not (opts.get(b'short') or pats)  # matchall
+            
+            if not inclsubs:
+                # if patch includes subrepo folders, enable subrepo check
+                submatch = scmutil.match(repo[None], pats, opts)
+                for s in repo[None].substate:
+                    if submatch(s):
+                        inclsubs = True
+                        break
+            
+            if inclsubs:
+                #if patch affects by sub-repos, clains all subrepos in clean state 
+                inclsubs = checksubstate(repo, patchparent)
+            else:
+                inclsubs = []
+            if inclsubs:
+                substatestate = repo.dirstate.get_entry(b'.hgsubstate')
+
             files = set(inclsubs)
             for x in refreshchanges:
                 files.update(x)



More information about the Mercurial-devel mailing list