Kdiff and hg: Unresolved conflicts after auto merge - merge

We are using Mercurial (+Tortoise Hg) as VCS and Kdiff as diff and merge tool.
Some files are merged automatically and sometimes this auto merge result is wierd:
public static Method()
<<<<<<< local
{
DoSmth();
}
=======
{
DoSmth2();
}
>>>>>>> other
Seems like kdiff has done nothing with unresolved conflict in file but marked it as resolved.
Maybe kdiff doesn't understand diff file format sometimes? Some bug in hg and kdiff integration?
Also seems that this problem appeared recently, may be the problem with a new version of hg/tortoise hg/kdiff?
We are using:
Windows 7 x64
TortoiseHg and Mercurial 3.6.1
Kdiff 0.9.98
From mercurial.ini:
[ui]
merge = kdiff3
[tortoisehg]
editor=VisualStudio
vdiff=meld
[merge-tools]
meld.executable = C:\Program Files (x86)\Meld\meld.exe
meld.priority = 1
meld.premerge = False
meld.args = $local $base $other
[diff]
git = True
Update:
Problem appears even with manual merge.
Steps:
Starting rebase
Tortoise Hg says: 'There are conflicts'
Clicking "Tool resolve", Kdiff opens
And here it is! Parent 1 (center column) contains 'dest', 'source' as a part of the file. But there were no such lines in this file.
Seems like HG gives to kdiff file with some diff info that Kdiff can't/mustn't understand.

It's a bug in Mercurial 3.6.0 and 3.6.1. It was fixed in 3.6.2.
resolve: restore .orig only after merge is fully complete (issue4952)
Quoting the original report:
Jonathan Little 2015-11-13 17:41:55 UTC
I have encountered the following problem introduced in Mercurial 3.6. I am running version 3.6+20151109 with TortoiseHG 3.6, but the problem appears to be in hg core (see my THG bug report: https://bitbucket.org/tortoisehg/thg/issues/4354) The behavior I'm seeing:
Set merge tool ([ui] merge in .hgrc/mercurial.ini) to internal:merge
Create a repository with two separate branches, with a change on each branch such that the changes conflict with each other.
Merge the two branch heads. internal:merge will leave the conflicting file with conflict markers.
Run "hg resolve --tool=kdiff3 ".
Expected result: KDiff3 correctly shows the shared ancestor content and the two conflicting revisions (see Expected.jpg).
Actual result: KDiff3 shows the shared ancestor revision and "other" conflicting revision correctly, but the local conflicting revision contains the merge markers from internal:merge (see Actual.jpg).
The problem occurs with THG's built in KDiff3 config, and with the built in KDiff3 config from mercurial/default.d/mergetools.rc. It does not occur with a barebones config consisting just of kdiff3.executable, but starts occurring when you add arguments and use $local. So it appears that the treatment of $local has changed to simply use the current local content of the file rather than the content on the merge parent from the local branch.
This behavior started with 3.6.0.

The merge result which you show looks very much like the result of another merge tool, namely internal:merge
As you can configure different merge tools for different filetypes or files - or explicitly give the merge tool for a certain merge - are you sure that you didn't use another merge tool than kdiff? Possibly a new tortoiseHG version (re-)defined some merge tool settings.
Verify the configuration of your merge tool in your configuration file. See https://www.mercurial-scm.org/wiki/KDiff3 for how it should look for kdiff3. Quote for convenience:
[extensions]
hgext.extdiff =
[extdiff]
cmd.kdiff3 =
[merge-tools]
kdiff3.args = $base $local $other -o $output

We are using Mercurial (+Tortoise Hg) as VCS and Kdiff as diff and merge tool.
Show it! I want to see screenshot of THG's Global Setting - TortoiseHG tab (or repository-specific settings of THG), or relevant part of ini-file (better, shorter). Here is part of my mercurial.ini with p4merge as global diff-merge tool
[ui]
merge = p4merge
...
[tortoisehg]
vdiff = p4merge
Some files are merged automatically and sometimes this auto merge result is wierd
<<<<<<< and >>>>>>> strings are signs for another merger: internal:merge3 with conflict markers
This is not generally recommended as Mercurial gets no direct feedback when merges are successfully completed, and it's not terribly user-friendly compared to modern tools.
You must configure selected tool properly: KDiff3 is GUI-tool, which will appear on screen every-time when merge can't be performed automatically (have conflicts) and it's your duty - perform hand-work of editing result in KDiff window

Related

Merge info not getting recorded in mergeinfo property

I have merge code from a branch to trunk using SVN merge tool (not the svn merge command but using UI). I use TortoiseSVN.
When I run following command svn propget svn:mergeinfo <<URL_to_trunk>> then I cannot see the merge information getting recorded in mergeinfo property.
Even if I use this command with branch URL then as well I cannot see the recorded merge info.
I read following line in SNV book.
The svn:mergeinfo property is automatically maintained by Subversion
whenever you run svn merge.
Does this mean that mergeinfo property would be updated only when merge is done using svn merge command from command line and not merge using UI?
If not then why I cannot see merge info using svn propget svn:mergeinfo <<URL_to_trunk>>?
To add to the previous answer, tortoise will also not record merge info if the "ignore ancestry" is checked
The svn:mergeinfo property should be correctly added to merged files even when using Tortoisesvn.
You should run the "svn propget" command on merged files in your working copy, to see the svn:mergeinfo property.

How to minimize conflicts in merging with the CVS Eclipse plugin

I am trying to execute the above merge scenario using Eclipse and the CVS plugin. It works a lot like this Eclipse branching article.
The problem I am encountering is what I consider "incorrect conflicts".
Shouldn't M2 be free of conflicts?
At the point after the commit tagged PM1, the two branches are the same. Some work is done on HEAD (as WD2) and committed to HEAD. A tag W2 is created. Now I want those changes in p1test.
The branch in the Eclipse project is set to p1test and a merge is done by selecting HEAD as the "Branch or version to be merged (end tag)", and W1 as "Common base version (start tag)". Since there have been no changes in p1test, I would have expected no conflicts in M2. But that's not what I see. The WD2 work shows as conflicts. That doesn't seem right since those files haven't been touched in the p1test branch.
Am I doing this right?
I guess you did it right as your diagram comes from the original documentation.
Do you use CVS keywords ($Revision$, $Author$, $Date$, ...) in your text files ? Do conflicts concern lines with such keywords ?
I suggest you to test the merge operation with CVS command line itself:
Do a fresh checkout of p1test branch
Invoke cvs update -kk -j W1 -j W2
You should have no conflict and be able to commit the resulting merge on p1test branch
The -kk option is required to avoid conflicts on keywords.

What is the best way to merge specific changes in several branches and trunk?

I used SVN/CVS for a long time just as a place where my code stored is. But now I came to a point where I need a "best way to do".
We have several branches.
For Example:
Release1 (shipped),
Release2 (not finished, contains new features),
Fix1 (contains bug fixes for Release1 and will be shipped after customer tests),
Fix2/trunk (The trunk is our current development state with Fix2).
And now we come to my problem.
I cannot say if Release 2 is shipped before Fix1 or Fix2 and I have now a Hotfix for Release1. Just a few files, but it was urgent.
What is now the best way to get the changes in all branches?
Auto merge will also merge differences that are branch specific. Is the best way to merge it by hand?
There has to be a way like: I mark my change with ID "abc" and say merge only changes of abc in all branches.
Btw. I am using Eclipse with Subversive. Maybe a tool outside eclipse will be better!?
I use Subclipse plugin for Eclipse. You can probably do this with svn command line also. If your fix is isolated to a single revision number then you can merge just that revision to the trunk(or any other branch).
branch1 (revision 103) -hotfix
trunk (revision 100)
Using Subclipse, you can right click the file then choose "Team"->"Merge." Select either "Merge a range of revision" or "Merge two different trees" option then provide the source url and revision to merge to the target tree.
From command line... given that your current working directory is the trunk:
svn merge -r 103:103 http://svn/branches/branch1
You probably can't merge to multiple branches and that's probably better because you want to be careful with the merge process.

How can I do a partial update (i.e., get isolated changesets) from subversion with subclipse?

If a file is committed several times with various changes, how can I fetch one change at a time, i.e., one changeset at a time?
I use eclipse, subversion, and subclipse, and I can't change the former two for the time being (or the MS platform..).
In my Team/Synchronization view in eclipse (using subclipse), choosing the changeset model, a file seems to be listed only in the latest relevant changeset even if all changesets are listed. So an earlier changeset doesn't necessarily show the full set of files in the original commit, nor the original diff for a file in a commit.
Update: I'm thinking about using changesets for simplified code review, so I'd like the partial update represented for all the files commited in one changeset. It's easy to get diffs and specific revisions for specific files in eclipse, but I'd like to step through all the changes in one specific commit/ changeset in a practical manner.
As I'm sure you know, svn up will by default grab the latest revision of the file.
However, you can use the -r parameter to svn up to grab a particular revision of a file. So if you know a file was committed in revisions 5, 7, and 9, you could do this:
svn up -r5 myfile
svn up -r7 myfile
svn up -r9 myfile
I believe (but I don't have an installation of it in front of me) that Subclipse has a similar option, labeled something like "Update to Revision..."
Subversion does not support atomic changesets.
(Note: If anyone can prove me wrong, I'll happily switch accepted answer.)
I've compared Git and Subversion using TortoiseGit and TortoiseSVN (and looked at what is possible on the command line).
With both Svn and Git I can update to a certain revision, or see and update to different versions of only one file at a time.
With both Tortoise clients can I see individual commits (revisions) from the repository and look at changes between a revision and the previous revision. (Note that I can't seem to do this in Eclipse, ref the question.)
Only with Git, however, can I update to or cherry-pick an isolated commit. The closest I've seen to this functionality in Subversion is to update to head and then revert a certain revision with a "subtractive merge"...
Test setup: make a project, check out or clone the project, make 2 separate commits to repository from elsewhere, including at least one file that is modified in both commits.
Then, with Git: fetch remote changes.
Then, with both Git and Subversion: look at the log.

Subversion and Eclipse - branching, and merging with the trunk

I use v 3.4.2 of Eclipse and Subversion (using svn 1.4.6 on the server), and I'm having problems understanding the specific options (Depth, Ignore ancestry, etc) and how to merge changes from the trunk into the branch, and back again.
Also, when conflicting changes are present, Subversion seems to break - in the compare editor for the conflicting file, my Local File contains SVN text (e.g. <<<<<<< .working) which obviously don't appear in the actual working copy file. If I go back to my Resource view, I see a whole bunch of SVN temporary files. Is this a bug somewhere, or am I doing something wrong?
The "breakage" as you describe it is the standard way that subversion works - when the merge results in line conflicts, SVN keeps both sides of the conflicts and puts them in the source file for you to review. You have to edit your conflicted file, examine your version of the conflict vs. the repository's version and edit it so that only one set remains (remove the <<<< line, the >>>> line, the ===== line and all the conflicting code lines that you don't want to have). After that right click your source file and choose "mark as merged". following that you can commit your merged file. This is called manual merging and you must complete that when there are conflicts.
The bunch of temporary files are the original source files from either side and they should help you to resolve the conflict - you should have a file ending with ".mine" which is your original clean version of the source file and a file ending with ".rXXXXX" (where XXXX is a subversion revision number) which is the repository's original clean version of the source file. When you "mark as merged" these files will be gone.
Eclipse has a nice graphics tool that you can use to resolve the conflict using a compare style editor, but it has some quirks and it takes some practice and understanding of the tool in order to use it effectively. If you want to try it is available under the file's RMB menu->Team->Edit Conflicts.
I think you'll probably find that those lines such as <<<<< .working do appear in your actual working copy file. This is how Subversion lets you know which parts of your text need to be manually edited because of a merge conflict.
You can read more about merge workflow in the Resolve Conflicts section of the excellent Version Control with Subversion book.