How to push a bunch of changes like one in mercury

As I understand it, one of the main advantages of a distributed version control system such as Mercurial is that you don’t have to worry about breaking something in your super-important main repo (which is used by quite a few other developers) and doing whatever you work and research in your personal remote clone until you understand that everything is stable and you can push your work away. And so I had a question: if you can’t discard not the whole history of changes (with a few changes that you made for yourself), but only the one that actually differs between your repo and the current state of the wizard.

One example:

hg init master-repo; cd master-repo echo -e 'Important file\nWith Bug!' > file hg commit -A -m "initial commit" cd ..; hg clone master-repo hotfix-repo; cd hotfix-repo echo "fix1" >> file hg commit -m "first attempt to fix bug" echo "fix2" >> file hg commit -m 'Fixed it!' 

Now (possibly after dragging and merging with the new master-repo changes) I want to discard only one set of changes containing all the changes that I made without my local commit history. One possible solution is to create another clone, and then use diff / patch between the two clones to extract / apply the changes from the first and simultaneously execute them in the second repo. Then push as usual. But is it possible to use only mercury commands?

Thanks in advance!

+6
source share
2 answers

Opinions differ on whether or not it is good to collapse a set of trial and error changes into one set of changes before clicking:

  • Pros: you avoid making changes to your history when your test suite fails - these changes are not suitable for hg bisect and add noise.

  • Con: you cannot roll back the changes that you posted to other repositories - this will overwrite your local change sets, and you will have to manually clear the other repositories. p>

Technically, it is completely safe to collapse a set of changesets into one set of changes before clicking. You start with

 ... a --- b --- c --- x --- y --- z 

and you rewrite this in

 ... a --- b --- c --- w 

where w has exactly the same repository state as z (but, of course, a different parent set of changes). There are no mergers (and therefore merge conflicts), so it cannot fail.

After dubbing, you can stretch and merge with the upstream ( d and e ):

 ... a --- b --- c --- w --- v \ / d ----- e 

You need an extension to overwrite history. Here I would suggest one of:

  • Collapse extension : as the name suggests, this extension is intended to discard sets of changes.

  • Histedit extension : full-featured history editing, but the fold command allows you to collapse a set of changes.

  • Extend extension : this standard extension can move changes and collapse them at the same time. In the above example, it moves x --- y --- z after e :

     ... a --- b --- c --- d --- e --- x' --- y' --- z' 

    Then you can collapse x' to z' if necessary:

     ... a --- b --- c --- d --- e --- w' 

    Compared to simply dropping x to z , rebasing does include merges so that it can fail.

+5
source

Introduction

I think rewriting a story and sending / receiving “polished” sets of changes (in the Git-boys style) is usually a bad idea - history is history, it has its own meaning.

In the end, for the "mainline" branch (you use branches , right), all your changes will be presented as a single merge , regardless of the number of change counters in the branch

Short answer

Not. In Mercurial, you push / click and receive and accept the full set of changesets, which made a difference in repo history

Long answer

Somehow you can by reinstalling your change history before exchanging for the "other side". Just remember: each set of changes does not represent the new state of the object, but the diff between the old and the current (briefly describe it), thus, by the usual removal of changes, you can get the wrong final result.

In any case, you have many ways to rewrite your own story (as extensions):

  • Collapse
  • Change history
  • MQ (with mq patches per se, bending change sets in mq-patch and splitting the same path)
  • Perhaps some others unknown to me
+3
source

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


All Articles