What to do, not dispense commits in Mercurial

I have an IDE set for local save on every save. Ideally, I would like to keep an uncensored report on my idiotic mistakes in rare cases when they can be useful. But most of the time he makes my historical way detailed.

I would like to know a good strategy to preserve this story, but be able to ignore it most of the time. My IDE runs my own script every time I save, so I have control over this.

I'm new to Mercurial, so the main answer may be all I need here. But what are all the steps that I have to follow when committing, merging, and reporting so that I can basically ignore these automatic commits, but without actually crushing them? Or should I give up and just crush it?

A related question is how high-rated squash suggests it’s better to keep this story

Edit - My point is that if Mercurial wants to keep your whole story (which I agree with), it should allow you to filter this story so that you don’t see things that you might have in order to seduce squash. I would rather not squash, I just ask for help in the strategy (with regular use, although not always), so that it looks as big as possible, as if I crushed my story.

+4
source share
4 answers

You want to keep a detailed history of your repo, but want to have (and be able to export) an idealized story that contains only ā€œreasonableā€ versions, right? I can empathize.

Solution 1: Use tags to mark interesting moments in the story, and learn to ignore all the messy bits between them.

Solution 2: Use two branches and merge. Make your development in the default branch and save the parallel release branch. (You can call it clean , but in fact you control releases). Whenever default is in a stable state that you want to check, switch to the release branch and merge the current default state into it - in batches, if you want. If you never associate anything with release , there will never be a merge conflict conflict.

  (original branch) --o--o--o--o--o--o--o (default) \ \ \ r ... ... --r--------r (release) 

Result: you can upgrade to any version of release and expect a healthy state. You can run hg log -r release and you will see only the selected breakpoints. You can view the full magazine to find out how it all happened. Disadvantages: since the release branch depends on default , you cannot drag it to another repo without bringing default with you. Also hg glog -r release will look weird due to repeated merges.

Solution 3: Use the named branches as above, but use the rebase extension instead of merging. He has the ability to copy, and not just drag and drop changed changes; and it has the --collapse option, which converts a set of changes into one. Whenever you have a set of r1:tip revisions that you want to complete, copy them from default to release as follows:

 hg rebase --source r1 --dest release --keep --collapse 

This pushes one revision at the beginning of release , which is equivalent to the whole set of changes from r1 to the default chapter. The --keep option makes it a copy, not a destructive rewrite. The advantage is that the release branch looks the way you wanted it: nice and clean, and you can click it without dragging the default branch with it. The downside is that you cannot associate your steps with changes to default , so I would recommend method 2 if you really don't need to hide the intermediate versions. (Also: it’s not so easy to deflate history in several batches, since rebase will move / copy all descendants of the ā€œoriginalā€ version.)

All this requires additional work from you. This is inevitable, since mercurial has no way of knowing which reversals you would like to deflate.

+4
source

it should allow you to filter this story so that you don’t see things that you might have, to filter through

Mercurial has tools for this. If you just don't want to see (in hg log , I suppose) - filter these revisions with revsets:

 hg log -r "not desc('autosave')" 

Or, if you use TortoiseHg, just go to View → Filter Toolbar and type "not desc (" autosave ") on the toolbar. Voila, your autosave entries are hidden from the main list.

+3
source

If you really want to save all the tiny changes from each Ctrl-S in the repo history and only log show a subset of important ones, you can always tag ā€œimportantā€ changes, and then the log alias is log -r tagged() . Or you can use the same principle with a different clipping descriptor , for example, include the text "autosave" in messages with an automatic message and use log -r keyword(autosave) , which will show you all non-auto commits.


To achieve my goal, at least by approaching it, I would use the mq extension and automatically commit the update queue repository for each save. Then, when you finish your ā€œidiotic inconvenienceā€, you can hg qfinish patch as one set of changes that you can click. You should (as always!) Save the changes centered around one concept or step (for example, ā€œfixing the save buttonā€), but this will fix all the small steps that need to be taken so that you can go there.

You need

  • hg qinit --mq once to initialize the patch queue repository (fyi: saved in \.hg\patches\ )
  • hg qnew fixing-the-save-btn creates a patch

then every time you save an IDE in your environment

  • hg qrefresh to update the patch
  • hg commit --mq to make a small set of changes to the update queue repository

and when you finish

  • hg qfinish fixing-the-save-btn converts a patch into a mutable change set

This prevents your interference locally for your repo according to what was changed each time it was saved, but only pushes the set of changes when it is complete. You can also qpop or qpush change the item you were working on.

If you try to use the squash method, you will lose the history of the ravine when you reset shifts. Either this, or you are stuck trying to transfer work to / from the "real" repository, which, I can tell you from experience, you do not want to do. :)

+2
source

I suggest you use branches. When you start a new function, you create a new branch. You can perform as many and often as you want in this thread. When you are done, you will merge the function branch into your trunk. Thus, you basically divide the story into two categories: one in the fine-grained (history in the branches of the traits), and the other in the large grain (history in the trunk). You can easily view any of them using the command: hg log --branch <branch-name> .

+1
source

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


All Articles