changeset 50183:c74d4ce646fb

narrow: move `only_show` handling sooner in `tracked` This will help us to improve the locking scope in the `tracked` command.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 23 Feb 2023 03:49:29 +0100
parents e9d92faa08f8
children a6ca61fd1fa8
files hgext/narrow/narrowcommands.py
diffstat 1 files changed, 13 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- 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'