[PATCH] histedit: expose histedit plan via tags RFC

Augie Fackler raf at durin42.com
Tue Dec 29 16:26:20 CST 2015


On Fri, Dec 25, 2015 at 03:23:05PM -0600, timeless wrote:
> # HG changeset patch
> # User timeless <timeless at mozdev.org>
> # Date 1451069184 0
> #      Fri Dec 25 18:46:24 2015 +0000
> # Node ID ea3b6c05af8fe118aafe23f719bce3ad86f3f297
> # Parent  e2aa9c4030c4109e5efa50462ffc6048ca30106f
> histedit: expose histedit plan via tags RFC
>
> This isn't ready for merging, but I'd like people to think about this...
>
> https://public.etherpad-mozilla.org/p/HisteditLabels

Interesting thought. Probably worth talking to Mateusz (from Facebook)
and writing up a more complete Plan page on the wiki. I'd probably try
and push you towards using some sort of namespace rather than tags for
this as well, but that might defeat the purpose a littl I guess. Seems
like an area that's worth pursuing more though, for users with really
long histedit chains.

>
> $ EDITOR=cat hg histedit --edit-plan
> mess 4a16ba62654e 2 1
> drop 5d1098ab227e 3 2
> fold 6767ceabe4dd 4 3
> roll 361cfb0601fc 5 4
> pick 405aae9a557f 6 5
> pick 629dbc9cce33 7 6
> pick fb6bc3d9960a 8 7
> pick c67e1d4dd153 9 8
>
> $ hg log -G --template "{rev}\n{tags}"
> @  12
> |  h_2_applied tip
> o  11
>    h_0_applied
> o  10
> |  h_0 h_0_origin
> o  9
> |  h_10 h_10_pick
> o  8
> |  h_9 h_9_pick
> o  7
> |  h_8 h_8_pick
> o  6
> |  h_7 h_7_pick
> o  5
> |  h_6 h_6_roll
> o  4
> |  h_5 h_5_fold
> o  3
> |  h-next h_4 h_4_drop
> o  2
> |  h-current h_3 h_3_mess
> o  1
> |  h-prev h_2 h_2_origin
> o  0
>    h_1 h_1_dropped
>
> diff --git a/hgext/histedit.py b/hgext/histedit.py
> --- a/hgext/histedit.py
> +++ b/hgext/histedit.py
> @@ -193,6 +193,7 @@
>  from mercurial import scmutil
>  from mercurial import util
>  from mercurial import obsolete
> +from mercurial import localrepo
>  from mercurial import merge as mergemod
>  from mercurial.lock import release
>  from mercurial.i18n import _
> @@ -1260,7 +1261,7 @@
>      1) the list of final node
>      2) the list of temporary node
>
> -    This meant to be used on abort as less data are required in this case.
> +    This is meant to be used on abort as less data are required in this case.
>      """
>      replacements = state.replacements
>      allsuccs = set()
> @@ -1428,6 +1429,55 @@
>          ui.write(_('hist:   %s (histedit --continue)\n') %
>                   (ui.label(_('%d remaining'), 'histedit.remaining') %
>                    len(state.actions)))
> +def reposetup(ui, repo):
> +    class histeditrepo(repo.__class__):
> +        def _findtags(self):
> +            '''augment tags from base class with patch tags'''
> +            result = super(histeditrepo, self)._findtags()
> +
> +            histedittags = []
> +
> +            state = histeditstate(repo)
> +
> +            if not state.inprogress():
> +                return result
> +            state.read()
> +
> +            i = 0
> +            def addstate(rev, tag):
> +                histedittags.append((rev, "h_%d" % i))
> +                histedittags.append((rev, "h_%d_%s" % (i, tag)))
> +            for (origin, applied) in state.replacements:
> +                if len(applied):
> +                    histedittags.append((applied[0], "h_%d_%s" % (i, 'applied')))
> +                    addstate(origin, 'origin')
> +                else:
> +                    addstate(origin, 'dropped')
> +                i += 1
> +            if i != 0:
> +                histedittags.append((histedittags[-1][0], 'h-prev'))
> +            if state.actions:
> +                histedittags.append((state.actions[0].node, 'h-current'))
> +                if len(state.actions) > 1:
> +                    histedittags.append((state.actions[1].node, 'h-next'))
> +            for a in state.actions:
> +                addstate(a.node, a.verb)
> +                i += 1
> +            if not histedittags:
> +                return result
> +
> +            tags = result[0]
> +            for item in histedittags:
> +                if item[1] in tags:
> +                    self.ui.warn(_('tag %s overrides histedit concept of same '
> +                                   'name\n') % item[1])
> +                else:
> +                    tags[item[1]] = item[0]
> +
> +            return result
> +
> +    if repo.local():
> +        repo.__class__ = histeditrepo
>
>  def extsetup(ui):
>      cmdutil.summaryhooks.add('histedit', summaryhook)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list