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

login
register
mail settings
Submitter Kostia Balytskyi
Date Nov. 10, 2016, 11:37 a.m.
Message ID <d77543b3c0f6cd8dfc00.1478777851@dev1902.lla1.facebook.com>
Download mbox | patch
Permalink /patch/17439/
State Accepted
Headers show

Comments

Kostia Balytskyi - Nov. 10, 2016, 11:37 a.m.
# HG changeset patch
# User Kostia Balytskyi <ikostia@fb.com>
# Date 1478776828 28800
#      Thu Nov 10 03:20:28 2016 -0800
# Node ID d77543b3c0f6cd8dfc00be6060ef93743d98eeeb
# Parent  f2a82865a03b0f36478fae50f60b00aa64d806c2
shelve: move unknown files handling to a separate function

This change has nothing to do with future obsshelve introduction,
it is done just for readability purposes.

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -335,6 +335,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()
@@ -364,13 +371,9 @@  def _docreatecmd(ui, repo, pats, opts):
                           not opts.get('addremove', False))
 
         name = getshelvename(repo, parent, opts)
-        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