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

login
register
mail settings
Submitter Kostia Balytskyi
Date Nov. 8, 2016, 1:51 p.m.
Message ID <914e385828e4597d1e1a.1478613103@dev1902.lla1.facebook.com>
Download mbox | patch
Permalink /patch/17395/
State Superseded
Headers show

Comments

Kostia Balytskyi - Nov. 8, 2016, 1:51 p.m.
# HG changeset patch
# User Kostia Balytskyi <ikostia@fb.com>
# Date 1478543425 28800
#      Mon Nov 07 10:30:25 2016 -0800
# Node ID 914e385828e4597d1e1ae0a97d8cd24a32d8e029
# Parent  31ef2cba32928a93982ea6adea2d189030ce18bf
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
@@ -330,6 +330,12 @@  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]
@@ -382,12 +388,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())