From e803561cdceb1db8c5d6a9e0e8a4466645c1b8e8 Mon Sep 17 00:00:00 2001 From: Saurabh Singh Date: Wed, 10 Jan 2018 08:10:27 -0800 Subject: [PATCH] pushrebase: skip adding --to option to push command if it already exists Summary: pushrebase extension adds the --to option to push command if the remotenames extension is not loaded. This is not a robust enough check as other extensions like infinitepush can also add the --to option leading to duplicate options. This commit addresses the same. Test Plan: Ran all the tests. Reviewers: rmcelroy, #mercurial, #sourcecontrol Reviewed By: rmcelroy Differential Revision: https://phabricator.intern.facebook.com/D6691642 Signature: 6691642:1515578521:9f783df23df9fa8d3291a6f050cc1d5b6e5dd2fa --- hgext/pushrebase.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hgext/pushrebase.py b/hgext/pushrebase.py index 50a8ff90bc..e51f87e1d8 100644 --- a/hgext/pushrebase.py +++ b/hgext/pushrebase.py @@ -89,10 +89,8 @@ def uisetup(ui): def extsetup(ui): entry = wrapcommand(commands.table, 'push', _push) - try: - # Don't add the 'to' arg if it already exists - extensions.find('remotenames') - except KeyError: + # Don't add the 'to' arg if it already exists + if not any(a for a in entry[1] if a[1] == 'to'): entry[1].append(('', 'to', '', _('server revision to rebase onto'))) partorder = exchange.b2partsgenorder