I am currently using the commmand hg diffmerge -r 32 -r 30 myfile, but this only displays two windows, not three. How can I make it do a three way merge?
.hgrc
[ui]
merge=diffmerge
[extensions]
collapse=~/.hgext/collapse.py
hgext.purge=
hgext.extdiff=
hgext.graphlog=
[extdiff]
cmd.diffmerge=/usr/bin/diffmerge
[merge-tools]
diffmerge.executable=/usr/bin/diffmerge
diffmerge.args= --result=$output -t1="Local Version" -t2=$output -t3="Other Version" --caption=$output $local $base $other
diffmerge.binary=False
diffmerge.symlinks=False
diffmerge.gui=True
diffmerge.premerge=True
I suppose you mean you're using SourceGear DiffMerge as external merge tool. What's your .hgrc? Is it based on the sample from hg website?
My guess is that your diffmerge.args is problematic. You can try running diffmerge manually with those arguments to make sure it works.
With your .hgrc it's clear now. Your command hg diffmerge -r 32 -r 30 myfile is NOT a merge command, instead you're asking hg to use diffmerge as the external diff tool (specified in [extdiff] section) to compare myfile between version 32 and 30. There's not a 3rd version involved.
For merge you run hg merge [-r<the other head>], and since your .hgrc tells hg to use diffmerge as merge tool (specified in [ui] section) hg will use diffmerge for the 3-way merge. I verified that it works in my Windows setup with identical hgrc.
Related
I have a mercurial repo with subrepos (also mercurial). Imagine the situation where I have changed the subrepos and the main repo. Now I want to see the changes between several commits including the changes in the subrepos.
Is it possible?
I use TortoiseHG and diffmerge. In diffmerege calling for visual diff from TortoiseHg, I can't see the changes in the subrepos between several commits.
In the command line you can do the following. Let us say you want to see all the changes of a subrepo named example between the changesets (in the main repo) c608f6017bd7 and 72d284a44170.
In the main repo
hg diff -rc608f6017bd7:72d284a44170 .hgsubstate | grep example
will return the changesets of the subrepo example, something like:
-001fc0acef220bcd42898ef3932dee8330ea64c0 example
+77f9db4d51c4b483607178aba91c872b0adedf1e example
Now you can see the logs and the diffs of the subrepo changes with:
cd example
hg log -r001fc0acef220bcd42898ef3932dee8330ea64c0:77f9db4d51c4b483607178aba91c872b0adedf1e
hg diff -r001fc0acef220bcd42898ef3932dee8330ea64c0:77f9db4d51c4b483607178aba91c872b0adedf1e
If you need it often, you can create a bash script named sublog like:
#!/bin/bash
r=$(hg diff -r$1:$2 .hgsubstate | grep $3 | cut -c 2-41 | tr '\n' ':' | sed 's/:$//'; echo '')
cd $3
hg log -r:$r
and use it like:
sublog c608f6017bd7 72d284a44170 example
I can only tell you how to achieve it on the command line - but that is readily available with tortoiseHG, too:
Most commands can be made aware of subrepositories by using the -S or --subrepos flag. As such, in order to see the diff between two changesets X and Y, including those on all subrepositories, do at the main repository:
hg diff -S -rX:Y
Mind, of course, that it will not show a diff in the subrepositories if there was no change of the sub-repository version(s) committed to the main one.
With the versions of TortoiseHg I've used (which doesn't include the last few releases), I haven't seen a way of doing what you're asking about. There are a few options though:
you can type commands directly in the output log window in TortoiseHg, so you can do hg diff -S -rX:Y there.
Archive the versions of the parent repo which you want to diff to some directories (hg archive --repository <path-to-repo> -r <rev> -S -t files -- <outputfolderpath>, or in TortoiseHg, right-click the changeset, select Export -> Archive). Then use diffmerge on the archive directories. This is a bit tedious (especially if you want to diff many changesets), but you will get a "deep" visual diff.
Having read Completely manual Mercurial merge, I have such a .hgrc:
[ui]
merge = meld
[merge-tools]
meld.priority = 1
meld.premerge = False
meld.args = $local $other $base
[merge-patterns]
** = meld
However, hg merge -r REV just works and I don't get what i'm missing...
I'd like to do a manual merge to drop some of the changes the other branch introduces. The other branch has a changeset affecting several files and I don't want to modify them all.
I've got two guesses. Either your configuration settings aren't getting picked up or you don't have enough conflict for Mercurial to consider your merge in need of resolution.
You can check for the former with hg showconfig -- make sure you see your meld settings.
If they are showing up then maybe there isn't enough conflict between the two changesets you're merging. Even with premerge set to false there still needs to be something that requires merging. Are there actual changes in the same file in both changesets? Perhaps try hg merge --tool internal:fail and then check the hg resolve --list to see what's there.
I' m following your instruction to use MELD when doing a diff. I get this:
hg meld file.F
usage:
meld Start with no windows open
meld <dir> Start with VC browser in 'dir'
meld <file> Start with VC diff of 'file'
meld <file> <file> [file] Start with 2 or 3 way file comparison
meld <dir> <dir> [dir] Start with 2 or 3 way directory comparison
meld: error: no such option: -a
where does this -a option come from?
I've looked for that in the manual, but I can't generate a patch for the last commit.
I tried
hg qnew patch_name
but it does only file with
# HG changeset patch
# Parent a6a8e225d16ff5970a8926ee8d24272a1c099f9c
I also tried
hg export tip
but it doesn't do anything. I committed the changes exactly.
How to generate a patch file with the last commit in?
The command to do this is export:
$ hg export -o FILE -r REV
It doesn't require redirection and will thus work correctly on any platform/shell.
Your hg export tip is the best way to do it, and the hg diff and hg log based answers are just lesser versions of the same. What exactly do you see/get when you type hg export tip? What does the output of hg log -p -r tip show?
The changeset tip is just means "the changeset that most recently arrived in my repository" which isn't as useful a concept as you might think, since hg pull and hg tag all create changesets too. If you really want the last thing you committed you'll need a more precise revspec.
Like so:
hg diff -r tip > tip.patch
You can use this command:
hg log -r tip -p > tip.patch
this will generate a patch for just that revision.
If you want to convert the latest commit to a patch file, use
hg qimport -r tip
This will replace the topmost regular commit with an applied MQ patch file.
To generate patches using "mq extensions" in mercurial, you can follow the below given steps. This will create a patch using mercurial:
1) Enabling mq extensions: Add the following lines to your hgrc file and save it.
[extensions]
mq =
2) Creating a patch using mq extensions: To create a patch using mq extensions you can do the following.
hg qnew -e -m "comment you want to enter" bug_name.patch
In the above command, -e flag is for editing the patch and -m flag is for adding a message to the patch.
3) Updating the patch: For updating the patch, you can use the following command when a patch is already applied.
hg qrefresh
It looks like hg out --patch or hg out -p is a good way to see what code is pushed out to the repo (when it is pushed)... but the diff is in text format. Is there a way to make it use kdiff3 as well?
hg outgoing --patch shows the changes in each changeset separately, which probably isn't what you want if you're looking for a visual representation. You more likely want the GUI equivalent of hg diff -r your_latest_changeset -r remote_servers_latest_changeset where the latest changesets are the respective tip revisions if you're not using named branches. You can get that in your favorite GUI using the extdiff extension yielding a final command like:
hg extdiff -p kdiff3 -r your_latest_changeset -r remote_servers_latest_changeset
$ hg out --patch | mdr
Will give you a graphical view
You'll need MDR (mac and win)
We use both Examdiff and Kdiff3 to view Mercurial changes.
Just add this to .hgrc:
[extdiff]
cmd.kdiff3 =
cmd.examdiff = C:\Program Files\ExamDiff Pro\ExamDiff.exe
And then you can type hg examdiff or hg diff3 to see a complete diff of all your changes.
What I would like is to do the same to see a "before and after" of files for a given changeset that was checked in by someone else.
I know you can type hg log to see all changesets and then hg log -vprXX to see a text diff, but that's too hard for my GUI preferring eyes. Anyone know how to the equivalent with the GUI tools?
Can't use just use the -c option to extdiff?
hg kdiff3 -c XX
or
hg examdiff -c XX
in your example?
-c --change change made by revision
from the hg help extdiff output.