From patchwork Tue Nov 8 13:51:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [8, of, 8, shelve-ext] shelve: move unknown files handling to a separate function From: Kostia Balytskyi X-Patchwork-Id: 17398 Message-Id: <3a015218113bab2d0793.1478613104@dev1902.lla1.facebook.com> To: Date: Tue, 8 Nov 2016 05:51:44 -0800 # HG changeset patch # User Kostia Balytskyi # 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 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