histedit: add history-editing-backup config option
authorSushil khanchi <sushilkhanchi97@gmail.com>
Tue, 10 Jul 2018 17:01:06 +0530
changeset 38733 c2586a6e5884
parent 38732 be4984261611
child 38734 25880ddf9a86
histedit: add history-editing-backup config option Instead of passing --no-backup option every time you don't want to store backup, now you can set config option: [ui] history-editing-backup = False This option aims to operate on every history editing command. Differential Revision: https://phab.mercurial-scm.org/D3901
hgext/histedit.py
mercurial/configitems.py
tests/test-histedit-no-backup.t
--- a/hgext/histedit.py	Wed Jul 18 09:49:34 2018 -0700
+++ b/hgext/histedit.py	Tue Jul 10 17:01:06 2018 +0530
@@ -1111,7 +1111,9 @@
     fm.startitem()
     goal = _getgoal(opts)
     revs = opts.get('rev', [])
-    nobackup = opts.get('no_backup')
+    # experimental config: ui.history-editing-backup
+    nobackup = (opts.get('no_backup') or
+                not ui.configbool('ui', 'history-editing-backup'))
     rules = opts.get('commands', '')
     state.keep = opts.get('keep', False)
 
--- a/mercurial/configitems.py	Wed Jul 18 09:49:34 2018 -0700
+++ b/mercurial/configitems.py	Tue Jul 10 17:01:06 2018 +0530
@@ -1093,6 +1093,9 @@
 coreconfigitem('ui', 'graphnodetemplate',
     default=None,
 )
+coreconfigitem('ui', 'history-editing-backup',
+    default=True,
+)
 coreconfigitem('ui', 'interactive',
     default=None,
 )
--- a/tests/test-histedit-no-backup.t	Wed Jul 18 09:49:34 2018 -0700
+++ b/tests/test-histedit-no-backup.t	Tue Jul 10 17:01:06 2018 +0530
@@ -93,3 +93,41 @@
   o  0   36b4bdd91f5b   1970-01-01 00:00 +0000   test
        one
   
+==========================================
+Test history-editing-backup config option|
+==========================================
+Test when `history-editing-backup` config option is enabled:
+  $ hg histedit -r '36b4bdd91f5b' --commands - << EOF
+  > pick 36b4bdd91f5b 0 one
+  > pick 6153eb23e623 1 two
+  > roll 80d23dfa866d 2 three
+  > edit 7d5187087c79 3 four
+  > EOF
+  merging file
+  Editing (7d5187087c79), you may commit or record as needed now.
+  (hg histedit --continue to resume)
+  [1]
+  $ hg histedit --abort
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  saved backup bundle to $TESTTMP/foo/.hg/strip-backup/1d8f701c7b35-cf7be322-backup.hg
+  saved backup bundle to $TESTTMP/foo/.hg/strip-backup/5c0056670bce-b54b65d0-backup.hg
+
+Test when `history-editing-backup` config option is not enabled
+Enable config option:
+  $ cat >>$HGRCPATH <<EOF
+  > [ui]
+  > history-editing-backup=False
+  > EOF
+
+  $ hg histedit -r '36b4bdd91f5b' --commands - << EOF
+  > pick 36b4bdd91f5b 0 one
+  > pick 6153eb23e623 1 two
+  > roll 80d23dfa866d 2 three
+  > edit 7d5187087c79 3 four
+  > EOF
+  merging file
+  Editing (7d5187087c79), you may commit or record as needed now.
+  (hg histedit --continue to resume)
+  [1]
+  $ hg histedit --abort
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved