Patchwork [8,of,8,shelve-ext] shelve: move unknown files handling to a separate function

login
register
mail settings
Submitter Kostia Balytskyi
Date Nov. 8, 2016, 1:51 p.m.
Message ID <3a015218113bab2d0793.1478613104@dev1902.lla1.facebook.com>
Download mbox | patch
Permalink /patch/17398/
State Superseded
Headers show

Comments

Kostia Balytskyi - Nov. 8, 2016, 1:51 p.m.
# HG changeset patch
# User Kostia Balytskyi <ikostia@fb.com>
# Date 1478543425 28800
#      Mon Nov 07 10:30:25 2016 -0800
# Node ID 3a015218113bab2d079327c89609796392d37652
# Parent  914e385828e4597d1e1ae0a97d8cd24a32d8e029
shelve: move unknown files handling to a separate function

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -337,6 +337,13 @@  def _shelvecreatedcommit(repo, node, nam
                    fp=shelvedfile(repo, name, 'patch').opener('wb'),
                    opts=mdiff.diffopts(git=True))
 
+def _includeunknownfiles(repo, pats, opts, extra):
+    s = repo.status(match=scmutil.match(repo[None], pats, opts),
+                    unknown=True)
+    if s.unknown:
+        extra['shelve_unknown'] = '\0'.join(s.unknown)
+        repo[None].add(s.unknown)
+
 def _docreatecmd(ui, repo, pats, opts):
     wctx = repo[None]
     parents = wctx.parents()
@@ -365,13 +372,9 @@  def _docreatecmd(ui, repo, pats, opts):
         # pull races. ensure we don't print the abort message to stderr.
         tr = repo.transaction('commit', report=lambda x: None)
 
-        extra={}
+        extra = {}
         if includeunknown:
-            s = repo.status(match=scmutil.match(repo[None], pats, opts),
-                            unknown=True)
-            if s.unknown:
-                extra['shelve_unknown'] = '\0'.join(s.unknown)
-                repo[None].add(s.unknown)
+            _includeunknownfiles(repo, pats, opts, extra)
 
         if _iswctxonnewbranch(repo) and not _isbareshelve(pats, opts):
             # In non-bare shelve we don't store newly created branch