mercurial alias: "option --config may not be abbreviated" error - configuration

I have defined the following alias in my mercurial configuration.
[alias]
ci_s = ci --config phases.new-commit=secret
When I executed the command ci_s, I got the error:
abort: option --config may not be abbreviated!
Not sure what's causing the error. My guess is the "=" sign between new-commit and secret. Is there any way to make this alias to work? Thanks.

So I have got the solution to my question from the helpful Mercurial IRC. According to one of the core developers, mg, the error message is telling me that I cannot use --config in aliases. Instead, I can choose to use shell alias, ci_s = !$HG ci --config..., which would make Mercurial spawn a new child process. Since the commit process is quick, so I don't see any issue with spawning a new child process.

Related

Mercurial error on commit: "abort: phases.new-commit: not a valid phase name ('')"

I'm getting the following error when attempting to commit to a Hg repository:
Z:\wormcard_maker>hg commit -m "asdf"
transaction abort!
rollback completed
abort: phases.new-commit: not a valid phase name ('')
This happens over multiple different repositories and has survived re-cloning the repository and reinstalling Mercurial. I can commit to the repository fine from a different computer (running Linux).
I'm running Hg 4.8 as distributed with TortoiseHg 4.8 on Windows 7.
In TortoiseHg just set the "File - Settings - Commit - New Commit Phase" option.
I tried using the THG setting but it didn't work; just kept producing the same error.
(While doing this I noticed that the THG dropdown for the phase choices had a bunch of blank lines in it; so I think THG was confused.)
Instead I manually edited my HGRC file and made sure it contained:
[phases]
new-commit = secret
which worked.
You could obviously use draft, etc. in place of secret.
Neither of the other answers worked for me - even though I had new-commit = secret in the HGRC it still produced the error.
The workaround I found was to do this:
hg ci -m "message" --config phases.new-commit=secret
which did work, apparently by overriding whatever invalid phase name hg was trying to use. Even though I don't know why.
I assume this would work with other comments, not just ci (aka commit).

Finding secret changesets in Mercurial 2.8

I'm trying to get Mercurial to show me all changesets in phase secret. According to the docs, I should execute the command hg log -r "secret()", but if I do that, it tells me hg: parse error at 9: invalid token. I'm running Mercurial 2.8
Is it possible to find the changesets I'm looking for?
The solution turned out to be that I copied the command from somewhere, but that somewhere used quote characters that my command line didn't recognize.

How can I overcome the error "unknown parent" when applying a Mercurial bundle.

I bundle changes from one repository, email them to another machine and apply them there to a repository (for a workflow description see this question).
Suddenly I get the following error message (when applying a bundle with a command like hg unbundle -u "bundle_123.hg"):
adding changesets transaction abort!
rollback completed
abort: 00changelog.i#24ecac5680c1: unknown parent!
How can I apply this bundle despite the "unknown parent"? I hoped for a --forceoption, but unbundle doesn't have one...
Or can I avoid this error in an other way?
Short answer: you can't unbundle this bundle, because autonomous changesets are impossible in Mercurial
You don't have parent of 24ecac5680c1 (?) CSET in destination repository (while you must have it) - your bundle is bad and you selected wrong base on bundling

In Mercurial, how to run original command if default arguments are present?

I have configured hg log in ~/.hgrc to only list commits from the current branch by default:
[defaults]
log = --branch .
However, occasionally I'd like to really see commits from all branches. Is there a way to tell hg log when invoked form the command line to not use the configured defaults but fall back to the built-in behavior? As a brute-force solution ignoring ~/.hgrc altogether for this particular invocation of hg log would be fine for me.
I'm aware that defaults are deprecated in favor of aliases, but aliases cannot be created with the same names as existing commands, which is what I want in order to not have to learn new command names, esp. when ~/.hgrc settings are to be shared by multiple developers.
Edit: Not being able to create aliases with the same names as existing commands was a regression that has been fixed.
You should be able to use --config to override the setting in your .hgrc:
hg --config defaults.log= log
From the man page:
--config set/override config option (use 'section.name=value')
I have gone through the bug reports on the Mercurial website and cannot find any workarounds for this, the response being a blanket "this is deprecated".
Personally, not learning the commands to me is not a valid reason for not migrating away from default command values. A possible alternative would be to move away from per-repository settings and have some settings at the user level, so you can set your own defaults / aliases.
Defaults are now deprecated, so you should likely remove this and specify the arguments each time. Confirmed in the documentation:
https://www.mercurial-scm.org/wiki/Defaults
(defaults are deprecated. Don't use them. Use aliases instead)
Try:
[alias]
blog = log --branch
Usage:
hg blog <branch name>
hg blog default
I know I'm resurrecting an old question here, but this statement
aliases cannot be created with the same names as existing commands
is incorrect.
In your .hgrc file in the [alias] section, you can, for example, have:
[alias]
add = add --dry-run
This will make the add command always do a dry-run, instead of actually recursively adding all unknown files in the repository.
It seems the best solution to my use-case indeed it to temporarily ignore the ~/.hgrc file altogether. This can be done by setting HGRCPATH to an empty string, which causes Mercurial to only read the .hg/hgrc file from the current repository:
HGRCPATH="" hg log

"Crosses Branches" error with Mercurial and CruiseControl.Net

We are migrating to Mercurial, and of course, we need to update our CruiseControl.Net build process to use it instead of Visual SourceSafe.
We updated our CruiseControl config file with the following block:
<sourcecontrol type="hg" autoGetSource="true">
<executable>C:\Program Files\Mercurial\hg.exe</executable>
<repo>https://bitbucket.org/GTSDevs/galaxy</repo>
<workingDirectory>C:\Cruise Control\Releases\5.0.0\source</workingDirectory>
<branch>master</branch>
<multipleHeadsFail>false</multipleHeadsFail>
<tagOnSuccess>true</tagOnSuccess>
<timeout units="minutes">20</timeout>
</sourcecontrol>
This worked well until we pushed some code to our repository with a branch in it. Now our build fails with the following error:
ThoughtWorks.CruiseControl.Core.CruiseControlException: Source control operation failed: abort: crosses branches (merge branches or use --clean to discard changes)
. Process command: C:\Program Files\TortoiseHg\hg.exe update -r master --noninteractive
at ThoughtWorks.CruiseControl.Core.Sourcecontrol.ProcessSourceControl.Execute(ProcessInfo processInfo)
at ThoughtWorks.CruiseControl.Core.Sourcecontrol.Mercurial.Mercurial.GetSource(IIntegrationResult result)
at ThoughtWorks.CruiseControl.Core.IntegrationRunner.Build(IIntegrationResult result)
at ThoughtWorks.CruiseControl.Core.IntegrationRunner.Integrate(IntegrationRequest request)
All the information I can find on the error appears to pertain to doing an update.
Can anyone help out with getting past this?
Is there something more we should be doing in our ccnet.config file to support Mercurial?
Some ideas:
the best way would be to add a new parameter to the Mercurial source control block in order to add the --clean command line parameter
mercurial support in CruiseControl.NET - how to clean & update build folder?