Patchwork histedit: expose histedit plan via tags RFC

login
register
mail settings
Submitter timeless@mozdev.org
Date Dec. 25, 2015, 9:23 p.m.
Message ID <ea3b6c05af8fe118aafe.1451078585@waste.org>
Download mbox | patch
Permalink /patch/12352/
State Deferred
Headers show

Comments

timeless@mozdev.org - Dec. 25, 2015, 9:23 p.m.
# HG changeset patch
# User timeless <timeless@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

$ 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
Augie Fackler - Dec. 29, 2015, 10:26 p.m.
On Fri, Dec 25, 2015 at 03:23:05PM -0600, timeless wrote:
> # HG changeset patch
> # User timeless <timeless@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@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
Mateusz Kwapich - Jan. 5, 2016, 9:32 p.m.
I usually don’t do long histedit chains - that may be why I don’t see how
useful is this. Can you tell me more about the intended use cases of such
tags?


On 12/29/15, 2:26 PM, "Mercurial-devel on behalf of Augie Fackler" <mercurial-devel-bounces@selenic.com on behalf of raf@durin42.com> wrote:

>On Fri, Dec 25, 2015 at 03:23:05PM -0600, timeless wrote:

>> # HG changeset patch

>> # User timeless <timeless@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://urldefense.proofpoint.com/v2/url?u=https-3A__public.etherpad-2Dmozilla.org_p_HisteditLabels&d=CwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=dK7q_6fOymlfdGMBe3wUaA&m=Wr5NcAfmeBq5rmUpIolh-XWaMGhdfHgB0IJhhNiexC4&s=g343cEq-wnu5XEOjK_lYnorbhkRKf9P8Fs-UhOD7FB0&e= 

>

>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@selenic.com

>> https://selenic.com/mailman/listinfo/mercurial-devel

>_______________________________________________

>Mercurial-devel mailing list

>Mercurial-devel@selenic.com

>https://selenic.com/mailman/listinfo/mercurial-devel
timeless - Jan. 5, 2016, 9:44 p.m.
On Tue, Jan 5, 2016 at 4:32 PM, Mateusz Kwapich <mitrandir@fb.com> wrote:
> I usually don’t do long histedit chains - that may be why I don’t see how
> useful is this. Can you tell me more about the intended use cases of such
> tags?

I frequently do long chains, and have many chains in progress. It's
really helpful for me to be able to look at a graphical log of the
work I've done and the work I'm about to do. While there is an
--edit-plan, it doesn't help me look across at where I am in what I've
already done.

My histedits often involve quite a bit of resequencing and folding,
and it's pretty easy to get lost.
Augie Fackler - Jan. 6, 2016, 9:22 p.m.
> On Jan 5, 2016, at 4:44 PM, timeless <timeless@gmail.com> wrote:
> 
> On Tue, Jan 5, 2016 at 4:32 PM, Mateusz Kwapich <mitrandir@fb.com> wrote:
>> I usually don’t do long histedit chains - that may be why I don’t see how
>> useful is this. Can you tell me more about the intended use cases of such
>> tags?
> 
> I frequently do long chains, and have many chains in progress. It's
> really helpful for me to be able to look at a graphical log of the
> work I've done and the work I'm about to do. While there is an
> --edit-plan, it doesn't help me look across at where I am in what I've
> already done.
> 
> My histedits often involve quite a bit of resequencing and folding,
> and it's pretty easy to get lost.

I can see merit to the feature, but I’m not sure:

1) What the labels should look like
2) That dropping them in the tags namespace is sensible

> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
Pierre-Yves David - Jan. 8, 2016, 1:33 p.m.
On 12/29/2015 10:26 PM, Augie Fackler wrote:
> On Fri, Dec 25, 2015 at 03:23:05PM -0600, timeless wrote:
>> # HG changeset patch
>> # User timeless <timeless@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.

+1 on this.

That would be nice to have a Plan page about this.

This label must not goes into the tags api. We have the namespace API 
for this kind of purpose now, please use it.

I'm +1 for the general idea of the feature (also see what hg bisect is 
doing/should do) I've not looked at the details of your plan yet.

Patch

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)