rdevguide icon indicating copy to clipboard operation
rdevguide copied to clipboard

Guidance for applying patches for review and potentially handling conflicts

Open zkamvar opened this issue 1 year ago • 3 comments

I'm interested in helping to confirm the patches proposed in https://github.com/r-devel/bug-bbq/issues/2, but at the moment, I cannot find instructions for applying a patch.

An example I can find is from the patches proposed in https://bugs.r-project.org/show_bug.cgi?id=18145 and https://bugs.r-project.org/show_bug.cgi?id=17918, which both touch the same function, but are yet unconfirmed. These patches are both over 2 years old and it's not clear whether or not they can be neatly applied.

zkamvar avatar Apr 11 '24 17:04 zkamvar

Ideally it's as simple as running svn patch, e.g. for #18145

svn patch ~/Downloads/fix_s3method_detection_debugcall.diff

But unfortunately it cannot be neatly applied :upside_down_face:

C         src/library/utils/R/debugcall.R
>         rejected hunk @@ -31,13 +31,27 @@
C         tests/reg-tests-1d.R
>         rejected hunk @@ -5998,7 +5998,23 @@
Summary of conflicts:
  Text conflicts: 2

I am unclear myself how to proceed in this case since it didn't leave any conflict markers. It looks like we'll have to generate the patch from scratch based on the current trunk?

MichaelChirico avatar Apr 12 '24 01:04 MichaelChirico

Here are the instructions about applying a patch: https://contributor.r-project.org/rdevguide/FixBug.html It might be a good moment to check how to update the patch, and update the documentation accordingly.

llrs avatar Apr 12 '24 09:04 llrs

svn help patch recommends updating to the revision the patch had been generated from before applying a patch and then updating back to HEAD (which will uncover the conflicts and prompt for resolution). So in order to "rebase" a patch, it will be needed to:

  1. Start with a clean checkout of R
  2. svn up -r $N where $N is the source revision
  3. svn apply "$patch", which should apply cleanly
  4. svn up HEAD, which will interactively ask about each conflict. If interrupted, conflict resolution can be continued again by running svn resolve.
  5. svn diff to obtain the newly conflict-free patch

People who prefer Git can also start with a Git mirror, find out the commit $start corresponding to the source revision of the patch and then run:

  1. git checkout -b updated_patch $start
  2. patch -p0 <"$patch" or apply the patch in a different way
  3. git commit -a -m "Patch from R Bugzilla PRNNNNN"
  4. git rebase master
  5. Resolve conflicts
  6. git diff master...updated_patch to obtain the now conflict-free patch
  7. Adjust or regenerate patch for Subversion compatibility

aitap avatar Apr 14 '24 05:04 aitap