Commit Graph

324 Commits

Author SHA1 Message Date
Yuya Nishihara
96a8ea56df cmdserver: forcibly use L channel to read password input (issue3161)
Command server is designed to use the channel protocol even if the server
process is accessible to tty, whereas vanilla hg should be able to read
password from tty in that case.  So it isn't enough to swap sys.stdin:

    # works only if the server process is detached from the console
    sys.stdin = self.fin
    getpass.getpass('')
    sys.stdin = oldin

or test isatty:

    # vanilla hg can't talk to tty if stdin is redirected
    if self._isatty(self.fin):
        return getpass.getpass('')
    else:
        ...

Since ui.nontty flag is undocumented and command-server channels don't provide
isatty(), this change won't affect the other uses of ui._isatty().

issue3161 also suggests to provide some context of messages.  I think it can
be implemented by using the generic templating function.
2014-04-26 18:13:06 +09:00
Pierre-Yves David
2feab6f005 ui: pushbuffer can now also capture stderr
We need an easy way to capture both stderr and stdout during bundle2 processing
of a remote bundle. This changeset adds simple changes to the `ui` class to make
this possible.

I expect the interface to change in future releases as bundle2 will probably want to
distinguish stdout and stderr. The current change will, however, do for now.
2014-04-16 23:36:57 -04:00
Mads Kiilerich
160aa99a26 config: give a useful hint of source for the most common command line settings
'hg showconfig --debug' will instead of:
  none: ui.verbose=False
give the better hint:
  --verbose: ui.verbose=False
2014-03-19 02:45:04 +01:00
Mads Kiilerich
55b56c55c8 config: backout 012889e73d40 - 8224e8f455bf removed the only use of overlay 2014-03-19 01:59:15 +01:00
Alexander Drozdov
8bd59ff2d8 ui: edit(): transplant: set HGREVISION environment variable for an editor
transplant command set 'transplant_source' extra for the revision.
Allow an editor to access the extra using HGREVISION environment variable.

This may be useful when an editor is actually a script which modifies a commit
message. Transplant filters is an alternative way to do it.
2014-02-10 07:13:10 +04:00
Alexander Drozdov
bc85c50d9f ui: edit(): rebase, graft: set HGREVISION environment variable for an editor
rebase and graft commands set 'rebase_source' or 'source' extras for the revision.
Allow an editor to access the extras using HGREVISION environment variable.

This may be useful when an editor is actually a script which modifies a commit
message.

The name 'HGREVISION' has been selected as transplant already sets this variable
for its filters (--filter).
2014-02-06 12:21:20 +04:00
Alexander Drozdov
76bdfab906 ui: allow edit() to work with revision extras
Make edit() to accept optional 'extra' dictionary. Revision extras will be
used in upcoming patches to set some environment variables.
2014-02-06 11:38:28 +04:00
Matt Mackall
ab8d3b450f ui: fix extra space in username abort 2014-02-27 15:14:37 -06:00
Matt Mackall
6ba3cc7397 ui: suggest config --edit when no username is set 2014-02-27 14:46:29 -06:00
FUJIWARA Katsunori
1629d4ee7f ui: add "extractchoices()" to share the logic to extract choices from prompt 2013-12-02 00:50:29 +09:00
Matt Mackall
397a3b5d72 merge with stable 2013-10-09 14:15:34 -07:00
Matt Mackall
4b0ea6e3c8 ui: send password prompts to stderr again (issue4056) 2013-10-09 11:27:59 -07:00
Augie Fackler
15caa41e46 ui.config: fix bug in config alternatives from 98114deb235a 2013-07-24 19:13:39 -04:00
Matt Mackall
13d2a13ea6 ui: merge prompt text components into a singe string
This will help avoid problems with partial or mismatched translation
of the components.
2013-05-22 17:31:43 -05:00
Bryan O'Sullivan
7f31537028 ui: use util.sizetoint in configbytes 2013-05-14 15:16:44 -07:00
FUJIWARA Katsunori
2de8c4416b i18n: show the non-ASCII password prompt text correctly
Before this patch, the prompt text for asking password is directly
passed to "getpass.getpass()" of Python standard library.

In "getpass.getpass()" implementation on Windows environment, the
prompt text is split into byte sequence and "msvcrt.putch()" is
applied on each bytes in it. This splitting causes non-ASCII prompt
text to be broken.

This patch shows the prompt text for asking password on "ui.getpass()"
side, and invokes "getpass.getpass()" with empty prompt text. This
prevents non-ASCII prompt text from being broken in
"getpass.getpass()" implementation.

This patch also sets "ui.prompt" label to prompt text to follow
"ui.prompt()" style.
2013-04-25 20:48:49 +09:00
Bryan O'Sullivan
12ef7ce995 ui: add a configbytes method, for space configuration
This accepts a floating point number, followed by optional whitespace,
followed by an optional one- or two-letter unit specifier (for
bytes, kilobytes, megabytes, or gigabytes).
2013-04-18 12:58:28 -07:00
Matt Harbison
7f63ccb02c ui: add 'force' parameter to traceback() to override the current print setting
This will allow a current traceback.print_exc() call in dispatch to be replaced
with ui.traceback() even if --traceback was not given on the command line.
2013-02-09 14:22:52 -05:00
Matt Harbison
8ab43e8c5a ui: add support for fully printing chained exception stacks in ui.traceback()
Currently, only SubrepoAbort has a cause chained to it.
2013-02-09 14:15:34 -05:00
Durham Goode
4add84adea blackbox: adds a blackbox extension
Adds a blackbox extension that listens to ui.log() and writes the messages to
.hg/blackbox.log. Future commits will use ui.log() to log commands, unhandled
exceptions, incoming changes, and hooks.  The extension defaults to logging
everything, but can be configured via blackbox.track to only log certain events.
Log lines are of the format:  "date time user> message"

Example log line:
2013/02/09 08:35:19 durham> 1 incoming changes - new heads: d84ced58aaa
2013-02-12 14:08:33 -08:00
Mads Kiilerich
ac8e1fc147 check-code: there must also be whitespace between ')' and operator
The check pattern only checked for whitespace between keyword and operator.

Now it also warns:
 >     x = f(),7
 missing whitespace after ,
 >     x = f()+7
 missing whitespace in expression
2012-12-09 23:33:16 +01:00
Mads Kiilerich
2f4504e446 fix trivial spelling errors 2012-08-15 22:38:42 +02:00
Matt Mackall
61aa1f42b8 merge with stable 2012-06-29 00:40:52 -05:00
Idan Kamara
7875dccb0b ui: add a variable to control whether hooks should be called
So hooks can be temporarily disabled.
2012-06-23 19:57:07 +03:00
Martin Geisler
2fb6d24292 ui: lowercase "no username" warning 2012-06-12 14:18:18 +02:00
Martin Geisler
85338c4193 ui: lowercase "not trusting file" warning message 2012-06-12 14:18:18 +02:00
Martin Geisler
d599cd6742 ui: lowercase ConfigError warning message 2012-06-12 14:18:18 +02:00
Matt Mackall
b267442ddb ui: add _isatty method to easily disable cooked I/O 2012-05-20 14:31:56 -05:00
Brodie Rao
46ce54af4d cleanup: replace more naked excepts with more specific ones 2012-05-13 13:17:31 +02:00
Brodie Rao
d6a6abf2b0 cleanup: eradicate long lines 2012-05-12 15:54:54 +02:00
Steven Stallion
d79ff306e5 plan9: initial support for plan 9 from bell labs
This patch contains support for Plan 9 from Bell Labs. A README is
provided in contrib/plan9 which describes the port in greater detail.
A new extension is also provided named factotum which permits the
factotum(4) authentication agent to provide credentials for HTTP
repositories. This extension is also applicable to other POSIX
platforms which make use of Plan 9 from User Space (aka plan9ports).
2012-04-08 12:43:41 -07:00
Matt Mackall
560dd93d34 merge with stable 2012-04-06 15:18:14 -05:00
Kevin Bullock
cb270596b4 ui: swallow EBADF on stderr
ui.write_err already swallows EPIPE and EIO if a write to stderr fails.
On Mac OS X at least, a write to a closed file descriptor results in
EBADF. Before this patch, hg would exit with status 1 if a write to
stderr failed during startup (e.g. while trying to print a warning about
not finding an extension):

  $ ./hg --config extensions.foo= version 2>&-; echo $?
  1

With this patch, it correctly swallows stderr and continues to run the
command:

  $ ./hg --config extensions.foo= version 2>&-
  Mercurial Distributed SCM (version 2.1)
  ...
2012-04-04 12:46:54 -05:00
Matt Mackall
107150b868 ui: add formatter method 2012-02-20 16:42:48 -06:00
Pierre-Yves David
3dfd3d6ee3 config: have a way to backup and restore value in config
This is introduce to allow temporary overwriting of a config value while being
able to reinstall the old value once done. The main advantage over using
``config`` and ``setconfig`` is that backup and restore will properly restore
the lack of any config. Restoring the fact that there was no value is important
to allow config user to keep using meaniful default value.

A more naive approach will result in the following scenario::

  Before:
    config(section, item, my_default) --> my_default

  temporal overwrite
    old = config(section, item)
    …
    setconfig(section, item, old)

  After
    config(section, item, my_default) --> None

The first user of this feature should be mq to overwriting minimal phase of
future commit.
2012-01-18 16:52:26 +01:00
Matt Mackall
864ce9da04 misc: adding missing file close() calls
Spotted by Victor Stinner <victor.stinner@haypocalc.com>
2011-11-03 11:24:55 -05:00
Matt Mackall
af293bcf51 merge with stable 2011-09-12 23:02:45 -05:00
Simon Heimberg
4cccc99bac ui: write traceback to self.ferr 2011-09-11 14:42:30 +02:00
Martin Geisler
9b3666843e ui: also swap sys.stdout with self.fout in _readline
In 55a66b5d9114, _readline was changed to output a space using
raw_input and this was done using sys.stdout directly, not self.fout.

This change broke the command server for JavaHg since it (and other
clients) would see a spurious ' ' on stdout and interpret this as an
unknown channel.
2011-08-30 14:18:58 +02:00
Idan Kamara
9b89917a5f ui: pass ' ' to raw_input when prompting
This is a workaround for calling ui.prompt(...), typing some character then
hitting backspace which causes the entire line to delete rather than just the
one character. This was seen on Debian using gnome-terminal.

(credits to Mads for the idea)

Python bug can be found here: http://bugs.python.org/issue12833
2011-08-25 22:06:03 +03:00
Idan Kamara
bc85c198e4 ui: call write() so the prompt string goes through subclassed implementation 2011-08-01 19:53:00 +03:00
Martin Geisler
0bbf634d5b merge with stable 2011-08-30 15:22:10 +02:00
Matt Mackall
afa4ceeda8 merge with stable 2011-08-25 16:21:53 -05:00
Matt Mackall
eebe42565e ui: allow alternatives for config options 2011-08-11 14:34:03 -05:00
Matt Mackall
eb714d4d00 merge with stable 2011-08-01 14:52:11 -05:00
Simon Heimberg
9cc31081c5 ui: config path relative to repo root 2011-07-23 06:09:14 +02:00
Simon Heimberg
e99ca763b9 ui: providing no default value to configpath should not raise an Error 2011-07-23 06:08:52 +02:00
Simon Heimberg
28de693a93 ui: fix error, base can not be a list 2011-07-23 06:08:49 +02:00
Matt Mackall
d056d98ad8 ui: rename _is_trusted to _trusted
is and do are pointless, underbar separators are style violations
2011-07-12 16:36:22 -05:00
Idan Kamara
fce499faf1 ui: use ui out descriptor when calling util.system 2011-06-24 17:04:37 +03:00