From patchwork Fri Dec 13 13:57:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11290613 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A5EC518B6 for ; Fri, 13 Dec 2019 20:37:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 575BD24751 for ; Fri, 13 Dec 2019 20:37:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KrlfyFhr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727640AbfLMN6I (ORCPT ); Fri, 13 Dec 2019 08:58:08 -0500 Received: from mail-wr1-f52.google.com ([209.85.221.52]:34481 "EHLO mail-wr1-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727507AbfLMN6H (ORCPT ); Fri, 13 Dec 2019 08:58:07 -0500 Received: by mail-wr1-f52.google.com with SMTP id t2so6776846wrr.1 for ; Fri, 13 Dec 2019 05:58:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=K4nTQ0kCXi1h71P7LCfnyO4NxOvrAcJyf5H1qyP/pVI=; b=KrlfyFhrrhT1H7WuiXIPmNfkcGnxJZP/bvU2Me+a7Ar0crSLEZslfztCmFcg4CKzPU M3oHwhsHY1vEqsSVzLUazu9/A1EcXlWbDAIMkvNR6xAl4nUjbf+R73/FfLm3cxdJafJB lz6OHmrXcgfWH3dXNYT6N6uYii4sCwvKU25YMYo7Woc4FVYtFLSq2dTo0sNYJALVBm+5 bnaDyZ4qZLF56w5FS7o5bAwZUQrxjtLes5ArLbcOFvLUgtQ9mvb6X+AyiSgUKbSKn+0E zkpOt5hCGJInO1Zsoq8kmyMisb4slr96pOdFYO0fGat4fi8/V9XLQA/jDloI3YKORZBS 8L6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=K4nTQ0kCXi1h71P7LCfnyO4NxOvrAcJyf5H1qyP/pVI=; b=MIL17ZSbXwrfNvk3zPBo0nh+pC9lKCzWcSQ6pxNr530WE5RyLdj/hsDzGbgxQr0DRV 2oVId7BhTkDsz6d1NV8H7cY2x2hCTiPvS8OsN9/gLKhCPcrz6X3ElWezrTImuHBgg43J qIV371rkh85FVjSWZJbUZmDnnnwIHnnPMS98Ltm9LK30qKDXfmZcu+Hlg1LcoTGSv6Ih bp7B09fVUbi5MHXVj8t00Yl/0M8RDHgtnE3GkSmdkWoHKdkp+5lAkVS6NErk9zOP5yfk 0tq/dZ8Cyh5r0icD89Qv37VLPjD2FyzT6a5riYwpBMQe/J3K0DwcIm0A8hP79faXe1Gi 6tlg== X-Gm-Message-State: APjAAAV1o2vEX6wQQ20/V5QpTLMXUEYOsJT0IBrc1YPQEJKJEk0R2Be6 aigmG9RQ2Fkwcjm33J7ekfeom6U0 X-Google-Smtp-Source: APXvYqzZ/0Nv66hHXK2OQYH1h7nRuyn8wMUqv8pc08bXoqOg/TaDkfZcVrA+LPZGrPXpBPMflU6DYg== X-Received: by 2002:adf:e887:: with SMTP id d7mr12589506wrm.162.1576245483612; Fri, 13 Dec 2019 05:58:03 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id o194sm303105wme.45.2019.12.13.05.58.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Dec 2019 05:58:03 -0800 (PST) Message-Id: <6c23cd56842e76e5c11f32ba59fd7729769ab4b7.1576245481.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Ben Keene via GitGitGadget" Date: Fri, 13 Dec 2019 13:57:58 +0000 Subject: [PATCH v4 1/4] git-p4: yes/no prompts should sanitize user text Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Ben Keene , Junio C Hamano , Ben Keene Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Ben Keene When prompting the user interactively for direction, the tests are not forgiving of user input format. For example, the first query asks for a yes/no response. If the user enters the full word "yes" or "no" or enters a capital "Y" the test will fail. Create a new function, prompt(prompt_text) where * prompt_text is the text prompt for the user * returns a single character where valid return values are found by inspecting prompt_text for single characters surrounded by square brackets This new function must prompt the user for input and sanitize it by converting the response to a lower case string, trimming leading and trailing spaces, and checking if the first character is in the list of choices. If it is, return the first letter. Change the current references to raw_input() to use this new function. Since the method requires the returned text to be one of the available choices, remove the loop from the calling code that handles response verification. Thanks-to: Denton Liu Signed-off-by: Ben Keene --- git-p4.py | 67 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/git-p4.py b/git-p4.py index 60c73b6a37..3b3f1469a6 100755 --- a/git-p4.py +++ b/git-p4.py @@ -167,6 +167,21 @@ def die(msg): sys.stderr.write(msg + "\n") sys.exit(1) +def prompt(prompt_text): + """ Prompt the user to choose one of the choices + + Choices are identified in the prompt_text by square brackets around + a single letter option. + """ + choices = set(m.group(1) for m in re.finditer(r"\[(.)\]", prompt_text)) + while True: + response = raw_input(prompt_text).strip().lower() + if not response: + continue + response = response[0] + if response in choices: + return response + def write_pipe(c, stdin): if verbose: sys.stderr.write('Writing pipe: %s\n' % str(c)) @@ -1778,12 +1793,11 @@ def edit_template(self, template_file): if os.stat(template_file).st_mtime > mtime: return True - while True: - response = raw_input("Submit template unchanged. Submit anyway? [y]es, [n]o (skip this patch) ") - if response == 'y': - return True - if response == 'n': - return False + response = prompt("Submit template unchanged. Submit anyway? [y]es, [n]o (skip this patch) ") + if response == 'y': + return True + if response == 'n': + return False def get_diff_description(self, editedFiles, filesToAdd, symlinks): # diff @@ -2345,31 +2359,22 @@ def run(self, args): " --prepare-p4-only") break if i < last: - quit = False - while True: - # prompt for what to do, or use the option/variable - if self.conflict_behavior == "ask": - print("What do you want to do?") - response = raw_input("[s]kip this commit but apply" - " the rest, or [q]uit? ") - if not response: - continue - elif self.conflict_behavior == "skip": - response = "s" - elif self.conflict_behavior == "quit": - response = "q" - else: - die("Unknown conflict_behavior '%s'" % - self.conflict_behavior) - - if response[0] == "s": - print("Skipping this commit, but applying the rest") - break - if response[0] == "q": - print("Quitting") - quit = True - break - if quit: + # prompt for what to do, or use the option/variable + if self.conflict_behavior == "ask": + print("What do you want to do?") + response = prompt("[s]kip this commit but apply the rest, or [q]uit? ") + elif self.conflict_behavior == "skip": + response = "s" + elif self.conflict_behavior == "quit": + response = "q" + else: + die("Unknown conflict_behavior '%s'" % + self.conflict_behavior) + + if response == "s": + print("Skipping this commit, but applying the rest") + if response == "q": + print("Quitting") break chdir(self.oldWorkingDirectory) From patchwork Fri Dec 13 13:57:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11290609 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 31483175D for ; Fri, 13 Dec 2019 20:37:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D0D8F24715 for ; Fri, 13 Dec 2019 20:37:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ds2quPmB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727620AbfLMN6H (ORCPT ); Fri, 13 Dec 2019 08:58:07 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:37512 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727563AbfLMN6G (ORCPT ); Fri, 13 Dec 2019 08:58:06 -0500 Received: by mail-wm1-f66.google.com with SMTP id f129so6667010wmf.2 for ; Fri, 13 Dec 2019 05:58:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=CrcFgAOSLMt24NNawc3MVnI7liTnEq9Ggfv8QAET1f8=; b=ds2quPmBft6WDqhDsVKr1NNezV4NwHMRECAjCyCy2kE5vrnBmViUAaNbCjI0up/vmA EEZg0vyiI1Q9fHwMYMxRhQnW+SDCJ3NtAxC9s4Ml92a3yEmWgON61lV5/C/8D84PQshq W64z7IyXEttqL+9Pmz+eEsTcF7NZsSuJuqGE8QctgZZI0BjULSgd6vbR6mVud/2/+Ybg Oe6wxrDzXysrhRvsl3OqnkIS2JLwCBBRaff2Ngh4sXDuSTam1ai6vY0Tinb+KDeqBfA9 MEB9fAjXq5Ki3X1QTU2QQW3Qs+/3JsQ2A1zaC26YO22/7n8KYIosd4hq1r2HBJjnq5/h 6+Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=CrcFgAOSLMt24NNawc3MVnI7liTnEq9Ggfv8QAET1f8=; b=HJ6N5gfCUaMFUEAix588GM4yWHm+FowKGbXLdt/DRqlhpIWuBJXAeH4T/DNVP4lmGw VG73NLO21Dl42vBUMF4169VRvzr4gcTpjo6pGB+Nq7v/PI1EBu0AP3gaAZdn2lVSPhiv +HnKvVbKuMjX7UHDeqqP3K+Duay7BwZJvJgpApIYUmHcA+DYocUXjsOxHuMLYP4FHoFK Z2wSz4KwipXKiGPDrqHEosfsa7CvBbep5oxN1IgDeTt3tYH4SBvf473GQtUJcfVDjOxY 0X+NvZ4zOLJEF9HwDTWj3Q3h7EJ+Oow498Fzte7XhNUoDPzx+0YPtwjKhkAOwDuj31KW Z1hA== X-Gm-Message-State: APjAAAXsbChCdZJC2tB50UQR3Hy2yRVQFNGujpGLbHWwx3wn147iUJ2a nkl54ERbPMeWLiY52tuzI3ticTbw X-Google-Smtp-Source: APXvYqzDL2LEonMdAGl5bL8dfXSYaHlZKW2QTjK7DB2ysqih9ginNNHDYNNtczCMbJd1Gl4RqBRI3g== X-Received: by 2002:a1c:6707:: with SMTP id b7mr14176102wmc.54.1576245484438; Fri, 13 Dec 2019 05:58:04 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id a16sm9944084wrt.37.2019.12.13.05.58.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Dec 2019 05:58:03 -0800 (PST) Message-Id: In-Reply-To: References: From: "Ben Keene via GitGitGadget" Date: Fri, 13 Dec 2019 13:57:59 +0000 Subject: [PATCH v4 2/4] git-p4: show detailed help when parsing options fail Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Ben Keene , Junio C Hamano , Ben Keene Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Ben Keene When a user provides invalid parameters to git-p4, the program reports the failure but does not provide the correct command syntax. Add an exception handler to the command-line argument parser to display the command's specific command line parameter syntax when an exception is thrown. Rethrow the exception so the current behavior is retained. Signed-off-by: Ben Keene --- git-p4.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/git-p4.py b/git-p4.py index 3b3f1469a6..9165ada2fd 100755 --- a/git-p4.py +++ b/git-p4.py @@ -4145,7 +4145,12 @@ def main(): description = cmd.description, formatter = HelpFormatter()) - (cmd, args) = parser.parse_args(sys.argv[2:], cmd); + try: + (cmd, args) = parser.parse_args(sys.argv[2:], cmd); + except: + parser.print_help() + raise + global verbose verbose = cmd.verbose if cmd.needsGit: From patchwork Fri Dec 13 13:58:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11290611 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6C4996C1 for ; Fri, 13 Dec 2019 20:37:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1EFDC24715 for ; Fri, 13 Dec 2019 20:37:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JaKcfkOI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727627AbfLMN6I (ORCPT ); Fri, 13 Dec 2019 08:58:08 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:39149 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727504AbfLMN6H (ORCPT ); Fri, 13 Dec 2019 08:58:07 -0500 Received: by mail-wm1-f67.google.com with SMTP id d5so6647312wmb.4 for ; Fri, 13 Dec 2019 05:58:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=PLkOpxRjopd1grtaiqebV+fxUypmpyol1dinFMMeObI=; b=JaKcfkOIughAfXmecV2x/DKSYOliZtEJnwwlxaAQxCn2h0B+zTt7tfjAtByzyyQ8o5 DpRmWH4uAFU8f1zTcOaI3PRJytQ3UCtw5hQWcvuGVsI4RMmGl7oXGfyQCfDAAGY3U0/9 nB2VX2MtPX+wo+LqXs24/OpqPfFB/cRST+sZnp30E7VbjkuM3SVJHI7TK/gpPn+Ax0EP NZlYyZfnOre6WGcf59UDTBegNOPMm8GLDgAYFPUOqaNKQoPxwx7J26CCmkcyDiZqzhdw I85l1y38KkpRw2Heo2bgObNI7slFHMnvfH8gRK1od0wnjiONikMAgzbcDTNtqdvNb373 V5qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=PLkOpxRjopd1grtaiqebV+fxUypmpyol1dinFMMeObI=; b=dEt7GQ3P+9cRmvdrZvLX+g1oIB6s0XUAOTuPILmkMsUFApig5D+H9zyeQ95oz4C57G TVL+yTfRZTpw+p/EPVnJbttcUwA5nKc974rMXdBTcnGQchzEbhP3Fh7P6bfdH4g6uTqV gGmbwnsABkNIoxpgaNFYaCca0tynemic7UqcGe9no8Fnqe9zH5g+Yif1IyuOlWmd18eT ieP1yAfUY+Mezz6IpbkrK2b6xXPjqT33GVTmvNiLwWRa1e+MG04hMVQxTfpDcJltcxw4 N87TFUJ+LW9YiGxIi+eXuNlO41ktg/qI6hZxuTDrmfPcJXCUL6NIKx0dA5SZ+kIsuiEZ 7egQ== X-Gm-Message-State: APjAAAV3KMcjPFwpFUwmUq0roCSYwPZPBG91GXKtoejfV7RWyx/wRC+O bkoPzVh2NLXPh6ChG09Ke/qXpxJN X-Google-Smtp-Source: APXvYqxb7JDozeu2aMSneBjwq3QosRrwl96wlvuqvzDD2gFOkndtooxXpOQMIZZnu9BSRRIpCh/ciQ== X-Received: by 2002:a7b:cf21:: with SMTP id m1mr13383134wmg.170.1576245485099; Fri, 13 Dec 2019 05:58:05 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id q11sm10027240wrp.24.2019.12.13.05.58.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Dec 2019 05:58:04 -0800 (PST) Message-Id: <20f63986935cd4ca850d0ecdbb5af5fa0658167b.1576245481.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Ben Keene via GitGitGadget" Date: Fri, 13 Dec 2019 13:58:00 +0000 Subject: [PATCH v4 3/4] git-p4: wrap patchRCSKeywords test to revert changes on failure Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Ben Keene , Junio C Hamano , Ben Keene Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Ben Keene The patchRCSKeywords function has the potentional of throwing an exception and this would leave files checked out in P4 and partially modified. Add a try-catch block around the patchRCSKeywords call and revert the edited files in P4 before leaving the method. Signed-off-by: Ben Keene --- git-p4.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/git-p4.py b/git-p4.py index 9165ada2fd..03969052c8 100755 --- a/git-p4.py +++ b/git-p4.py @@ -1953,8 +1953,15 @@ def applyCommit(self, id): # disable the read-only bit on windows. if self.isWindows and file not in editedFiles: os.chmod(file, stat.S_IWRITE) - self.patchRCSKeywords(file, kwfiles[file]) - fixed_rcs_keywords = True + + try: + self.patchRCSKeywords(file, kwfiles[file]) + fixed_rcs_keywords = True + except: + # We are throwing an exception, undo all open edits + for f in editedFiles: + p4_revert(f) + raise if fixed_rcs_keywords: print("Retrying the patch with RCS keywords cleaned up") From patchwork Fri Dec 13 13:58:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11290615 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA84618B8 for ; Fri, 13 Dec 2019 20:37:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8ECA924751 for ; Fri, 13 Dec 2019 20:37:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Vs96MdNJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727669AbfLMN6J (ORCPT ); Fri, 13 Dec 2019 08:58:09 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:39874 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727606AbfLMN6I (ORCPT ); Fri, 13 Dec 2019 08:58:08 -0500 Received: by mail-wr1-f66.google.com with SMTP id y11so6754231wrt.6 for ; Fri, 13 Dec 2019 05:58:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=YmwJ1AiAhROBSVvbSzClqv1iDdOg1HA0hifERAW9N5c=; b=Vs96MdNJzwmmk4L0QybHZe10Nx2a4BaYK9QOTFU3PChABClNkgdPiiFxoghEZArJRy rqMja1TKkiZsAMnUgoN6xf59/u/AnhzRzrwkhDynuk2R0TJzNtoP+Ut7EvhEEOIXKFIQ 2S0e5NL+nulawXU+uAykGolimOWMk0MbfxY+0GCrirxwidOtpvqRx8DpB51tcc6E5RX6 d53FcIxChYxHY7qUdmT7iopVyd6dQ5xkAlgraXSbWemXiauFBLjIAiaFGR2gsBVUNCH8 gAkDCLHEepalgHdw4UtK2/7q/t5ROwKbzkTtftBMR7lHJ0oWv9mrvzcX+mhqOM7BQKlZ ag1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=YmwJ1AiAhROBSVvbSzClqv1iDdOg1HA0hifERAW9N5c=; b=SaDeRP7pVCsUaxdncnwUvisbemdLgHnH2EnipAME3qP5ieIVvXYEk1Yzvgl63CfgsX e4MOfjXDb+I1DaMneGbwyr076jnsaeJ5bTNX8ASCHBkdW5Ns897c0m6rngYWjJxnxq0V 6rPhYdq7TN9CiL9ekc9Xs2sOxZxfXYbtzDf/mTQM6teAp5hrW5rdrH+xKY7QYGF13xDI 9Adt/SuK77HvSQJ5p8HvNfcDqIlXm7Z0s9Ybz36dciutKtaPhwV6FQa8du2ohIn0ghIy xTCzmd0Qw4bPcPEhUd27Cy1t0s/CUkkll2jhX5elXO9wadP1iMRKDucTNPcH3PdjGl+t +YJA== X-Gm-Message-State: APjAAAWlGv8F9HZdVkSqZignOwcunV2qQLZQD/rPiNtzZPJtBtKMmdLj ck6yKZa1dYrtrJl9CECXxXePt2if X-Google-Smtp-Source: APXvYqyd26kFUGlOScjZREQE97sN4oQXwJ5i7tygQK5xq5gyznL5eCn46AImuR097on4GcYzI7ru3A== X-Received: by 2002:adf:cd92:: with SMTP id q18mr12748368wrj.261.1576245486011; Fri, 13 Dec 2019 05:58:06 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id g9sm10258020wro.67.2019.12.13.05.58.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Dec 2019 05:58:05 -0800 (PST) Message-Id: In-Reply-To: References: From: "Ben Keene via GitGitGadget" Date: Fri, 13 Dec 2019 13:58:01 +0000 Subject: [PATCH v4 4/4] git-p4: failure because of RCS keywords should show help Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Ben Keene , Junio C Hamano , Ben Keene Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Ben Keene When applying a commit fails because of RCS keywords, Git will fail the P4 submit. It would help the user if Git suggested that the user set git-p4.attemptRCSCleanup to true. Change the applyCommit() method that when applying a commit fails becasue of the P4 RCS Keywords, the user should consider setting git-p4.attemptRCSCleanup to true. Signed-off-by: Ben Keene --- git-p4.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/git-p4.py b/git-p4.py index 03969052c8..690e5088cc 100755 --- a/git-p4.py +++ b/git-p4.py @@ -1962,6 +1962,14 @@ def applyCommit(self, id): for f in editedFiles: p4_revert(f) raise + else: + # They do not have attemptRCSCleanup set, this might be the fail point + # Check to see if the file has RCS keywords and suggest setting the property. + for file in editedFiles | filesToDelete: + if p4_keywords_regexp_for_file(file) is not None: + print("At least one file in this commit has RCS Keywords that may be causing problems. ") + print("Consider:\ngit config git-p4.attemptRCSCleanup true") + break if fixed_rcs_keywords: print("Retrying the patch with RCS keywords cleaned up")