[PATCH 08 of 10 shelve-ext v3] shelve: add obs-based unshelve functionality

Sean Farley sean at farley.io
Mon Feb 13 15:05:52 EST 2017


Kostia Balytskyi <ikostia at fb.com> writes:

> # HG changeset patch
> # User Kostia Balytskyi <ikostia at fb.com>
> # Date 1484835394 28800
> #      Thu Jan 19 06:16:34 2017 -0800
> # Node ID 94a237a046059ef246aacb2c3ad809c9f0bdbe70
> # Parent  abdf9565fdce15604ea4abf013cb7c98a11f70ca
> shelve: add obs-based unshelve functionality
>
> Obsolescense-based unshelve works as follows:
> 1. Instead of stripping temporary nodes, markers are created to
> obsolete them.
> 2. Restoring commit is just finding it in an unfiltered repo.
> 3. '--keep' is only passed to rebase on traditional unshelves
> (and thus traditional rebases), becuase we want markers to be
> created fro obsolete-based rebases.
> 4. 'hg unshelve' uses unfiltered repo to perform rebases
> because we want rebase to be able to create markers between original
> and new commits. 'rebaseskipobsolete' is disabled to make rebase not
> skip the commit altogether.
>
> I have a test for the case when shelve node has been stripped before
> unshelve call, that test is together with ~30 commits I was talking
> about in patch 1.
>
> diff --git a/hgext/shelve.py b/hgext/shelve.py
> --- a/hgext/shelve.py
> +++ b/hgext/shelve.py
> @@ -25,6 +25,7 @@ from __future__ import absolute_import
>  import collections
>  import errno
>  import itertools
> +import time
>  
>  from mercurial.i18n import _
>  from mercurial import (
> @@ -252,8 +253,13 @@ class shelvedstate(object):
>  
>      def prunenodes(self):
>          """Cleanup temporary nodes from the repo"""
> -        repair.strip(self.ui, self.repo, self.nodestoprune, backup=False,
> -                     topic='shelve')
> +        if self.obsshelve:
> +            unfi = self.repo.unfiltered()
> +            relations = [(unfi[n], ()) for n in self.nodestoprune]
> +            obsolete.createmarkers(self.repo, relations)
> +        else:
> +            repair.strip(self.ui, self.repo, self.nodestoprune, backup=False,
> +                         topic='shelve')

All these 'if self.obsshelve' seem to suggest that this could use a
higher-level abstraction with subclassing (but this is fine as-is, we
can refactor later if desired).


More information about the Mercurial-devel mailing list