narrow: move `only_show` handling sooner in `tracked`
authorPierre-Yves David <pierre-yves.david@octobus.net>
Thu, 23 Feb 2023 03:49:29 +0100
changeset 50183 c74d4ce646fb
parent 50182 e9d92faa08f8
child 50184 a6ca61fd1fa8
narrow: move `only_show` handling sooner in `tracked` This will help us to improve the locking scope in the `tracked` command.
hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py	Fri Feb 24 13:23:15 2023 +0000
+++ b/hgext/narrow/narrowcommands.py	Thu Feb 23 03:49:29 2023 +0100
@@ -563,20 +563,9 @@
         or update_working_copy
     )
 
-    oldincludes, oldexcludes = repo.narrowpats
-
-    # filter the user passed additions and deletions into actual additions and
-    # deletions of excludes and includes
-    addedincludes -= oldincludes
-    removedincludes &= oldincludes
-    addedexcludes -= oldexcludes
-    removedexcludes &= oldexcludes
-
-    widening = addedincludes or removedexcludes
-    narrowing = removedincludes or addedexcludes
-
     # Only print the current narrowspec.
     if only_show:
+        oldincludes, oldexcludes = repo.narrowpats
         ui.pager(b'tracked')
         fm = ui.formatter(b'narrow', opts)
         for i in sorted(oldincludes):
@@ -590,6 +579,18 @@
         fm.end()
         return 0
 
+    oldincludes, oldexcludes = repo.narrowpats
+
+    # filter the user passed additions and deletions into actual additions and
+    # deletions of excludes and includes
+    addedincludes -= oldincludes
+    removedincludes &= oldincludes
+    addedexcludes -= oldexcludes
+    removedexcludes &= oldexcludes
+
+    widening = addedincludes or removedexcludes
+    narrowing = removedincludes or addedexcludes
+
     if update_working_copy:
         with repo.wlock(), repo.lock(), repo.transaction(
             b'narrow-wc'