hg diff calling kdfif3 instead of outputting text - mercurial

Is it possible to run kdiff3 instead of outputting text when I run hg diff? It can either be some switch or some setup that allows to hookup kdiff3.

You should look into the extdiff extension. That allows you to create new diff commands that can launch external diff tools, such as KDiff3.
You configure it with something like:
[extdiff]
cmd.vdiff = kdiff3
and you can then use hg vdiff to get a graphical diff using KDiff3. Strangely, the extension doesn't allow you to overload the normal hg diff command — it only lets you add new commands.

Related

How to get meld to use hgignore

I've just started using Meld. I'm using its Version Control Diff feature and its working well, except that it doesn't seem to use the .hgignore file.
The tree I'm working in is huge, but I only mercurial-track a small portion, so Meld is taking a loong time to scan the entire tree, 90% of which I could care less about.
I'm using Meld 1.6.0, which doesn't appear to allow the user to manually select the VC type, so I'm forced to start the compare in the directory containing the .hg sub-dir.
Is there a way to get Meld to use the .hgignore file or perhaps override Meld's default VC choice?
I think you should do "the other way around", that is:
configure mercurial to use meld as its "external diff" tool, utilizing "extdiff" extension.
NOTE: All of the above has been tested in UNIX-like environment
in ~/.hgrc enable "extdiff" extension by adding to [extensions] section:
[extensions]
extdiff =
add this below:
[extdiff]
cmd.meld = # if meld is not in your path, you may need to type in here the absolute path to the script
Save ~/.hgrc file.
Now, Then a new hg subcommand shall be available to you.
Enter the hg repo folder, in terminal:
user#machine:~$ cd myrepo
user#machine:~/myrepo$ hg meld
That would spawn meld properly, respectful to .hgignore, mercurial respects itself )
For GUI trickery, you may hook this up to context menus of your favourite file manager:
1. Linux: you may to dance with the Shaman's drum a bit more, but TortoiseHg respects extdiff extension.
1. Windows: TortoiseHg does this automagically
1. Mac: no idea how to do this to Finder :), maybe AppleScripting will be needed here.
Regards.

Is there a way to get "hg extdiff" to include subrepositories?

I would like to configure Mercurial to be able to do something like "hg diff -S", but with an external diff tool (kdiff3, specifically). The logical way to do this would be something like
hg extdiff -S -p kdiff3
However, this does not work because the extdiff extension does not support the "-S" option that many other mercurial commands use to include subrepositories. Is there a workaround?
No, I'm afraid not -- adding a --subrepos flag to the extdiff extension was not on the wishlish when my client sponsored the work on the other commands.

How can I add remote repositories in Mercurial?

I am working with Git repositories in the following way:
I have the master repository and several remotes on the different production machines.
I am pushing the production code to the remotes and restart the services for the changes to take effect.
I am about to switch from Git to Mercurial and I would like to know ahead how I can achieve something like that.
You add entries to the [paths] section of your local clone's .hg/hgrc file. Here's an example of a section that would go in the .hg/hgrc file:
[paths]
remote1 = http://path/to/remote1
remote2 = http://path/to/remote2
You can then use commands like hg push remote1 to send changesets to that repo. If you want that remote repo to update is working directory you'd need to put a changegroup hook in place at that remote location that does an update. That would look something like:
[hooks]
changegroup = hg update 2>&1 > /dev/null && path/to/script/restart-server.sh
Not everyone is a big fan of having remote repos automatically update their working directories on push, and it's certainly not the default.
if you want to add default path, you have to work with default in your ~project/.hg/hgrc file. As Follows:
[paths]
default = https://path/to/your/repo
Good Luck.
You could have a look at hg-git GitHub plugin:
adding the ability to push to and pull from a Git server repository from Mercurial.
This means you can collaborate on Git based projects from Mercurial, or use a Git server as a collaboration point for a team with developers using both Git and Mercurial.
Note: I haven't tested that tool with the latest versions of Mercurial.
If you're on Unix and you have Git installed, you can use this bash function to readily add a path to the remotes without a text editor:
add-hg-path() {
git config -f $(hg root)/.hg/hgrc --add paths.$1 $2
awk '{$1=$1}1' $(hg root)/.hg/hgrc > /tmp/hgrc.tmp
mv /tmp/hgrc.tmp $(hg root)/.hg/hgrc
}
Then invoke it with:
$ add-hg-path remote1 https://path.to/remote1
If someone would like to build a Powershell equivalent, I'd like to include that as well. Other potentials improvements include error checking on the parameters and factoring out the call to $(hg root).

Mercurial: make `hg log` not show files?

I'm (ab)using Mercurial to manage thousands of files that change often, but I'd like to be able to view the log (hg log) without having my term filled with all of the filenames that changed on each commit. hg log -q is a little too quiet, since I need to see the descriptions. Is there a flag I'm missing for hg log?
It sounds as if you might have the verbose flag turned on. You can check by running hg showconfig and looking for a line like ui.verbose=true.
There are a few ways you can fix it:
remove that line from the offending configuration file (Mercurial can use several, and they vary by OS: use hg help config to list the possibilities).
override the flag in your repository's .hg\hgrc or your private Mercurial configuration (Mercurial.ini or ~/.hgrc): add the following lines to it:
[ui]
verbose=false
clear the verbose flag on the commandline: hg log --config ui.verbose=false.

How to commit only a part of the changes made to a file?

I want to commit separately different parts of the same file.
I want to commit line 2 first with the message (changeset 1) and the 4th line with the message (changeset 2). How do I do it?
I am using Mercurial Distributed SCM (version 3.5.2+20151001)
You can do this with the interactive option to commit.
First add the following to your ~/.hgrc file:
[ui]
interface = curses
Then use:
hg commit -i
This will tell commit to allow you to interactively select what files or (by drilling into the file) select sub file changes.
You can use this multiple times, selecting individual changes in the files.
Note: without the addition to your .hgrc, hg commit -i will ask you for each file and not allow you to drill into and select individual file changes.
The interactive option is also being implemented in other mercurial commands such as restore (you can select what changes are to be restored) and the new experimental amend command. It is very powerful and easy to use.