copy a single file from one branch to another| pseudo conflict in a merge

Matt Harbison mharbison72 at gmail.com
Sun Jul 14 19:37:40 UTC 2019


On Sun, 14 Jul 2019 01:36:53 -0400, Uwe Brauer <oub at mat.ucm.es> wrote:

>
> Hi
>
> The following scenario happens once in a while. After some commits, push
> and pulls I have 3 (out of 10) modified files in my default and in my  
> feature
> branch.
>
> Now in two of them the merge is not problematic, but in file1 there is a
> conflict. This conflict however is somehow a pseudo conflict, I know for
> sure that the correct version is file1 in the feature branch.
>
> So when I merge, the merging tool (in my case meld) pops up for a three
> way merge. If I were really comfortable with that tool, I would face no
> problem, but I have to admit I am not. I have always to remember what
> presents the left and what the right side in the graphical window.
>
> So in short I would like to avoid using that tool.
>
> What are the alternatives?
>
> https://www.mercurial-scm.org/wiki/TipsAndTricks#Keep_.22My.22_or_.22Their.22_files_when_doing_a_merge
>
> Talks about a dummy merge, but this concerns all files as I understood
> which is not my case.
>
> The primitive solution I came up with was:
>
>     1. Checkout feature branch copy file1 outside the repository
>
>     2. Checkout default branch
>
>     3. Copy file
>
>     4. commit
>
>     5. Merge
>
> But this looks like stone age honestly.
>
> What would be an elegant mercurial-like solution?

Instead, you can merge like you normally do.  If you can't figure out how  
to properly reconcile a file and you know you want to sync it to some  
previously committed state, just save it in meld so that it is marked as  
resolved.  But before you commit, run this:

   hg revert -r feature_branch file1


You can specify any revision you want, and any number of files you want  
(instead of feature_branch).  That avoids steps 1-4.



More information about the Mercurial mailing list