# HG changeset patch # User Jason R. Coombs # Date 1659980408 14400 # Node ID 35c9f0bc2648872eac56d2a6140a22dff7b6b306 # Parent 360c156e1f811f690c3abc5ae2910b230a9c1c70 phase-shelve: Extract function for _optimized_match for re-use diff -r 360c156e1f81 -r 35c9f0bc2648 mercurial/shelve.py --- a/mercurial/shelve.py Wed Aug 17 02:43:44 2022 +0200 +++ b/mercurial/shelve.py Mon Aug 08 13:40:08 2022 -0400 @@ -210,6 +210,15 @@ self.vfs.tryunlink(self.name + b'.' + ext) +def _optimized_match(repo, node): + """ + Create a matcher so that prefetch doesn't attempt to fetch + the entire repository pointlessly, and as an optimisation + for movedirstate, if needed. + """ + return scmutil.matchfiles(repo, repo[node].files()) + + class shelvedstate: """Handle persistence during unshelving operations. @@ -579,10 +588,7 @@ _nothingtoshelvemessaging(ui, repo, pats, opts) return 1 - # Create a matcher so that prefetch doesn't attempt to fetch - # the entire repository pointlessly, and as an optimisation - # for movedirstate, if needed. - match = scmutil.matchfiles(repo, repo[node].files()) + match = _optimized_match(repo, node) _shelvecreatedcommit(repo, node, name, match) ui.status(_(b'shelved as %s\n') % name) @@ -957,7 +963,7 @@ user=shelvectx.user(), ) if snode: - m = scmutil.matchfiles(repo, repo[snode].files()) + m = _optimized_match(repo, snode) _shelvecreatedcommit(repo, snode, basename, m) return newnode, bool(snode)