All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Ben Keene via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Ben Keene <seraphire@gmail.com>
Subject: Re: [PATCH 2/3] git-p4: [usability] RCS Keyword failure should suggest help
Date: Mon, 09 Dec 2019 14:22:44 -0800	[thread overview]
Message-ID: <xmqqa781t9zf.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <d608f529a0e01e99c97e895ab483000da068a7ac.1575901009.git.gitgitgadget@gmail.com> (Ben Keene via GitGitGadget's message of "Mon, 09 Dec 2019 14:16:48 +0000")

"Ben Keene via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Ben Keene <seraphire@gmail.com>
>
> 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

s/becasue/because/

> git-p4.attemptRCSCleanup to true.

The above explains the new "else:" clause really well.  The
original's logic was to

 - tryPatchCmd to apply a commit, which might fail,
 - when the above fails, only if attemptrcscleanup is set, munge
   the lines with rcs keywords and rerun tryPatchCmd

but your new "else:" gives a suggestion to use the (experimental?)
attemptRCSCleanup feature.

However, it does not explain the change to the "if :" clause.  I can
see that patchRCSKeywords() method does want to raise an exception,
and it is a good idea to prepare for the case and clean up the mess
it may create.  At least that deserves a mention in the proposed log
message---I actually think that the new try/except is an equally
important improvement that deserves to be a separate patch.

> Signed-off-by: Ben Keene <seraphire@gmail.com>
> ---
>  git-p4.py | 19 +++++++++++++++++--
>  1 file changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/git-p4.py b/git-p4.py
> index 0fa562fac9..856fe82079 100755
> --- a/git-p4.py
> +++ b/git-p4.py
> @@ -1950,8 +1950,23 @@ 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
> +            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) != 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")

  reply	other threads:[~2019-12-09 22:22 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-09 14:16 [PATCH 0/3] git-p4: Usability enhancements Ben Keene via GitGitGadget
2019-12-09 14:16 ` [PATCH 1/3] git-p4: [usability] yes/no prompts should sanitize user text Ben Keene via GitGitGadget
2019-12-09 22:00   ` Junio C Hamano
2019-12-10 14:26     ` Ben Keene
2019-12-09 14:16 ` [PATCH 2/3] git-p4: [usability] RCS Keyword failure should suggest help Ben Keene via GitGitGadget
2019-12-09 22:22   ` Junio C Hamano [this message]
2019-12-09 14:16 ` [PATCH 3/3] git-p4: [usability] Show detailed help when parsing options fail Ben Keene via GitGitGadget
2019-12-09 22:24   ` Junio C Hamano
2019-12-09 22:06 ` [PATCH 0/3] git-p4: Usability enhancements Junio C Hamano
2019-12-10 15:22 ` [PATCH v2 0/4] " Ben Keene via GitGitGadget
2019-12-10 15:22   ` [PATCH v2 1/4] git-p4: yes/no prompts should sanitize user text Ben Keene via GitGitGadget
2019-12-11 11:52     ` Denton Liu
2019-12-11 11:59     ` Denton Liu
2019-12-10 15:22   ` [PATCH v2 2/4] git-p4: show detailed help when parsing options fail Ben Keene via GitGitGadget
2019-12-10 15:22   ` [PATCH v2 3/4] git-p4: wrap patchRCSKeywords test to revert changes on failure Ben Keene via GitGitGadget
2019-12-10 15:22   ` [PATCH v2 4/4] git-p4: failure because of RCS keywords should show help Ben Keene via GitGitGadget
2019-12-11 11:29     ` Denton Liu
2019-12-11  9:43   ` [PATCH v2 0/4] git-p4: Usability enhancements Luke Diamand
2019-12-12 19:46   ` [PATCH v3 " Ben Keene via GitGitGadget
2019-12-12 19:46     ` [PATCH v3 1/4] git-p4: yes/no prompts should sanitize user text Ben Keene via GitGitGadget
2019-12-13  1:45       ` Denton Liu
2019-12-13 13:42         ` Ben Keene
2019-12-13 19:46         ` Junio C Hamano
2019-12-15 20:30           ` Johannes Schindelin
2019-12-16 17:54             ` Junio C Hamano
2019-12-16 19:11             ` Ben Keene
2019-12-12 19:46     ` [PATCH v3 2/4] git-p4: show detailed help when parsing options fail Ben Keene via GitGitGadget
2019-12-12 19:46     ` [PATCH v3 3/4] git-p4: wrap patchRCSKeywords test to revert changes on failure Ben Keene via GitGitGadget
2019-12-12 19:46     ` [PATCH v3 4/4] git-p4: failure because of RCS keywords should show help Ben Keene via GitGitGadget
2019-12-13 13:57     ` [PATCH v4 0/4] git-p4: Usability enhancements Ben Keene via GitGitGadget
2019-12-13 13:57       ` [PATCH v4 1/4] git-p4: yes/no prompts should sanitize user text Ben Keene via GitGitGadget
2019-12-13 22:54         ` Denton Liu
2019-12-16 13:53           ` Ben Keene
2019-12-13 13:57       ` [PATCH v4 2/4] git-p4: show detailed help when parsing options fail Ben Keene via GitGitGadget
2019-12-13 13:58       ` [PATCH v4 3/4] git-p4: wrap patchRCSKeywords test to revert changes on failure Ben Keene via GitGitGadget
2019-12-13 13:58       ` [PATCH v4 4/4] git-p4: failure because of RCS keywords should show help Ben Keene via GitGitGadget
2019-12-16 14:02       ` [PATCH v5 0/4] git-p4: Usability enhancements Ben Keene via GitGitGadget
2019-12-16 14:02         ` [PATCH v5 1/4] git-p4: yes/no prompts should sanitize user text Ben Keene via GitGitGadget
2019-12-16 14:02         ` [PATCH v5 2/4] git-p4: show detailed help when parsing options fail Ben Keene via GitGitGadget
2019-12-16 14:02         ` [PATCH v5 3/4] git-p4: wrap patchRCSKeywords test to revert changes on failure Ben Keene via GitGitGadget
2019-12-16 14:02         ` [PATCH v5 4/4] git-p4: failure because of RCS keywords should show help Ben Keene via GitGitGadget
2019-12-16 20:39         ` [PATCH v5 0/4] git-p4: Usability enhancements Junio C Hamano
2019-12-21 10:19           ` Luke Diamand
2019-12-25 19:13             ` Junio C Hamano
2020-01-02 13:50               ` Ben Keene
2020-01-02 21:44                 ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqa781t9zf.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=seraphire@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.