r-devel / rdevguide

A guide for contributing to R core development
https://contributor.r-project.org/rdevguide/
Other
60 stars 19 forks source link

Guidance for applying patches for review and potentially handling conflicts #170

Open zkamvar opened 5 months ago

zkamvar commented 5 months ago

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.

MichaelChirico commented 5 months ago

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?

llrs commented 5 months ago

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.

aitap commented 5 months ago

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