How to get mercurial to emit base revision of conflicted file as well as modified version?

前端 未结 4 1554
轮回少年
轮回少年 2021-01-13 19:58

I\'m trying to merge two branches together using mercurial and there are some conflicts. When working in Subversion, merge conflicts would result in the conflicted file bein

相关标签:
4条回答
  • 2021-01-13 20:40

    Take a look at the hg resolve command. Once a merge has started, but before it's been committed, you can use resolve to list files with conflicts, as well as mark conflicts as resolved or unresolved, or restart the merging process, all at the granularity of individual files rather than changesets.

    It doesn't give you the files you want (though see @Ry4an's answer), but it can fire up your merge tools for any particular file whenever you care to resolve it.

    0 讨论(0)
  • 2021-01-13 20:47

    You can set the HGMERGE environment variable.

    Mercurial will usually attempt to merge the files using a simple merge algorithm first, to see if they can be merged without conflicts. Only if there are conflicting changes will hg actually execute the merge program.

    You can set this to some GUI merge tool etc.

    There are other options like internal:fail, internal:local, or internal:other

    In hgrc:

    [ui]
    merge = your-merge-program
    
    [merge-tools]
    kdiff3.args = $base $local $other -o $output
    

    So you should be able to specify merge program's arguments with all your needs. Probably, you can adopt this technique for Eclipse to be fired up.

    • https://www.mercurial-scm.org/wiki/MergingManuallyInEditor

    To make merge fail immediately on conflict, try

    export HGMERGE=false
    

    In fact, if you want to know the conflict in advance, you could use the "preview" option for hg merge

    -P --preview  review revisions to merge (no merge is performed)
    
    0 讨论(0)
  • 2021-01-13 20:52

    We have a built-in merge tool for this called internal:dump. So with

    [ui]
    merge = internal:dump
    

    you will be brought back to the good old Subversion-days, or something close to it.

    0 讨论(0)
  • 2021-01-13 20:55

    How about setting a merge tool that just saves the files mercurial is creating for the merge tool to operate on?

    [ui]
    merge = copy
    
    [merge-tools]
    copy.executable = /path/to/mycopy.sh
    copy.args = $base $local $other $output
    

    And then in mycopy.sh just do something like:

    #!/bin/sh
    cp $1 $4.base
    cp $2 $4.mine
    cp $3 $4.theirs
    

    That should always succeed instantly and leave you with a .base a .mine and a .theirs for each file that conflicted. You can set that up once in your ~/.hgrc and be done with it.

    0 讨论(0)
提交回复
热议问题