How can I use BeyondCompare3 to mark a merge as resolved. In the bottom pane I select the filename and save then exit however hg always shows me the merge as failing?
The file should be automatically marked as resolved once you saved output in the bottom pane. (You don't need to select filename as it should be point to the right place from the beginning.)
Any chance you might have misconfigured BeyondCompare as a merge tool? Here is a relevant part of the configuration file which always work for me:
[ui]
merge = beyondcompare3
[extensions]
extdiff=
[extdiff]
md.beyondcompare3 = c:\Program Files (x86)\Beyond Compare 3\BCompare.exe
opts.beyondcompare3 = /leftreadonly
[merge-tools]
; Windows version of BeyondCompare 3
beyondcompare3.priority=-1
beyondcompare3.args=$local $other $base /mergeoutput=$output /ro /lefttitle=local /centertitle=base /righttitle=other /outputtitle=merged /automerge /reviewconflicts /solo
beyondcompare3.premerge=False
beyondcompare3.regkey=Software\Scooter Software\Beyond Compare 3
beyondcompare3.regname=ExePath
beyondcompare3.gui=True
beyondcompare3.diffargs=/lro /lefttitle='$plabel1' /righttitle='$clabel' /solo /expandall $parent $child
beyondcompare3.diff3args=$parent1 $parent2 $child /lefttitle='$plabel1' /centertitle='$clabel' /righttitle='$plabel2' /solo /ro
beyondcompare3.dirdiff=True
beyondcompare3.binary=True
[tortoisehg]
vdiff = beyondcompare3
Related
I set up Mercurial in .hgrc to use less as a pager together with customized colors and templates following this guide:
[pager]
pager = LESS='FSrX' less
[templates]
# ...
[color]
mode=terminfo
This works very nicely and I'd like to keep this for all commands except for hg diff. For this command only I'd like to use a completely different mechanism:
No ANSI escape codes in output.
Use https://github.com/dandavison/delta as a pager.
Is it possible to configure Mercurial this way?
I found a solution here which achieves this setup using the extdiff extension.
[extensions]
hgext.extdiff =
[extdiff]
cmd.delta =
[alias]
diff = delta
Earlier I had this workaround - to create a separate alias:
[alias]
d = !$HG diff "$#" | delta
Unfortunately it's not possible to replace the original diff command this way. While it's possible (although discouraged) to replace a command with an alias, in this case it doesn't work: Invoking $HG diff from a diff alias would cause an infinite loop.
Beware of using manuals for Mercurial from 2014 in 2022, they can be outdated and just irrelevant
Correct using less now as pager will be (without artefacts of pager extension)
[pager]
pager = less -FRX
According to hg help pager in fresh HG (6.2), you can, with active pager, disable using it for some command(s)
You can disable the pager for certain commands by adding them to the pager. Ignore list
i.e. have smth. like
[pager]
ignore = diff
and get diff totally without paging
From the other side (contrary to the above point), you can use --config
set/override config option (use 'section.name=value')
option on calling hg diff (when|if you'll have delta as working pager) and for simplicity create hg-alias for "hg diff with delta" like
ddiff = diff --config pager.pager=delta $#
What are the most important special / dot files when using a hg repo ?
Like configuration files and similar.
There are a lot of files that a Mercurial repo will use for configuration or keep track of state, but here are the ones that have the best chance to come in handy:
.hg/last-message.txt -- used by hg commit to store backup of the commit message in case the commit fails.
Example:
My commit message!
.hg/localtags -- define local tags which are not shared among repositories.
Example:
8a7b128ab80b58fc2e63258c9e2bf1f58a5be7c2 myfirsttag
08ff3a0b2e5af9a74becbfdf3e92d6e9a2d0c960 secondtag
6535d105ea795a38808481b160314f9857736c53 thirdtag
.hgignore -- regular expressions that describe file names that should be ignored by hg.
Example:
syntax: glob
*.elc
*.orig
*.rej
*~
*.mergebackup
*.o
*.so
*.dll
*.exe
*.pyd
*.pyc
.hg/hgrc -- defaults and configuration values for mercurial.
Example:
[ui]
verbose = True
username = Joe User <j.user#example.com>
[extensions]
hgext.churn = /home/user/hg/hg/contrib/churn.py
[hgk]
path = /home/user/hg/hg/contrib/hgk
.hgsub -- locations of all subrepositories and where subrepository checkouts came from.
Example:
subrepo1 = https://user#example.org/user/repo
subrepo2 = https://user#example.org/user2/repo2
.hgtags -- contains changeset hash values and text tag names
Example(same format as localtags):
8a7b128ab80b58fc2e63258c9e2bf1f58a5be7c2 myfirsttag
08ff3a0b2e5af9a74becbfdf3e92d6e9a2d0c960 secondtag
6535d105ea795a38808481b160314f9857736c53 thirdtag
how do I open from terminal window only files with conflicts during git/mercurial merge in textmate/sublime text2 editors
You can use the following to open all files with git merge conflicts in sublime text:
git diff --name-only | uniq | xargs subl
I wanted to add another answer. git diff --name-only will give you all files that have diffs. This is why sometimes it will yield duplicate entries because it marks the file as "modified" as well as in a merge conflict state. Piping it into uniq is a good solution for this but git diff --name-only will also include files you might have purposely changed so it doesn't actually filter only files with merge conflicts. When you are in the middle of rebasing, this is probably not going to happen often though I would say in most cases #StephanRodemeier's answer works.
However, what you can do though is leverage the --diff-filter option which assigns a states to files. See more in the docs
--diff-filter=[(A|C|D|M|R|T|U|X|B)…[*]]
Select only files that are Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R), have their type (i.e. regular file, symlink, submodule, …) changed (T), are Unmerged (U), are Unknown (X), or have had their pairing Broken (B). Any combination of the filter characters (including none) can be used. When * (All-or-none) is added to the combination, all paths are selected if there is any file that matches other criteria in the comparison; if there is no file that matches other criteria, nothing is selected.
It seems when files are in the both modified state, the diff status gets set to U (Unmerged) and M (Modified) so you can filter for only Unmerged files.
git diff --diff-filter=U --name-only | xargs subl
Should work without needing to pipe into uniq
Another thing you can consider is simply setting your editor as the difftool i.e. for VSCode documentation specifies how to do this by adding this to your .gitconfig
[diff]
tool = default-difftool
[difftool "default-difftool"]
cmd = code --wait --diff $LOCAL $REMOTE
I'm working with small binary files in Mercurial as posted.
This binary files can be dumped as text to make a diff between versions, but the problem is that the files comes in pairs (eg: Form.scx / Form.sct), and I cannot found a way to tell Mercurial to "make a snapshot" (copy to a temporary location) of the other corresponding file when I do an hg ediff.
Just make a quick script and set that as the tool for extdiff. I'm guessing you're on Windows, but whatever the powershell equivalent to this is:
#!/bin/sh
binary-to-text $1 /tmp/$1.sct
binary-to-text $2 /tmp/$2.sct
diff /tmp/$1.sct /tmp/$2.sct
rm /tmp/$1.sct /tmp/$2.sct
That creates, compares, and then deletes the text versions. You'd want to be careful to not overwrite, deal with multiple concurrent invocations, etc.
Then configure a new command to run your script:
[extdiff]
cmd.mydiff = that_script_above.sh
Then you can do things like:
hg mydiff
Ideally you have only the "source" bonary format in your respository, not the text format, as you shouldn't keep generated items in the repo -- because if you update one but not the other you have an inconsistent state. Generating the comparable text files on demand is a better way to go.
As suggested by #Ryan, I ended up with a small batch previous to the diff program:
#echo off
set f1=%1
set f2=%2
::Temporary dir created by hg to copy the snapshot file
set tdir=%~dp1
::Original repository dir
set repo=%~dp2
::Filename extension
set ext=%~x1
::The binary files comes in pairs: scx/sct \ vcx/vct ...
set ex2=%ext:~0,-1%t
::Check if "dumpable" extension
echo %ext% | grep -iE "(vcx|vct|scx|sct|pjx|pjt|frx|frt)" > nul && goto DumpFile
goto diff
:DumpFile
set f1="%tdir%\_Dump1.prg"
set f2="%tdir%\_Dump2.prg"
::Get the pair file from the repository
hg cat %repo%\%~n1%ex2% -o "%~dpn1%ex2%" -R %repo%
::Do the dump, then the diff
MyDumpProgram.exe %1 %f1%
MyDumpProgram.exe %2 %f2%
goto diff
:diff
ExamDiff.exe %f1% %f2%
pause
and then config the batch in %UserProfile%\.hgrc
[extdiff]
cmd.ediff = d:\Utiles\diff2.bat
I've tried adding merge=kompare to my ~/.hgrc, but when I run hg merge, it runs kompare, but there's no UI to be seen. Hg says merging path/to/first-file and stays there, actionless.
The kompare.args posted earlier probably wont work. I've had difficulty using Kompare for merging, especially 3-way merges (which are preferred and safe).
BTW, most of the other options are enabled by default I believe, but you can verify with: hg showconfig merge-tools
You are better off using kdiff3. Incase you are on Ubuntu Intrepid, kdiff3 was erroneously removed from the repos - but you can easily compile from source.
You will also need to add a section that explains how to call Kompare. I don't know Kompare, so I don't know what the command line should look like (no guarantees for the kompare.args line), but it should be something like this:
[merge-tools]
kompare.executable = C:\<path...>\kompare.exe
kompare.args = $base $local $other -o $output
kompare.priority = 1
kompare.gui = True
kompare.binary = True
If merges aren't detected correctly, you might want to add
kompare.checkconflicts = True
kompare.checkchanged = True
Kompare does not support 3-way diffs, so it can be used for Visual Diff feature only. Here's the config to make it work:
[merge-tools]
kompare.executable = kompare
kompare.diffargs = -c $parent $child
kompare.gui = True
Note the diffargs field instead of args.