[PATCH V3] histedit: add a hint about enabled dropmissing to histedit edit comment

Mateusz Kwapich mitrandir at fb.com
Sat Mar 19 18:40:18 UTC 2016


# HG changeset patch
# User Mateusz Kwapich <mitrandir at fb.com>
# Date 1458412753 25200
#      Sat Mar 19 11:39:13 2016 -0700
# Node ID 7b5be7eb887fbfad229a3774a25f95da146511bd
# Parent  dfb21c34e07dfeeccb9be6197ad15733ee53a48e
histedit: add a hint about enabled dropmissing to histedit edit comment

Adds a hint to histedit comment reminding user about enabled dropmissing.
This will make the enabled dropmissing more visible. The example comment:

# Edit history between b592564a803c and b54649a8a63f
#
# Commits are listed from least to most recent
#
# You can reorder changesets by reordering the lines
#
# Commands:
#
#  e, edit = use commit, but stop for amending
#  m, mess = edit commit message without changing commit content
#  p, pick = use commit
#  b, base = checkout changeset and apply further changesets from there
#  d, drop = remove commit from history
#  f, fold = use commit, but combine it with the one above
#  r, roll = like fold, but discard this commit's description
#
# Deleting a changeset from the list will DISCARD it from the edited history!

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -220,13 +220,14 @@ secondaryactions = set()
 tertiaryactions = set()
 internalactions = set()
 
-def geteditcomment(first, last):
+def geteditcomment(ui, first, last):
     """ construct the editor comment
     The comment includes::
      - an intro
      - sorted primary commands
      - sorted short commands
      - sorted long commands
+     - additional hints
 
     Commands are only included once.
     """
@@ -255,8 +256,14 @@ Commands:
         addverb(v)
     actions.append('')
 
-    return ''.join(['# %s\n' % l if l else '#\n'
-                    for l in ((intro % (first, last)).split('\n')) + actions])
+    hints = []
+    if ui.configbool('histedit', 'dropmissing'):
+        hints.append("Deleting a changeset from the list "
+                     "will DISCARD it from the edited history!")
+
+    lines = (intro % (first, last)).split('\n') + actions + hints
+
+    return ''.join(['# %s\n' % l if l else '#\n' for l in lines])
 
 class histeditstate(object):
     def __init__(self, repo, parentctxnode=None, actions=None, keep=None,
@@ -1186,7 +1193,8 @@ def _aborthistedit(ui, repo, state):
 def _edithisteditplan(ui, repo, state, rules):
     state.read()
     if not rules:
-        comment = geteditcomment(node.short(state.parentctxnode),
+        comment = geteditcomment(ui,
+                                 node.short(state.parentctxnode),
                                  node.short(state.topmost))
         rules = ruleeditor(repo, ui, state.actions, comment)
     else:
@@ -1232,7 +1240,7 @@ def _newhistedit(ui, repo, state, revs, 
 
     ctxs = [repo[r] for r in revs]
     if not rules:
-        comment = geteditcomment(node.short(root), node.short(topmost))
+        comment = geteditcomment(ui, node.short(root), node.short(topmost))
         actions = [pick(state, r) for r in revs]
         rules = ruleeditor(repo, ui, actions, comment)
     else:


More information about the Mercurial-devel mailing list