Patchwork [6,of,8,shelve-ext,v2] shelve: move actual created commit shelving to a separate function

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

Comments

Kostia Balytskyi - Nov. 10, 2016, 11:37 a.m.
# HG changeset patch
# User Kostia Balytskyi <ikostia@fb.com>
# Date 1478776040 28800
#      Thu Nov 10 03:07:20 2016 -0800
# Node ID f2a82865a03b0f36478fae50f60b00aa64d806c2
# Parent  455f00c4d332ae42498a4089aa4a54f135c802ed
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, obsolescense-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.

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -328,6 +328,13 @@  def _nothingtoshelvemessaging(ui, repo, 
     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 @@  def _docreatecmd(ui, repo, pats, opts):
             _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())