Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how to apply patch from mercurial to git #193

Closed
Mariatta opened this issue May 10, 2017 · 10 comments
Closed

Document how to apply patch from mercurial to git #193

Mariatta opened this issue May 10, 2017 · 10 comments

Comments

@Mariatta
Copy link
Member

How I do it:

  1. In the CPython mercurial repo, re-create the patch using --git parameter:
    hg diff --git > issueNNNN-git.patch

  2. In the CPython git repo, create and switch to a new branch. Apply the patch into CPython git repository:
    git apply /path/to/issueNNNN-git.patch

  3. Commit, push, and open the PR.

@Mariatta
Copy link
Member Author

I think this can go in committing.rst

@DimitrisJim
Copy link
Contributor

Wouldn't this be better in gitdevs.rst or gitbootcamp.rst?

@Mariatta
Copy link
Member Author

gitdevs.rst (Mercurial for git developers) might go away, as proposed in #120

About adding it to gitbootcamp.rst, it's fine by me :)

@brettcannon
Copy link
Member

Does patch -p1 < path/to/patch.diff not work?

@Mariatta
Copy link
Member Author

If it works, let's use patch -p1 < path/to/patch.diff.
I'm traveling today and on my phone right now so I can't try it myself 😝

@ezio-melotti
Copy link
Member

Several patches on the tracker have already been created with --git, so for those, the 1st step is unnecessary. git apply might also work with non---git patches, but I haven't tested.
patch is generally not available on Windows.

@terryjreedy
Copy link
Member

I believe git patches do not work with Rietveld, so people have often been asked to resubmit. In any case, the top of the file indicates format.
Program 'patch' does not come with Windows; don't know if it exists.

@Mariatta
Copy link
Member Author

Alright just got around trying out patch. It works on my Macbook.

If we want to document patch and mentioning it works for Mac & Unix only, the steps would be

  1. In the CPython git repo, create and switch to a branch
  2. patch -p1 < /path/to/issueNNNN.patch
  3. commit, push and open the PR.

@refi64
Copy link

refi64 commented May 15, 2017

FWIW there's also Mozilla's hg-patch-to-git-patch, with which the entire workflow can be shortened to:

curl patch_url | hg-patch-to-git-patch | git am

@matrixise
Copy link
Member

+1 for git apply.
in the past, I used patch with the patches from hg.python.org when I wanted to patch my working directory for a test and sometimes, I got an error.
Since I use git apply, it's really rare when I have an issue.

About hg-patch-to-git-patch maybe we could use it if we create a copy in the tools directory of CPython just for the maintenance, because if Mozilla stops the dev of this small script, we will discuss for a new tool, new way to do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants