How to create a custom pull request with Github - hg - Git - Mercurial?

I would like to contribute to an open source project on Github. Before my workflow was as follows (without using VCS):

  • I saved the "working" folder and the "clean" folder on my hard drive. I updated the reference version when the changes occurred, and continued to work on my “working” version.
  • When I wanted to make a transfer request, I compared the files in the visual comparison program and went to the Github.com/source/edit file, manually edited the different files and sent the transfer request in the web interface.

Now I wanted to streamline this workflow (avoiding Git), but I was absolutely stuck after 5 hours of trial and error. I have done the following:

  • Github won to play my own
  • Cloned the forked reproducer and edited the git+ssh:// git@github.com URL to make clicks possible. Github - hg - Git - Mercurial still works.
  • Forked editing started, as usual. Modified files, etc.
  • Now what should I do if I want to send a transfer request for some of my edited files? I tried cloning in another reprogram and only changed there, but I did not see how this could help me.

So far, the only idea I could come up with is to keep two forked registries on your hard drive, one "clean" and one "work." Then I would physically copy the files from "work" to "clean" and only create a commit in a "clean" playback from these files. But this seems to be such a “hacker” way of doing things, I'm sure there should be a clean way with bookmarks / cloned reproductions or something elegant.

Can you tell me what would be the best workflow for sending selective pull requests using Mercurial?

+4
source share
1 answer

You cannot complete a transfer request that contains only part of a set of changes. Changes are not separable in both Mercurial and Git.

You also cannot push or pull (or request attraction) a set of changes without pulling all of your ancestors, so even committing two separate times with different files each time, you won’t get what you want if you transfer material that you don’t want push / pull / send before what you do.

That's why you need to use function branches to separate your views into logically different lines of development.

If the upward repo looks like this:

 [A]---[B]---[C]---[D] 

and you clone it, so now you have this:

 [A]---[B]---[C]---[D] 

and then you create a set of changes in which there is material that you want to send as a transfer request, and some of them are not executed:

 [A]---[B]---[C]---[D]---[E] 

you were unlucky. You cannot press part E without clicking on it all. You need to separate the material that you want to insert into one set of changes (F), and the material that you do not have (yet?), Wants to click (or request to pull) into another set of changes (E):

 [A]---[B]---[C]---[D]---[E]---[F] 

You are still out of luck because you cannot press (or ask to pull F) without turning on E, since E is an ancestor of F.

Instead, you need to make your siblings E and F, and not the parent child. Like this:

 [A]---[B]---[C]---[D]---[E] \ --[F] 

Now you can press F on your fork without E and you can request that F be pulled in without them even when he saw E.

This branching command looks different: do you use Mercurial:

 hg clone THEIRS # now you have A through D ... work ... hg commit # now you created E, which you don't want to push hg update D # current directory no longer shows E ... work ... hg commit # now you have F which is a child of D and a sibling of E hg push -r . # send F (but not E) 

or git:

 git clone THEIRS # now you have A through D git checkout -b feature_e ... work ... git commit # now you have created E, which you don't want to push git checkout master # current directory no longer shows E git checkout -b feature_f ... work ... git commit # now you have created F, which you do want to share git push -u origin feature_f # send F but not E 

And now you will have a branch with only F working, not E, and you can make the pull request you want.

TL DR: By the time you have repeatedly made contributions and contributions to the same commit branch or , you were out of luck. You need to separate them or create a patch and send the patch, not a pull request.

+6
source

Source: https://habr.com/ru/post/1433857/


All Articles