Disabling merge in tweakdefaults

Summary: Disabling merge in tweakdefaults to replace the hook

Test Plan: enable, disabled, disabled and meaasge modified

Reviewers: #sourcecontrol, rmcelroy

Differential Revision: https://phabricator.fb.com/D2515407

Tasks: 8593074
This commit is contained in:
Cecile Berillon 2015-10-06 16:39:18 -07:00
parent 5112a69d61
commit 0272f0d7ec
2 changed files with 25 additions and 0 deletions

View File

@ -233,6 +233,18 @@ Test tweaked branch command
$ hg branches --config tweakdefaults.branchesmessage='testing'| head -n0
testing
Test tweaked merge command
$ hg merge | head -n1
abort: no matching bookmark to merge - please merge with an explicit rev or bookmark
(run 'hg heads' to see all heads)
$ hg merge --config tweakdefaults.allowmerge=false
abort: merging is not supported for this repository -- use rebase instead
[255]
$ hg merge --config tweakdefaults.mergemessage='testing' --config tweakdefaults.allowmerge=false
abort: testing
[255]
Test that status is default relative
$ mkdir foo

View File

@ -56,6 +56,8 @@ def extsetup(ui):
options.append(('', 'new', None, _('allow branch creation')))
wrapcommand(commands.table, 'branches', branchescmd)
wrapcommand(commands.table, 'merge', mergecmd)
entry = wrapcommand(commands.table, 'status', statuscmd)
options = entry[1]
options.append(
@ -252,6 +254,17 @@ def branchescmd(orig, ui, repo, active, closed, **opts):
ui.warn(message + '\n')
return orig(ui, repo, active, closed, **opts)
def mergecmd(orig, ui, repo, node=None, **opts):
"""
Allowing to disable merges
"""
message = ui.config('tweakdefaults', 'mergemessage',
_('merging is not supported for this repository -- use rebase instead'))
if ui.configbool('tweakdefaults','allowmerge', True):
return orig(ui, repo, node, **opts)
else:
raise util.Abort(message)
def statuscmd(orig, ui, repo, *pats, **opts):
"""
Make status relative by default for interactive usage