Patchwork [2,of,3,V2] shelve: refactor _shelvecreatedcommit's match object into calling site

login
register
mail settings
Submitter Jordi Gutiérrez Hermoso
Date March 22, 2019, 5:18 p.m.
Message ID <e61152452e42c8bd3576.1553275110@chloe>
Download mbox | patch
Permalink /patch/39365/
State Accepted
Headers show

Comments

Jordi Gutiérrez Hermoso - March 22, 2019, 5:18 p.m.
# HG changeset patch
# User Jordi Gutiérrez Hermoso <jordigh@octave.org>
# Date 1553274206 14400
#      Fri Mar 22 13:03:26 2019 -0400
# Node ID e61152452e42c8bd357618f389afca8492e05651
# Parent  773e8b313d28d85002c459ea69d3671e7a0bc05e
shelve: refactor _shelvecreatedcommit's match object into calling site

We might need to use this match object again to move the dirstate in
case the user requested to `--keep` the changes.

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -420,14 +420,11 @@  def _nothingtoshelvemessaging(ui, repo, 
     else:
         ui.status(_("nothing changed\n"))
 
-def _shelvecreatedcommit(repo, node, name):
+def _shelvecreatedcommit(repo, node, name, match):
     info = {'node': nodemod.hex(node)}
     shelvedfile(repo, name, 'shelve').writeinfo(info)
     bases = list(mutableancestors(repo[node]))
     shelvedfile(repo, name, 'hg').writebundle(bases, node)
-    # Create a matcher so that prefetch doesn't attempt to fetch the entire
-    # repository pointlessly.
-    match = scmutil.matchfiles(repo, repo[node].files())
     with shelvedfile(repo, name, patchextension).opener('wb') as fp:
         cmdutil.exportfile(repo, [node], fp, opts=mdiff.diffopts(git=True),
                            match=match)
@@ -501,7 +498,10 @@  def _docreatecmd(ui, repo, pats, opts):
             _nothingtoshelvemessaging(ui, repo, pats, opts)
             return 1
 
-        _shelvecreatedcommit(repo, node, name)
+        # Create a matcher so that prefetch doesn't attempt to fetch
+        # the entire repository pointlessly
+        match = scmutil.matchfiles(repo, repo[node].files())
+        _shelvecreatedcommit(repo, node, name, match)
 
         if ui.formatted():
             desc = stringutil.ellipsis(desc, ui.termwidth())