From 6b99e3117550d9d071c2709a5a903f1c09a6a549 Mon Sep 17 00:00:00 2001 From: Durham Goode Date: Tue, 7 Apr 2015 13:52:59 -0700 Subject: [PATCH] fbamend: move evolve warning to be inside the amend command Summary: With the new evolve+inhibit ecosystem, we want to allow amend and amend --rebase to continue working even when evolve is on. Let's move the evolve check to be inside the amend command, and only complain when we see the evolve commands enabled. Test Plan: Added a test Reviewers: lcharignon, pyd Reviewed By: pyd Differential Revision: https://phabricator.fb.com/D2033649 Signature: t1:2033649:1430346833:3116b704e49f634709a6fea32e217b94e731b96f --- fbamend.py | 23 ++++++++++----------- tests/test-fbamend.t | 49 +++++++++++++++----------------------------- 2 files changed, 28 insertions(+), 44 deletions(-) diff --git a/fbamend.py b/fbamend.py index 4a68111f4f..d8a29d75cc 100644 --- a/fbamend.py +++ b/fbamend.py @@ -36,18 +36,6 @@ amendopts = [ ] def uisetup(ui): - if obsolete._enabled: - msg = ('fbamend and evolve extension are imcompatible, ' - 'fbamend deactivated.\n' - 'You can either disable it globally:\n' - '- type `hg config --edit`\n' - '- drop the `fbamend=` line from the `[extensions]` section\n' - 'or disable it for a specific repo:\n' - '- type `hg config --local --edit`\n' - '- add a `fbamend=!%s` line in the `[extensions]` section\n') - msg %= ui.config('extensions', 'fbamend') - ui.write_err(msg) - return entry = extensions.wrapcommand(commands.table, 'commit', commit) for opt in amendopts: opt = (opt[0], opt[1], opt[2], "(with --amend) " + opt[3]) @@ -72,6 +60,17 @@ def commit(orig, ui, repo, *pats, **opts): def amend(ui, repo, *pats, **opts): '''amend the current commit with more changes ''' + if obsolete.isenabled(repo, 'allnewcommands'): + msg = ('fbamend and evolve extension are incompatible, ' + 'fbamend deactivated.\n' + 'You can either disable it globally:\n' + '- type `hg config --edit`\n' + '- drop the `fbamend=` line from the `[extensions]` section\n' + 'or disable it for a specific repo:\n' + '- type `hg config --local --edit`\n' + '- add a `fbamend=!%s` line in the `[extensions]` section\n') + msg %= ui.config('extensions', 'fbamend') + ui.write_err(msg) rebase = opts.get('rebase') if rebase and _histediting(repo): diff --git a/tests/test-fbamend.t b/tests/test-fbamend.t index 7b42534095..74030dd657 100644 --- a/tests/test-fbamend.t +++ b/tests/test-fbamend.t @@ -266,47 +266,32 @@ Test that --addremove/-A works Test that the extension disables itself when evolution is enabled - $ cat > ${TESTTMP}/obs.py << EOF - > import mercurial.obsolete - > mercurial.obsolete._enabled = True + $ $PYTHON -c 'import evolve' || exit 80 + $ cat >> .hg/hgrc < [extensions] + > evolve= > EOF - $ echo '[extensions]' >> $HGRCPATH - $ echo "obs=${TESTTMP}/obs.py" >> $HGRCPATH -noisy warning +noisy warning during amend - $ hg version 2>&1 - fbamend and evolve extension are imcompatible, fbamend deactivated. + $ hg amend 2>&1 + fbamend and evolve extension are incompatible, fbamend deactivated. You can either disable it globally: - type `hg config --edit` - drop the `fbamend=` line from the `[extensions]` section or disable it for a specific repo: - type `hg config --local --edit` - add a `fbamend=!$TESTTMP/fbamend.py` line in the `[extensions]` section - Mercurial Distributed SCM (version *) (glob) - (see http://mercurial.selenic.com for more information) - - Copyright (C) 2005-2015 Matt Mackall and others - This is free software; see the source for copying conditions. There is NO - warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -commit has no new flags - - $ hg help commit 2> /dev/null | grep -- --fixup - [1] - $ hg help commit 2> /dev/null | grep -- --rebase + nothing changed [1] -The amend command is missing +no warning if only obsolete markers are enabled - $ hg help amend - fbamend and evolve extension are imcompatible, fbamend deactivated. - You can either disable it globally: - - type `hg config --edit` - - drop the `fbamend=` line from the `[extensions]` section - or disable it for a specific repo: - - type `hg config --local --edit` - - add a `fbamend=!$TESTTMP/fbamend.py` line in the `[extensions]` section - abort: no such help topic: amend - (try "hg help --keyword amend") - [255] + $ cat >> .hg/hgrc < [experimental] + > evolution=createmarkers + > EOF + + $ hg amend + nothing changed + [1]