merged two branches, and pushed, how to backout/strip?

Uwe Brauer oub at mat.ucm.es
Mon Jan 9 20:07:49 UTC 2017


   > Uwe Brauer <oub at mat.ucm.es> writes:

   > If the code being in the open is no problem, you can always revert
   > default to the commit before the merge, then commit, then merge default
   > into vs-11.89, revert vs-11.89 to the other commit before the merge and
   > commit again.

   > hg revert --all -r 138:7e1a64287b87
   > hg commit -m "backout bad merge"
   > hg up vs-11.89
   > hg merge default
   > hg ci -m "merge default with the backout"
   > hg revert --all -r 142:1dd731cf6a6a
   > hg ci -m "backout the backout"

   > Now from the view of hg, everything should work the same way as before
   > (including later merges into default and later merges of default into
   > vs-11.89).

Thanks very much but I am a bit confused.

Let me consider the following example


hg init
echo Main1 > main.txt
hg add main.txt
hg commit -m "Main1"
echo Main2 >> main.txt
hg commit -m "Main1"
hg branch vs-11.89
echo branch1 > main.txt
hg commit -m "Good Commit1"
echo branch2 >> main.txt
hg commit -m "Good Commit2"
echo badvariable >> main.txt
hg commit -m "Bad Commit"
# back to the default branch
hg up default
hg merge vs-11.89
hg commit -m "Bad merge"
# bad commit
hg push
# the mess is done

The graph looks like this.
@    changeset:   5:f13b8087f976
|\   tag:         tip
| |  parent:      1:3eafdb4fb59d
| |  parent:      4:03a9b146f1b0
| |  user:        Uwe Brauer <oub at mat.ucm.es>
| |  date:        Mon Jan 09 19:55:34 2017 +0000
| |  summary:     Bad Merge
| |
| o  changeset:   4:03a9b146f1b0
| |  branch:      vs-11.89
| |  user:        Uwe Brauer <oub at mat.ucm.es>
| |  date:        Mon Jan 09 19:52:19 2017 +0000
| |  summary:     Bad Commit
| |
| o  changeset:   3:bf8a52c245fa
| |  branch:      vs-11.89
| |  user:        Uwe Brauer <oub at mat.ucm.es>
| |  date:        Mon Jan 09 19:52:18 2017 +0000
| |  summary:     Good Commit2
| |
| o  changeset:   2:9102638dffb5
|/   branch:      vs-11.89
|    user:        Uwe Brauer <oub at mat.ucm.es>
|    date:        Mon Jan 09 19:52:18 2017 +0000
|    summary:     Good Commit1
|
o  changeset:   1:3eafdb4fb59d
:
if that were a private repo I would run

 hg strip -r 5

And the content of main would be 

Main1
Main2

Because after the strip I end up in the default branch.

Now suppose the repo is public, and I would follow your advice, first
let me pull the last strip

Then it seems to me that your advice would be translated to

# revert to last good commit in default
hg revert --all -r 1
hg commit -m "backout bad merge"
# go to branch
hg up vs-11.89
hg merge default
hg ci -m "merge default with the backout"
hg log -G
# revert the last bad commit to branch vs-11.89
hg revert --all -r 4
hg ci -m "backout the backout"


The graph looks like
@    changeset:   7:dfca195276fa
|\   branch:      vs-11.89
| |  tag:         tip
| |  parent:      4:03a9b146f1b0
| |  parent:      6:57fc9a2567fa
| |  user:        Uwe Brauer <oub at mat.ucm.es>
| |  date:        Mon Jan 09 20:01:28 2017 +0000
| |  summary:     merge default with the backout
| |
| o  changeset:   6:57fc9a2567fa
| |  user:        Uwe Brauer <oub at mat.ucm.es>
| |  date:        Mon Jan 09 20:01:27 2017 +0000
| |  summary:     backout bad merge
| |
| o  changeset:   5:f13b8087f976
|/|  parent:      1:3eafdb4fb59d
| |  parent:      4:03a9b146f1b0
| |  user:        Uwe Brauer <oub at mat.ucm.es>
| |  date:        Mon Jan 09 19:55:34 2017 +0000
| |  summary:     Bad Merge
| |


That is correct? However I end up in  the vs-11.89 branch.

I don't really understand
hg up vs-11.89
hg merge default
hg ci -m "merge default with the backout"
hg log -G
# revert the last bad commit to branch vs-11.89
hg revert --all -r 4
hg ci -m "backout the backout"

Why are the merge and revert necessary?

Thanks

Uwe 




More information about the Mercurial mailing list