narrow: move `only_show` handling sooner in `tracked`
This will help us to improve the locking scope in the `tracked` command.
--- 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'