How to merge to get rid of head with Mercurial command line, like I can do with TortoiseHg? -


my question this:

  • if have 2 heads (branches changes) in mercurial repository, , i'd rid of 1 of them, discard changes branch instead of merging them other, , can't strip out changesets have merge, how can command line client?

if have 2 heads in mercurial repository, , use tortoisehg client, repository might this:

two heads

then can rid of test2 head doing merge , discarding. first update head i'd keep (test3 in case, in image above current parent of working folder). right-click , select "merge with...":

merge with...

and in dialog pops choose discard changes merge target (ie. branch i'd discard changes from):

merge dialog

after merge has gone through, changes in test2 head has been discarded, , can commit. head has disappeared, changeset still part of history.

my question this: how can same thing using command line client? can't find matching options hg merge command:

 hg merge [-p] [-f] [[-r] rev]  merge working directory revision  ... snipped text  options:   -f --force       force merge outstanding changes  -t --tool value  specify merge tool  -r --rev rev     revision merge  -p --preview     review revisions merge (no merge performed)     --mq          operate on patch repository  use "hg -v merge" show global options 

edit: debugsetparents worked nicely:

 hg debugsetparents . 1 hg commit -m "merged rid of changeset #1" 

edit: attempt use --tool internal:local according 1 of answers:

@echo off  setlocal if exist repo rd /s /q repo hg init repo cd repo  rem revision 0 echo >test1.txt hg commit -m "test1" --addremove  rem revision 1 echo >test2.txt hg commit -m "test2" --addremove  rem revision 2 hg update 0 echo >test3.txt hg commit -m "test3" --addremove  rem let's rid of change in revision 1 merge hg merge --tool internal:local -r 1 hg commit -m "merged"  dir 

output of execution:

 [c:\temp] :test adding test1.txt adding test2.txt 0 files updated, 0 files merged, 1 files removed, 0 files unresolved adding test3.txt created new head 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget commit)   volume in drive c unlabeled      serial number 0e17:6aba  directory of  c:\temp\repo\*  16.11.2010  20:05             . 16.11.2010  20:05             .. 16.11.2010  20:05             .hg 16.11.2010  20:05              13  test1.txt 16.11.2010  20:05              13  test2.txt 16.11.2010  20:05              13  test3.txt                 39 bytes in 3 files , 3 dirs    12 288 bytes allocated     66 600 316 928 bytes free 

here changes introduced in 2nd changeset (the 1 revision number 1), present in merged changeset. not wanted.

according tortoisehg's source, when check discard changes merge target (other) revision, uses hg debugsetparents command:

hg debugsetparents rev1 [rev2]  manually set parents of current working directory      useful writing repository conversion tools, should used care.      returns 0 on success.  use "hg -v debugsetparents" show global options 

to use:

    hg <revision-to-keep>     hg debugsetparents <revision-to-keep> <revision-to-throw-away>     hg commit -m "merge discard ..." 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -