changeset 1911:442a7cb8404e

histedit: restrict default edited set to current topic when possible If we have an active topic, we restrict the edit within that topic.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 17 Mar 2016 09:14:57 -0700
parents 24986e5a537c
children 692a1aa1350c
files hgext3rd/topic/destination.py tests/test-topic-dest.t
diffstat 2 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/topic/destination.py	Thu Mar 17 09:13:12 2016 -0700
+++ b/hgext3rd/topic/destination.py	Thu Mar 17 09:14:57 2016 -0700
@@ -55,6 +55,15 @@
         movemark = repo['.'].node()
     return node, movemark, None
 
+def desthistedit(orig, ui, repo):
+    if not (ui.config('histedit', 'defaultrev', None) is None
+            and repo.currenttopic):
+        return orig(ui, repo)
+    revs = repo.revs('::. and stack()')
+    if revs:
+        return revs.min()
+    return None
+
 def setupdest():
     if util.safehasattr(destutil, '_destmergebranch'):
         extensions.wrapfunction(destutil, '_destmergebranch', _destmergebranch)
@@ -67,6 +76,8 @@
         bridx = destutil.destupdatesteps.index('branch')
         destutil.destupdatesteps.insert(bridx, 'topic')
         destutil.destupdatestepmap['topic'] = _destupdatetopic
+    if util.safehasattr(destutil, 'desthistedit'):
+        extensions.wrapfunction(destutil, 'desthistedit', desthistedit)
 
 def ngtip(repo, branch, all=False):
     """tip new generation"""
--- a/tests/test-topic-dest.t	Thu Mar 17 09:13:12 2016 -0700
+++ b/tests/test-topic-dest.t	Thu Mar 17 09:14:57 2016 -0700
@@ -5,6 +5,7 @@
   $ cat <<EOF >> .hg/hgrc
   > [extensions]
   > rebase=
+  > histedit=
   > [phases]
   > publish=false
   > EOF
@@ -479,3 +480,17 @@
   |
   o  0 () c_alpha
   
+
+Default destination for histedit
+================================
+
+By default hisetdit should edit with the current topic only
+(even when based on other draft
+
+  $ hg phase 'desc(c_zeta)'
+  11: draft
+  $ HGEDITOR=cat hg histedit | grep pick
+  pick e44744d9ad73 12 babar
+  pick 38eea8439aee 14 arthur
+  pick 411315c48bdc 15 pompadour
+  #  p, pick = use commit