shelve: move actual created commit shelving to a separate function
authorKostia Balytskyi <ikostia@fb.com>
Thu, 10 Nov 2016 03:07:20 -0800
changeset 30383 455f7856db20
parent 30382 dedf0915ca5b
child 30384 21a75b63c10e
shelve: move actual created commit shelving to a separate function Currently, this code does not have any branching, it just bundles a commit and saves a patch file. Later, obsolescence-based shelve will be added, so this code will also create some obsmarkers and will be one of the few places where obsshelve will be different from traditional shelve.
hgext/shelve.py
--- a/hgext/shelve.py	Thu Nov 10 03:33:01 2016 -0800
+++ b/hgext/shelve.py	Thu Nov 10 03:07:20 2016 -0800
@@ -328,6 +328,13 @@
     else:
         ui.status(_("nothing changed\n"))
 
+def _shelvecreatedcommit(repo, node, name):
+    bases = list(mutableancestors(repo[node]))
+    shelvedfile(repo, name, 'hg').writebundle(bases, node)
+    cmdutil.export(repo, [node],
+                   fp=shelvedfile(repo, name, 'patch').opener('wb'),
+                   opts=mdiff.diffopts(git=True))
+
 def _docreatecmd(ui, repo, pats, opts):
     wctx = repo[None]
     parents = wctx.parents()
@@ -380,12 +387,7 @@
             _nothingtoshelvemessaging(ui, repo, pats, opts)
             return 1
 
-        bases = list(mutableancestors(repo[node]))
-        shelvedfile(repo, name, 'hg').writebundle(bases, node)
-        cmdutil.export(repo, [node],
-                       fp=shelvedfile(repo, name, 'patch').opener('wb'),
-                       opts=mdiff.diffopts(git=True))
-
+        _shelvecreatedcommit(repo, node, name)
 
         if ui.formatted():
             desc = util.ellipsis(desc, ui.termwidth())