Mercurial's pager extension doesn't use the pager for hg status, is this a bug?
Also, when using hg glog -p, the pager is used, but this doesn't conform to the guide: "If no pager is set, the pager extension uses the environment variable $PAGER. If neither pager.pager, nor $PAGER is set, no pager is used." I have no $PAGER set.
Please see hg help pager:
pager extension - browse command output with an external pager
[...]
Below is the default list of commands to be paged:
[pager]
attend = annotate, cat, diff, export, glog, log, qdiff
Setting pager.attend to an empty value will cause all commands to be paged.
[...]
So it's documented behavior: the status command is not paged by default.
Related
New versions of mercurial will apply colors to the output of most commands and will pipe commands with long output to a pager. How do I restore the old behavior to not color output and never use a pager?
Add the following to your .hgrc:
[ui]
color = never
paginate = never
When working with commandline, you can also add parameters or options to your commands. This is however not permanent. The hg --help --verbose reveals:
--color TYPE when to colorize (boolean, always, auto, never, or debug)
--pager TYPE when to paginate (boolean, always, auto, or never)
(default: auto)
So the next command disables your pager and does not show any colors:
hg incoming --pager never --color never
I need a mercurail template/keyword "hostname" to get the name (or IP) of the computer where the repo is located. as far as i read the wiki, namely "Chapter 11. Customizing the output of Mercurial", hg help templates, and the web, I think it should be similar to the date keyword, dynamicly expanded. How can i define my own template/keyword?
Thank you verry much
The following extension should do the trick:
from mercurial import templatekw
testedwith = "3.5"
_ipname = None
def showipname(repo, ctx, templ, **args):
""":ipname: String. The hostname of the machine that the repository
resides on."""
import socket
global _ipname
if not _ipname:
_ipname = socket.gethostname()
return _ipname
def uisetup(ui):
templatekw.keywords["ipname"] = showipname
Then use (say):
hg log -r . -T '{node|short} at {ipname}\n'
Note that the value of socket.gethostname() may depend on your internet connectivity. If you need the value in /etc/hostname or something else that identifies your machine, use that method instead.
To use an extension, put it in a file, say ipnametempl.py somewhere, then add the following lines to your .hgrc:
[extensions]
ipnametempl=/path/to/ipnametempl.py
This can be either your user/global hgrc or the .hg/hgrc in your repository (the latter if you only want to enable it for a specific repository). See hg help hgrc to find out where the user/global hgrc files are on your system.
Either the repository is local to your machine (then you can get the absolute path via hg root) and query the name via the normal system tools. You can embed those also in your templates:
$ hg log -r. --template="{branch}-{rev} from $(hostname) running debian $(cat /etc/debian_version)"
trunk-22248 from MYHOSTNAME running debian 8.2
Or you know already the URL (remote path) in order to operate with it as you need to specify it as argument to hg pull/clone/outgoing/incoming
If the remote URL is not explicitly specified on the command line it is specified in your .hgrc in the [path] section. When there is a remote repository at all, then usually a default = URL is defined there.
If you need the URL printed, then install hooks for clone, pull and push (and maybe outgoing and incoming) which prints the $URL as available in those hooks - or maybe just the changegroup hook. Check http://hgbook.red-bean.com/read/handling-repository-events-with-hooks.html#sec:hook:changegroup and hg help config.
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.
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
When I commit something in Mercurial like this:
hg commit -m "username question"
I see this output:
No username found, using 'WindowsVistaAdmin#ChunkyMonkey' instead
ChunkyMonkey is my Windows machine name and obviously WindowsVistaAdmin is the user that I am signed in as on this machine.
How can I set the username to something more respectable, or, at least, more concise?
In your ~/.hgrc (*nix) or mercurial.ini (Windows) file:
[ui]
username = First Last <email#address.com>
(mercurial.ini is in C:\Documents and Settings\[username]\ for XP and lower, C:\Users\[username]\ for Vista and higher. You can also run hgtk userconfig if you have TortoiseHg installed and do it that way.)
you can specify your username on the command line directly if you want to using --config. eg
hg --config ui.username=frymaster -m "comment here" commit
in fact, you can override anything in your .hgrc with this command. just look at your .hgrc and note the format:
[section]
key=val
that translates directly to
hg --config section.key=val
Information from here:
Setting up a username
When you try to run hg commit for the
first time, it is not guaranteed to
succeed. Mercurial records your name
and address with each change that you
commit, so that you and others will
later be able to tell who made each
change. Mercurial tries to
automatically figure out a sensible
username to commit the change with. It
will attempt each of the following
methods, in order:
If you specify a -u option to the hg commit command on the command
line, followed by a username, this is
always given the highest precedence.
If you have set the HGUSER environment variable, this is checked
next.
If you create a file in your home directory called .hgrc, with a
username entry, that will be used
next. To see what the contents of this
file should look like, refer to the
section called “Creating a Mercurial
configuration file” below.
If you have set the EMAIL environment variable, this will be
used next.
Mercurial will query your system to find out your local user name and
host name, and construct a username
from these components. Since this
often results in a username that is
not very useful, it will print a
warning if it has to do this.
If all of these mechanisms fail,
Mercurial will fail, printing an error
message. In this case, it will not let
you commit until you set up a
username.
You should think of the HGUSER
environment variable and the -u option
to the hg commit command as ways to
override Mercurial's default selection
of username. For normal use, the
simplest and most robust way to set a
username for yourself is by creating a
.hgrc file; see below for details.
Here is how my windows /users/xxx/mercurial.ini looks. I don't have to enter username or passwords for anything. Looks like it might be repo specific. I have tortoiseHG installed, not sure if that makes any difference.
[ui]
username=mbroekhuis
[auth]
repo.prefix=http://myrepo
repo.username=mbroekhuis
repo.password=secret
For anyone trying to use HG workbench
settings
user global settings
Edit File
Save