Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 333
sschuberth Avatar asked Jul 24 '12 08:07

sschuberth


People also ask

What are the mercurial commands?

Mercurial Commands. Commands. Description. hg pull. get latest changes like git pull use flags like -u IDK why yet. hg add. only for new files. hg commit. add changes to commit with -m for message just like git.

What configuration options does the mercurial source recognize?

The Mercurial source recognizes the following configuration options, which you can set on the command line with --config: convert.hg.ignoreerrors: ignore integrity errors when reading.

How do I control the handling of files in mercurial?

To control Mercurial's handling of files that it manages, many commands support the -Iand -Xoptions; see hg help <command>and hg help patternsfor details. Files that are already tracked are not affected by .hgignore, even if they appear in .hgignore.

How do I find a specific directory in mercurial?

By default, this command searches all directories in the working directory. To search just the current directory and its subdirectories, use "--include .". If no patterns are given to match, this command prints the names of all files under Mercurial control in the working directory.


3 Answers

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')
like image 136
jyu Avatar answered Sep 19 '22 00:09

jyu


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
like image 34
Adam Houldsworth Avatar answered Sep 20 '22 00:09

Adam Houldsworth


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.

like image 24
moswald Avatar answered Sep 20 '22 00:09

moswald