Patchwork [2,of,3] shelve: do not update when keeping changes, just set the right parent

login
register
mail settings
Submitter Jordi Gutiérrez Hermoso
Date March 22, 2019, 3:29 p.m.
Message ID <6bff7f54a5f20e72e63e.1553268589@chloe>
Download mbox | patch
Permalink /patch/39359/
State Superseded
Headers show

Comments

Jordi Gutiérrez Hermoso - March 22, 2019, 3:29 p.m.
# HG changeset patch
# User Jordi Gutiérrez Hermoso <jordigh@octave.org>
# Date 1553268335 14400
#      Fri Mar 22 11:25:35 2019 -0400
# Node ID 6bff7f54a5f20e72e63edbceb2a34d86fb4c86f4
# Parent  773e8b313d28d85002c459ea69d3671e7a0bc05e
shelve: do not update when keeping changes, just set the right parent

This is not enough to enable `shelve --keep` to work, but it's a
necessary first step.
Pulkit Goyal - March 22, 2019, 3:42 p.m.
On Fri, Mar 22, 2019 at 6:35 PM Jordi Gutiérrez Hermoso <jordigh@octave.org>
wrote:

> # HG changeset patch
> # User Jordi Gutiérrez Hermoso <jordigh@octave.org>
> # Date 1553268335 14400
> #      Fri Mar 22 11:25:35 2019 -0400
> # Node ID 6bff7f54a5f20e72e63edbceb2a34d86fb4c86f4
> # Parent  773e8b313d28d85002c459ea69d3671e7a0bc05e
> shelve: do not update when keeping changes, just set the right parent
>
> This is not enough to enable `shelve --keep` to work, but it's a
> necessary first step.
>

Thanks a lot \o/ \o/ \o/

>
> diff --git a/hgext/shelve.py b/hgext/shelve.py
> --- a/hgext/shelve.py
> +++ b/hgext/shelve.py
> @@ -506,7 +506,10 @@ def _docreatecmd(ui, repo, pats, opts):
>          if ui.formatted():
>              desc = stringutil.ellipsis(desc, ui.termwidth())
>          ui.status(_('shelved as %s\n') % name)
> -        hg.update(repo, parent.node())
> +        if opts['keep']:
> +            repo.setparents(parent.node(), nodemod.nullid)
>

This function can be used here:
https://www.mercurial-scm.org/repo/hg-committed/file/6fef387af1da/mercurial/scmutil.py#l1257

It should make the next patch unrequired.

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -506,7 +506,10 @@  def _docreatecmd(ui, repo, pats, opts):
         if ui.formatted():
             desc = stringutil.ellipsis(desc, ui.termwidth())
         ui.status(_('shelved as %s\n') % name)
-        hg.update(repo, parent.node())
+        if opts['keep']:
+            repo.setparents(parent.node(), nodemod.nullid)
+        else:
+            hg.update(repo, parent.node())
         if origbranch != repo['.'].branch() and not _isbareshelve(pats, opts):
             repo.dirstate.setbranch(origbranch)