mercurial : disable all the extensions from the command line - mercurial

Is there a way for running mercurial without any external extension using a command line switch / environment variable?
For example, in this situation:
$ hg version --debug
Mercurial Distributed SCM (version 4.3.3)
[...]
Enabled extensions:
hggit external
hgremotebranches external
mq internal
rebase internal
shelve internal
How can I accomplish:
$ hg --disable-all-extensions version --debug
Mercurial Distributed SCM (version 4.3.3)
[...]
Enabled extensions:
<empty>
I know I can disable individual extensions via --config extensions.name=!, but I need to nuke everything at once.

From hg help environment:
HGRCPATH
A list of files or directories to search for configuration files. Item
separator is ":" on Unix, ";" on Windows. If HGRCPATH is not set,
platform default search path is used. If empty, only the .hg/hgrc from
the current repository is read.
So you can do:
HGRCPATH= hg version --debug
The mercurial developers encourage everyone to use this incantation in scripts to avoid having the meaning of mercurial commands depend on a user's configuration. See http://mozilla-version-control-tools.readthedocs.io/en/latest/hgmozilla/automation.html for more information from Mozilla about automating mercurial.

Related

Re-cloning a mercurial repository without generaldelta

I'm trying to do a hg clone on an Internet facing machine for later use on an offline build machine. Unfortunately mercurial is 3.9.1 on the Internet machine, but 1.4 on the offline machine.
I get the error abort: requirement 'generaldelta' not supported! and also abort: requirement 'dotencode' not supported!
I found this is becuase generaldelta feature was added in 1.9, and dotencode in 1.7. I've used instructions from the MissingRequirement wiki page to downgrade this repo using the following.
hg clone -U --config format.generaldelta=0 --config format.dotencode=0 --pull /tmp/foo /tmp/bar
However the new repo at /tmp/bar still uses generaldelta, although dotencode require has gone. i.e.
cat /tmp/bar/.hg/requires
fncache
generaldelta <=== still there
revlogv1
store
store
How can I rewrite the repo with both generaldelta and dotencode disabled?
The config option should have been format.usegeneraldelta not format.generaldelta. i.e.
hg clone -U --config format.usegeneraldelta=0 --config format.dotencode=0 --pull /tmp/foo /tmp/bar
Note the config. options are all config.use<feature-name> apart from config.dotencode see Mercurial format options. Beware as there is not any error checking either.

hg shelve installed but hg: unknown command 'unshelve'

I installed the shelve extension for hg by adding 'shelve=' to [extensions]. I can verify this by running 'hg help extensions' which has the following in the output:
enabled extensions:
extdiff command to allow external programs to compare revisions
fetch pull, update and merge in one command
shelve Manage shelves of pickled objects.
I then type 'hg shelve' in a repo of mine, and I get:
hg: unknown command 'shelve'
Mercurial Distributed SCM
...
I would expect the shelve extension to run...
Mercurial verison is 2.0.2
The Shelve extension is distributed with Mercurial 2.8 and later, as mentioned here.
There is an older third party shelve extension that you can use with Mercurial 2.0.2, but it is not distributed with Mercurial and must be installed separately.

hgrc extentions in /home folder not recognized

I added the convert extension (with no path) to my /home/user/.hgrc file, but it is not working:
$ hg convert source_r56 source_r56_fixed --filemap exclude.filemap
hg: unknown command 'convert'
'convert' is provided by the following extension:
convert import revisions from foreign VCS repositories into Mercurial
use "hg help extensions" for information on enabling extensions
I ran "hg help extensions" and realized that none of the enabled extensions in the file are showing as enabled.
I tried setting it in the source_r56/.hg/hgrc as well to no avail.
Update:
$ cat ~/.hgrc
[ui]
username = jetimms <jetimms#jetimms>
verbose = True
[extentions]
convert =
progress =
rebase =
[alias]
ssh = ssh -C
$ cat ./.hg/hgrc
[paths]
default = /home/jetimms/source
[extentions]
convert =
$
(BTW: source_r56 was cloned from a repository called "source".)
Perhaps to better answer the question about whether I am having the same problems with other extensions, I have included part of the results from "hg help extensions" regarding disabled extensions. Here I only note the ones listed above in the the ~/.hgrc. As noted in the comments, I have not used any other extensions.
$ hg help extensions
Using additional features
...
disabled extensions:
...
convert import revisions from foreign VCS repositories into Mercurial
...
progress show progress bars for some actions
...
rebase command to move sets of revisions to a different ancestor
$
You mispelled the word extensions in your .hgrc. Change [extentions] to [extensions] and you're set.

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).

Cloning a Mercurial repository over SSH

I'm having some difficulty cloning my mercurial repository over ssh.
Here's what I have tried:
hg clone ssh://username#username.webfactional.com/path/to/projectname projectname
It's giving me this error:
remote: bash: hg: command not found
abort: no suitable response from remote hg!
hg is installed on the server, however.
I was trying to follow the instructions on this website.
You need a double // after hostname i.e.:
hg clone ssh://username#username.webfactional.com//path/to/projectname projectname
Sounds like hg is not on your path. The Mercurial FAQ mentions possible fixes for this issue: FAQ/CommonProblems.
Add the remotecmd value to your Mercurial configuration by opening ~/.hgrc (or Mercurial.ini on Windows) on your client machine and adding the following:
[ui]
remotecmd = /path/to/hg
where /path/to/hg is the path to the hg command on the remote server.
If you're having problems with your Mercurial configuration, you can use the hg showconfig --debug command to obtain a full list of your Mercurial settings along with the path and line number of the configuration file that defines each configuration value.
Looks like mercurial isn't in your user's PATH on the remote server.
On webfactional I had to add:
export PATH=$PATH:/home/<user>/bin
to .bashrc to get it to work.
(also followed the remotecmd advice above)
You can use Sourcetree, TortoiseHg, Mercurial from the terminal, or any client you like to clone your Mercurial repository. These instructions show you how to clone your repository using Mercurial from the terminal.
From the repository, click + in the global sidebar and select Clone
this repository under Get to work.
Copy the clone command (either the SSH format or the HTTPS).
If you are using the SSH protocol, ensure your public key is in Bitbucket and loaded on the local system to which you are cloning.
From a terminal window, change to the local directory where you want to clone your repository.
Paste the command you copied from Bitbucket, for example:
CLONE OVER HTTPS:
$ hg clone https://username#bitbucket.org/teamsinspace/hg-documentation-tests
CLONE OVER SSH:
$ hg clone ssh://hg#bitbucket.org/teamsinspace/hg-documentation-tests
If the clone was successful, a new sub-directory appears on your local drive.
This directory has the same name as the Bitbucket repository that you cloned.
The clone contains the files and metadata that Mercurial requires to maintain the changes you make to the source files.
On the server, type: nano ~/.bashrc end edit the file by adding:
# User specific aliases and functions
export PATH=$PATH:$HOME/packages/mercurial
Under the assumption that ~/packages is the folder where mercurial was installed.
After editing, finish off with source ~/.bashrc and try again.
Pretty helpful to me was the following elaborate guide to install mercurial on a Bluehost hosting server.