changeset 30384:21a75b63c10e

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.
author Kostia Balytskyi <ikostia@fb.com>
date Thu, 10 Nov 2016 03:20:28 -0800
parents 455f7856db20
children b573d7ca31c4
files hgext/shelve.py
diffstat 1 files changed, 9 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/shelve.py	Thu Nov 10 03:07:20 2016 -0800
+++ b/hgext/shelve.py	Thu Nov 10 03:20:28 2016 -0800
@@ -335,6 +335,13 @@
                    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 @@
                           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