Commit Graph

499 Commits

Author SHA1 Message Date
Pierre-Yves David
40147b2819 devel-warn: move the develwarn function as a method of the ui object
We are going to use this feature in more and more place. Having to import
scmutil makes it an import cycle hell.
2015-06-19 11:19:45 -07:00
Matt Harbison
1378c4e950 ui: flush stderr after printing a non-chained exception for Windows
There were consistent test failures in test-bad-extension.t, because Windows
buffers stderr when redirected to a file (per the comment in ui.write_err()).
That resulted in failures like this:

  --- c:/Users/Matt/Projects/hg/tests/test-bad-extension.t
  +++ c:/Users/Matt/Projects/hg/tests/test-bad-extension.t.err
  @@ -23,11 +23,11 @@
     Traceback (most recent call last):
     Exception: bit bucket overflow
     *** failed to import extension badext2: No module named badext2
  -  Traceback (most recent call last):
  -  ImportError: No module named badext2
     hg help [-ec] [TOPIC]

     show help for a given topic or a help overview
  +  Traceback (most recent call last):
  +  ImportError: No module named badext2

   show traceback for ImportError of hgext.name if debug is set
   (note that --debug option isn't applied yet when loading extensions)

Instead of inserting another flush immediately after the print, to go along with
the one recently added prior to the print (see 3cd72de3be66), funnel the output
through ui.write_err().  The flush prior to printing the traceback only mentions
that stdout needs to be flushed, and only stderr needs to be flushed after
printing the traceback.  ui.write_err() does both for us without needing to
redocument the quirky Windows behavior.  It will also clear any progress bar.
2015-06-12 22:09:41 -04:00
Pierre-Yves David
beda8bc247 progress: display progress bars by default with core Mercurial
As discussed multiple time during sprint, we should activate progress by
default. Having progress bar significantly improve the user experience.
2015-06-07 17:51:27 -07:00
Pierre-Yves David
5446aa78a9 progress: move all logic altering the ui object logic in mercurial.ui
The ui object can take care of its progress object logic by itself.

test-subrepo-recursion is modified because it is a bit sensitive to the "no
progress bar" default. It will become unnecessary in the next step when
progress will be on by default in core.
2015-06-07 17:50:56 -07:00
Pierre-Yves David
5f05d2698e progress: move the singleton logic to the ui module
The use of a singleton for all of progress handling is debatable (because
config may vary). However this is how the extension has been doing it so far.
We move that code into the ui module because this is where is should belong when
progress is moved into core.
2015-06-07 17:26:34 -07:00
Yuya Nishihara
398221202a ui: flush stdout before writing traceback to stderr
Sometimes a traceback message is paired with ui.debug(). This patch makes sure
that these messages are displayed in the right order.
2015-05-31 14:40:28 +09:00
Augie Fackler
a5b17bd9d1 cleanup: use __builtins__.any instead of util.any
any() is available in all Python versions we support now.
2015-05-16 14:30:07 -04:00
Pierre-Yves David
281365197e progress: get the extremely verbose output out of default debug
When the progress extension is not enabled, each call to 'ui.progress' used to
issue a debug message. This results is a very verbose output and often redundant
in tests. Dropping it makes tests less volatile to factor they do not meant to
test.

We had to alter the sed trick in 'test-rename-merge2.t'. Sed is used to drop all
output from a certain point and hidding the progress output remove its anchor.
So we anchor on something else.
2015-05-09 23:40:40 -07:00
Siddharth Agarwal
eba77fa34f ui: disable revsetaliases in plain mode (BC)
ui.plain() is supposed to disable config options that change the UI to the
detriment of scripts. As the test demonstrates, revset aliases can actually
override builtin ones, just like command aliases. Therefore I believe this is a
bugfix and appropriate for stable.
2015-04-30 07:46:54 -07:00
Pierre-Yves David
3ecff4d3f6 ui: allow capture of subprocess output
We want to capture hooks output during bundle2 processing. For this purpose we
introduce a new 'subproc' argument to 'ui.pushbuffer'. When set, the output of
sub process created through 'ui.system' will be captured in the buffer too.

This will be used in the next changeset.
2015-04-23 14:57:39 +01:00
Alexander Drozdov
0af407fa48 editor: prefer 'intermediate-source' extra to use for HGREVISION environment variable
Revision 7fbf0ef28408 ('graft: record intermediate grafts in extras') introduced
'intermediate-source' extra which refers to the closest graft source.

As 'intermediate-source' extra provides more detailed information about the source
changeset than 'source' one, it is better to prefer the first one to use as a
value of HGREVISION environment variable for an editor.
2015-04-10 08:05:50 +03:00
Mathias De Maré
8b3f5b98e3 commands: add ui.statuscopies config knob
statuscopies enables viewing of copies and moves in 'hg status' by default.
2015-03-24 21:25:57 +01:00
Gregory Szorc
2d9de90ccf ui: represent paths as classes
Many have long wanted for paths to have expanded functionality and
flexibility.

In order to make that transition possible, we need to start
representing paths as something more than simple strings.

This patch introduces two classes:

1) "path" for representing a single path instance
2) "paths" for representing a collection of "paths"

Since we don't like patches that introduce new code without any
consumers, we convert ui.expandpath() to use the new APIs internally.
Upcoming patches will start exposing "path" instances to consumers
that currently interface with string paths.

The new "paths" attribute of ui is populated from config data the first
time it is accessed. Since it isn't updated when the configs are
modified, this could lead to some inaccurate caching behavior. It
shouldn't be an issue, as paths information is typically not accessed
until command dispatch, which occurs after the repository config
and extensions have been loaded. Time will tell if we need to refresh
paths information when the underlying config changes.
2015-02-07 12:42:10 -08:00
Yuya Nishihara
c3aa617f2e ui: introduce util.system() wrapper to make sure ui.fout is used
This change is intended to avoid future problem of data corruption under
command server.  out=ui.fout is mandatory as long as command server uses
stdout as IPC channel.
2014-11-08 12:57:42 +09:00
Mads Kiilerich
523c87c1fe spelling: fixes from proofreading of spell checker issues 2014-04-17 22:47:38 +02:00
Yuya Nishihara
df336dc3c8 ui: separate option to show prompt echo, enabled only in tests (issue4417)
The problem in commandserver was addressed by 766cfbe766dc, but it is tricky
to reuse ui.nontty option to disable echo back.  Instead, this patch introduces
new option to enable echoing of prompt response.

Prompt echoing is changed to be off by default, which should avoid possible
breakage of output parsing in user scripts.

For now, this option is undocumented because it exists for internal use.
2014-10-21 23:16:46 +09:00
Jordi Gutiérrez Hermoso
c978db634c config: use the same hgrc for a cloned repo as for an uninitted repo
This just copies the same local sample hgrc, except it sets the
default path to the repo it was cloned from.

This is cut-and-paste from the local sample hgrc, but I think it's
acceptable, since the two pieces of code are right next to each other
and they're small. There is danger of them going out of synch, but it
would complicate the code too much to get rid of this C&P.

I also add ui as an import to hg.py, but with demandimport, this
should not be a noticeable performance hit.
2014-10-06 16:35:02 -04:00
Jordi Gutiérrez Hermoso
e296a9f550 config: give a more detailed sample repo config
Some examples of the typical configurations that one might want to do
in an .hg/hgrc file. This includes a default-push that happens to
point to the same location as my-fork.

I insist on the myfork terminology for a server-side clone. Bitbucket,
Github, and others have widely popularised this meaning of "fork".

This also includes a gentle nudge to use a repo-specific username,
which is something that people might not instinctively realise is an
option.
2014-10-08 07:45:51 -04:00
Yuya Nishihara
2f53d7a8aa ui: disable echo back of prompt input if ui is set to non-tty purposely
d735f8a82023 is nice for test output, but it also affects command-server
channel.  Command-server client shouldn't receive echo-back message, which
makes it harder to parse the output.
2014-10-08 20:51:01 +09:00
Matt Mackall
6712145426 ui: fix comment about non-interactive prompts
This fixes my earlier in-flight addition to Mads' change.
2014-10-02 18:00:05 -05:00
Mads Kiilerich
29285eb86d ui: show prompt choice if input is not a tty but is forced to be interactive
The tests often set ui.interactive to control normally interactive prompts from
stdin. That gave an output where it was non-obvious what prompts got which
which response, and the output lacked the newline users would see after input.

Instead, if the input not is a tty, write the selection and a newline.
2014-10-01 01:04:18 +02:00
Matt Mackall
5bfd322b62 ui: move samplehgrcs from config
config is generic code that doesn't know about Mercurial usage, so
this was at the wrong layer
2014-09-11 12:26:12 -05:00
Yuya Nishihara
7bc5b972be ui: add brief comment why raw_input() needs dummy ' ' prompt string
Retrieved from 55a66b5d9114.

I was about to move ' ' to label(msg + ' ', 'ui.prompt') so that subclass can
distinguish prompt output from data.  But it was not that simple.
2014-08-24 12:35:53 +09:00
FUJIWARA Katsunori
e8856bc78d ui: invoke editor for committing with HGEDITFORM environment variable
At the external editor invocation for committing, the value specified
as "editform" for "cmdutil.getcommiteditor" is in "HGEDITFORM".

This enables external editor to do own customization according to
commit types.
2014-08-15 23:05:53 +09:00
anatoly techtonik
023b57a106 config: allow 'user' in .hgrc ui section (issue3169) 2014-07-26 09:27:11 +03:00
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
David Soria Parra
881ac28f17 i18n: remove translation of debug messages 2011-06-21 18:35:13 +02:00
Idan Kamara
325f77da0a ui: use I/O descriptors internally
and as a result:
- fix webproto to redirect the ui descriptors instead of sys.stdout/err
- fix sshserver to use the ui descriptors
2011-06-08 01:39:20 +03:00
Idan Kamara
d3e4ddd52a ui: add I/O descriptors 2011-06-07 13:39:09 +03:00
Idan Kamara
02f21a70dc util: add helper function isatty(fd) to check for tty-ness 2011-06-02 00:43:34 +03:00
Yann E. MORIN
236f8c6745 ui: enable alias exception when reading config in plain mode
When in plain mode with "alias" present in the exception list,
keep the aliases. This will be used later to enable auto-completion.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
2011-05-17 00:17:52 +02:00
Yann E. MORIN
013aed8037 ui: test plain mode against exceptions
Let ui.plain() accept an optional parameter in the form of a feature
name (as a string) to exclude from plain mode.

The result of ui.plain is now:
 - False if HGPLAIN is not set or the requested feature is in HGPLAINEXCEPT
 - True otherwise

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
2011-05-17 00:08:51 +02:00
Sune Foldager
73c8696ab4 ui: add configint function and tests 2011-05-03 22:28:08 +02:00
Brodie Rao
b7f0d2a103 url: move URL parsing functions into util to improve startup time
The introduction of the new URL parsing code has created a startup
time regression. This is mainly due to the use of url.hasscheme() in
the ui class. It ends up importing many libraries that the url module
requires.

This fix helps marginally, but if we can get rid of the urllib import
in the URL parser all together, startup time will go back to normal.

perfstartup time before the URL refactoring (707e4b1e8064):

! wall 0.050692 comb 0.000000 user 0.000000 sys 0.000000 (best of 100)

current startup time (9ad1dce9e7f4):

! wall 0.070685 comb 0.000000 user 0.000000 sys 0.000000 (best of 100)

after this change:

! wall 0.064667 comb 0.000000 user 0.000000 sys 0.000000 (best of 100)
2011-04-30 09:43:20 -07:00
Adrian Buehlmann
9a67b02dba move rcpath from util to scmutil 2011-04-21 20:14:29 +02:00
Brodie Rao
5f24d65643 HGPLAIN: allow exceptions to plain mode, like i18n, via HGPLAINEXCEPT
This makes it possible to gain the benefits of HGPLAIN for scripting
while preserving different behaviors like internationalization.
2011-01-05 00:18:36 +11:00
Matt Mackall
d0ca936e58 url: nuke some newly-introduced underbars in identifiers 2011-03-31 10:43:53 -05:00
Brodie Rao
8f5f4f569c url: use url.url in ui.expandpath() 2011-03-30 20:02:17 -07:00
Martin Geisler
73d96c7696 ui: label prompts, default to yellow prompts 2011-03-27 12:59:25 +02:00
Martin Geisler
583f21144f ui: yield unchanged values in walkconfig
Ever since walkconfig was introduced back in 4cc9ef8cd232, the values
yielded has been mutated by replacing "\n" with "\\n". This makes
walkconfig less useful than it could and there is no other way to
iterate over all config sections.

The third-party reposettings extension used ui.walkconfig but did not
take the replacement into account -- this change will actually fix a
bug in the extension when a value contains a newline.
2011-03-10 16:49:37 +01:00
Ry4an Brase
c7fa18ccc0 ui: always report untrusted hgrc files when debug enabled
It was suggested in IRC that people disabling the reporting of unstructed hgrc
files can masquerade as problems.  This makes sure untrusted hgrc files are
always reported if --debug is used.
2011-02-25 23:26:24 -06:00
Matt Mackall
2a8c2e15b4 ui: add configpath helper 2011-01-06 17:04:33 -06:00
Martin Geisler
6a3d9310ab code style: prefer 'is' and 'is not' tests with singletons 2010-11-22 18:15:58 +01:00
Nicolas Dumazet
d31f4fef82 ui: only fix config if the relevant section has changed
In particular, when extensions add hooks, or add non-ui and non-paths
configuration items during their setups, we really have no reason
to re-"fix" the config dictionaries.
2010-10-18 14:10:36 +09:00
Augie Fackler
42c8b2cf07 termwidth: move to ui.ui from util 2010-10-10 10:06:36 -05:00
Benoit Boissinot
e73a57d28e fix indentation error 2010-10-09 15:00:30 -05:00
Benoit Boissinot
e5538ef2cc ui.paths: expand paths directly in fixconfig (issue2373)
var and home expansion should be done first.
2010-10-09 12:28:16 -05:00
Augie Fackler
cb7412977d parsebool: create new function and use it for config parsing 2010-08-28 21:50:35 -05:00
Matt Mackall
2fdba01a23 ui: add logging hook 2010-08-19 11:14:02 -05:00
Matt Mackall
eef168b604 merge with stable 2010-08-19 10:25:41 -05:00
Mads Kiilerich
b27d1fd3b8 mq: don't inherit default and default-push paths with --mq (issue2333)
Configuration from the outer repo is inherited to the patches repo when --mq is
used.

In case the patches repo only has paths.default configured but the outer repo
has paths.default-push then the inherited default-push will win. Very
confusing.

Inheriting the default paths is however wrong in all sane cases, so now we
explicitly remove them.
2010-08-18 02:43:45 +02:00
Alecs King
3065ca2943 ui: differentiate empty configlist from None 2010-08-11 20:28:39 +08:00
Martin Geisler
8f362a460f mark ui.warn strings for translation 2010-07-16 14:44:30 +02:00
Mads Kiilerich
8670b69488 ui: ignore EIO in write_err
Hgs signal handler will catch the signal for example if the terminal hg is
running in is closed. That will make it try to warn that it was 'killed', but
that might fail with EIO and cause hg to exit with an unhandled exception.
Normally nobody cares, but system error handlers such as Fedoras abrt will
notice and report https://bugzilla.redhat.com/show_bug.cgi?id=596594 .
2010-06-16 00:22:10 +02:00
Dan Villiom Podlaski Christiansen
6d2a041cb0 ui: document the formatted(), interactive() & plain() functions. 2010-06-07 16:14:12 +02:00
Dan Villiom Podlaski Christiansen
a15c6a0d68 ui: add ui.formatted configuration variable and accessor function.
This new configuration variable is similar in nature `ui.interactive',
but applying to output instead of input. This allows as to support
non-interactive sessions where formatted should be enabled, such as
when using the pager extension.

The variable itself is left undocumented; it is not intended for use
outside Mercurial and its extensions.
2010-06-07 14:59:52 +02:00
Steve Borho
0d0e614fc9 Merge backout 2010-06-08 15:52:56 -05:00
Steve Borho
b82bd4f289 Backed out changeset: 1bfde817782c 2010-06-08 15:52:41 -05:00
Thomas Arendsen Hein
56a5e9e864 ui: handle leading newlines/spaces/commas in configlist
Thanks to Greg Ward for spotting the problem introduced in cc0423a3b3fe
and for supplying the test case.
2010-06-08 21:09:41 +02:00
Steve Borho
e91613380a color: labeled text should be passed to ui.write() as ui.labeled
Some implementations of ui.label() (HTML versions in particular) must escape
the provided text and then markup the text with their tags.  When this marked
up text is then passed to ui.write(), we must label the text as 'ui.labeled'
so the implementation knows not to escape it a second time (exposing the initial
markup).

This required the addition of a 'ui.plain' label for text that is purposefully
not marked up.

I was a little pedantic here, passing even ' ' strings to ui.label() when it
would be included with other labeled text in a ui.write() call.   But it seemed
appropriate to lean to the side of caution.
2010-06-03 23:18:18 -05:00
Chad Dombrova
8cc38b5dd4 ui.username(): expand environment variables in username configuration value.
note: expansion of config variables must be handled on a case-by-case basis
because they can contain arbitrary data that may not be desirable to expand.
2010-05-26 14:03:29 -07:00
Henrik Stuart
bd56afc915 ui: fix check-code error 2010-04-28 21:00:07 +02:00
Henrik Stuart
1c5ca1f5d8 ui: support quotes in configlist (issue2147)
Several places that use ui.configlist, predominantly in authentication
scenarios need to interface with systems that can contain spaces in usernames
(e.g. when client certificates are usernames, or Windows usernames).

This changeset introduces a parser that supports quoting of strings, and
escape quotation marks that get decoded into a single quotation mark that
adopts the usual behavior one would expect from quoting strings. The Python
library shlex module is not used, on purpose, as that raises if it cannot
match quotation marks in the given input.
2010-04-25 17:38:41 +02:00
Brodie Rao
9a7e3ba689 ui: add ui.write() output labeling API
This adds output labeling support with the following methods:

- ui.write(..., label='topic.name topic2.name2 ...')
- ui.write_err(.., label=...)
- ui.popbuffer(labeled=False)
- ui.label(msg, label)

By adding an API to label output directly, the color extension can forgo
parsing command output and instead override the above methods to insert
ANSI color codes. GUI tools can also override the above methods and use
the labels to do GUI-specific styling.

popbuffer gains a labeled argument that, when set to True, returns its
buffered output with labels handled. In the case of the color extension,
this would return output with color codes embedded. For existing users
that use this method to capture and parse output, labels are discarded
and output returned as normal when labeled is False (the default).

Existing wrappers of ui.write() and ui.write_err() should make sure to
accept its new **opts argument.
2010-04-02 15:22:00 -05:00
Yuya Nishihara
56bfdbef10 ui: ignore ui.logtemplate and ui.style when HGPLAIN is set
HGPLAIN should suppress them because they change Mercurial's default
output.
2010-03-03 00:12:05 +09:00
Brodie Rao
df04f13391 ui: unset ui.slash when HGPLAIN is set 2010-02-18 16:51:39 -05:00
Brodie Rao
9dbf7b06a9 ui: suppress aliases when HGPLAIN is set 2010-02-18 16:50:49 -05:00
Brodie Rao
48b845981a ui: add HGPLAIN environment variable for easier scripting
If HGPLAIN is set, the following settings are ignored when read from
hgrc files:

- ui.debug
- ui.fallbackencoding
- ui.quiet
- ui.traceback
- ui.verbose
- defaults.*

Localization is also disabled.

Equivalent options set via command line are honored.
2010-02-07 14:56:18 +01:00
Benoit Boissinot
5919c97831 merge with crew 2010-02-12 16:04:00 +01:00
Thomas Arendsen Hein
4ee8391b45 ui: look before you leap on sys.stderr.closed (and look nicer)
4262f8a58f24 introduced a fix if sys.stdout.closed does not exist.

This change uses a getattr with default instead of hasattr (which just calls
getattr) and accessing the attribute.

Additionally it applies the same fix for sys.stderr.closed as this is not
available in the bpython shell (reported by Roger Gammans).
2010-02-12 15:46:48 +01:00
Augie Fackler
596e0f49d1 ui.progress: clarify termination requirement 2010-02-07 10:25:18 -06:00
Dirkjan Ochtman
09ba0e50af ui: look before you leap on sys.stdout.closed 2010-02-07 16:44:55 +01:00
Matt Mackall
8d99be19f0 many, many trivial check-code fixups 2010-01-25 00:05:27 -06:00
Matt Mackall
cd3ef170f7 Merge with stable 2010-01-19 22:45:09 -06:00
Matt Mackall
595d66f424 Update license to GPLv2+ 2010-01-19 22:20:08 -06:00
Dirkjan Ochtman
efbb46e5cb merge with stable 2010-01-13 12:00:06 +01:00
Dirkjan Ochtman
b176d4360e ui: just return it if it's already a bool 2010-01-13 11:53:55 +01:00
Patrick Mezard
f8872c1d27 ui: display progress with decimal notation 2010-01-08 23:15:24 +01:00
Bryan O'Sullivan
4035f1dfaa Make it possible to debug failed hook imports via use of --traceback
Prior to this change, if a Python hook module failed to load (e.g. due
to an import error or path problem), it was impossible to figure out
why the error occurred, because the ImportErrors that got raised were
caught but never displayed.

If run with --traceback or ui.traceback=True, hg now prints tracebacks
of both of the ImportError instances that get raised before it bails.
2009-11-12 14:05:52 -08:00
Martin Geisler
93008b71a6 ui: refer to "hg help config" when no username is set 2009-11-07 22:13:09 +01:00
Jesse Glick
7966725b4b Related to Issue919: ui.progress, apparently unused before now, is busted. 2009-11-05 16:40:48 -05:00
Martin Geisler
b10a5e234c ui: only use "user@host" as username in noninteractive mode
We regularly see people on IRC ask how they can correct commits they
accidentally made without having configured a username. This change
will make Mercurial abort when a commit is made without a username.

If Mercurial is run without a TTY (from a cronjob or similar), a
username is constructed as usual. Schematically the changes are as
follows:

With ui.askusername=False:

                  old         new
  interactive     user@host   abort
  noninteractive  user@host   user@host

With ui.askusername=True:

                  old         new
  interactive     prompt      prompt
  noninteractive  user@host   user@host
2009-10-20 00:17:36 +02:00
Alexander Solovyov
32999e4659 make path expanding more consistent
This expands ~user and $FOO constructs in ui.ignore files, [defaults],
[paths], extension paths, and HGRCPATH files.
2009-10-19 22:19:28 +03:00
Andrey Somov
2ccddf5ead improve code readability 2009-09-09 11:12:36 +02:00
Brodie Rao
d6fac35b34 ui: fix NameError in ui.progress due to unit/units typo 2009-08-18 14:47:41 -04:00
Dirkjan Ochtman
f692d68a57 kill trailing whitespace 2009-08-05 17:08:28 +02:00
Matt Mackall
a57f5b2b3b Add ui.progress API 2009-07-16 14:49:52 -05:00
Simon Heimberg
e0e4fc74e3 ui: extract choice from prompt
avoid translating single characters (as l for _local or sym_link)
2009-06-21 01:13:19 +02:00
Mads Kiilerich
4f97bc02c9 ui.prompt: Show prompt and selection in non-interactive mode
ui.prompt was completely silent in non-interactive mode, unless in verbose
mode. It is fine that it chooses the default automatically, but it is confusing
that the message and prompt shown interactively can't be found in scripted
tests.

The prompt and selection is now .write'ed instead of .note'ed.
2009-06-21 03:13:38 +02:00
Martin Geisler
cac71647b1 posix: do not use fstat in isowner
The fstat function was undefined, but never used since a stat object
was always passed in the optional st argument. Passing st is now
mandatory.

This bug crept in when util was split up into posix and windows
modules. The fstat function is still defined in util, but importing it
into posix would create an import cycle which seems unnecessary.
2009-05-30 23:42:35 +02:00
Martin Geisler
58e8fb6277 removed unused imports 2009-05-30 23:20:30 +02:00
Matt Mackall
07ba4cbe2d ui: fix two bugs in %% warning 2009-05-27 14:44:52 -05:00
Patrick Mezard
032c355a2a Merge with crew-stable 2010-01-09 00:25:56 +01:00
Ronny Pfannschmidt
83060db9d7 make ui.interactive() return false in case stdin lacks isatty 2009-12-13 18:29:16 +01:00
Sune Foldager
5063be569c ui: add environ property to access os.environ or wsgirequest.environ
The property returns os.environ by default, and is propagated by ui.copy.
During hgweb processing, ui.environ is set to the proper WSGI-request
environment, as contained in wsgirequest.environ. For CGI, this is the
same as os.environ.

The property is meant to be read-only, as with os.environ (generally).
2009-11-19 10:32:33 +01:00
Patrick Mezard
f8fb6f0d87 ui: honor interactive=off even if isatty() 2009-05-21 20:59:36 +02:00
Martin Geisler
0a365d5ca2 use 'x is None' instead of 'x == None'
The built-in None object is a singleton and it is therefore safe to
compare memory addresses with is. It is also faster, how much depends
on the object being compared. For a simple type like str I get:

            | s = "foo" | s = None
  ----------+-----------+----------
  s == None | 0.25 usec | 0.21 usec
  s is None | 0.17 usec | 0.17 usec
2009-05-20 00:52:46 +02:00
Martin Geisler
698fece124 ui: use set instead of dict 2009-05-17 16:20:27 +02:00
Matt Mackall
5534a9c3e3 editor: move HG: filtering from ui to commiteditor 2009-05-14 13:21:17 -05:00
Alexander Solovyov
038c7df455 hgwebdir: read --webdir-conf as actual configuration to ui (issue1586)
This cleans up code and allows specification of values more globally. For
example, it's now possible to specify web.contact in webdir-conf for all
repositories without a specified contact set.
2009-05-11 14:20:18 +02:00
Simon Heimberg
09ac1e6c92 separate import lines from mercurial and general python modules 2009-04-28 17:40:46 +02:00
Steve Borho
52bf113f2e ui: replace regexp pattern with sequence of choices
Use ampersands (&) to delineate the response char in each choice.
ui.prompt() responses are now explicitly case insensitive.  GUIs
that subclass ui can generate dialogs from the full choice names.
2009-04-30 10:15:32 -05:00
Martin Geisler
750183bdad updated license to be explicit about GPL version 2 2009-04-26 01:08:54 +02:00
Dirkjan Ochtman
80de6974e4 more whitespace cleanup and some other style nits 2009-04-27 12:37:19 +02:00
Ronny Pfannschmidt
1d760927a4 ui: ui.copy() now takes the ui class into account
Helps subclassing by other API users.
2009-04-27 10:33:57 +02:00
Matt Mackall
c15de6b1b7 ui: make interactive a method 2009-04-26 16:50:44 -05:00
Matt Mackall
de487eacda ui: print_exc() -> traceback() 2009-04-26 16:50:44 -05:00
Matt Mackall
1be9517a0f ui: traceback -> _traceback 2009-04-26 16:50:44 -05:00
Matt Mackall
efc3ded95f ui: report_untrusted fixes
- report_untrusted -> _reportuntrusted
- only report config shadows if enabled
- config shadows are debug messages
2009-04-26 16:50:44 -05:00
Matt Mackall
77cc1dfdeb ui: privatize cdata vars 2009-04-26 16:50:44 -05:00
Matt Mackall
e84a8d1258 ui: buffers -> _buffers 2009-04-26 16:50:44 -05:00
Matt Mackall
30784dabe1 ui: trusted_users -> _trustusers, trusted_groups -> _trustgroups 2009-04-26 16:50:44 -05:00
Matt Mackall
4e3a9053dc ui: assumetrusted -> trust 2009-04-26 16:50:44 -05:00
Matt Mackall
00aa85afa3 ui: _get_cdata -> _data 2009-04-26 16:50:44 -05:00
Matt Mackall
86dab18ddb config: getsource -> source 2009-04-26 16:50:43 -05:00
Matt Mackall
286d20f8b7 ui: simplify fixconfig 2009-04-26 16:50:43 -05:00
Matt Mackall
59ffac0401 ui: fix-up and warn about deprecated %% 2009-04-26 16:50:43 -05:00
Matt Mackall
036f77e767 config: add section filter to read
move section filtering out of ui.readconfig
kill section filtering in config.update
2009-04-26 16:50:43 -05:00
Matt Mackall
be7d59ab85 ui: kill most users of parentui name and arg, replace with .copy() 2009-04-26 16:50:43 -05:00
Matt Mackall
88b13fecec ui: replace parentui mechanism with repo.baseui 2009-04-26 16:50:43 -05:00
Matt Mackall
10af375ad9 ui: less links to parentui 2009-04-26 16:50:43 -05:00
Matt Mackall
b7e5202883 showconfig: show source file and line with --debug 2009-04-26 16:50:43 -05:00
Benjamin Wohlwend
ef87785038 ui.isatty() accesses sys.stdin, causing mod_wsgi to throw IOError. 2009-04-26 13:36:08 -07:00
Matt Mackall
e8b3de6bf8 ui: introduce new config parser 2009-04-23 15:40:10 -05:00
Matt Mackall
b784fcf1a7 ui: simplify init, kill dupconfig 2009-04-23 15:40:10 -05:00
Matt Mackall
371257fd73 ui: fold readsections into readconfig
readconfig now reads only single files
readconfig takes an optional list of sections
readconfig trusts files we're looking for sections in
2009-04-23 15:40:10 -05:00
Matt Mackall
c85f431ef9 ui: cleanup _is_trusted a bit 2009-04-23 15:40:10 -05:00
Matt Mackall
e2ffc933dc ui: simplify parent overlay logic 2009-04-23 15:40:10 -05:00
Matt Mackall
87a779b162 ui: always have ucdata
simplify readconfig logic
2009-04-23 15:40:10 -05:00
Matt Mackall
97699b4b90 ui: fold verbosity_constraints into fixconfig, simplify 2009-04-23 15:40:10 -05:00
Matt Mackall
0174734c46 ui: kill updateopts
Move setconfig into dispatch._parseconfig
2009-04-23 15:40:10 -05:00
Matt Mackall
ebffe5ccb8 ui: refactor option setting
No more passing options as constructor keywords. Basic options are now
always stored in the overlay for simplicity and consistency.
2009-04-23 15:40:10 -05:00
Matt Mackall
cc041814d1 ui: kill redundant call to verbosity_constraints 2009-04-23 15:40:10 -05:00
Matt Mackall
f21df2587f ui: always have an overlay 2009-04-23 15:40:10 -05:00
Matt Mackall
3243d007af ui: kill check_trusted 2009-04-23 15:40:10 -05:00
Matt Mackall
db4f571c07 ui: move _isatty near user 2009-04-23 15:40:10 -05:00
Steve Borho
6e4ca6d775 catch CTRL-D at password prompt
We caught this exception in ui.prompt(), but not here.  Without
this, hitting CTRL-D at the password prompt gives a long traceback.
2009-02-21 17:46:06 -06:00
Martin Geisler
bcc3bda9f7 lowercase prompts
The prompts are interactive and not meant for scripts.
2009-01-03 17:15:21 +01:00
Brendan Cully
8fa18a6932 Merge with crew-stable 2008-12-09 17:02:52 -08:00
Brendan Cully
3cfb5b4e74 issue1419: catch strange readline import error on windows 2008-12-09 17:01:14 -08:00
Benoit Boissinot
d954d76b97 use repr() instead of backticks 2008-12-06 14:27:31 +01:00
Peter Arrenbrecht
63d1bb911f ui: log non-interactive default response to stdout when verbose
This allows test scripts that feed their output into documentation
to properly show the session as it would appear to an end-user.
2008-11-07 10:27:39 +01:00
Benoit Boissinot
0c4a5ee0aa ui: add an option to prompt for the username when it isn't provided
When ui.askusername is set and not username are specified on the command line,
in hgrc or in the variables $HGUSER or $EMAIL, then hg will prompt for the
username.
Feature requested, and documentation provided by Mark Edgington.
2008-08-06 15:10:05 +02:00
Matt Mackall
a65ef7bc5d util: add sort helper 2008-06-27 18:28:45 -05:00
Matt Mackall
06bb84cfa6 ui: disallow newlines in usernames (issue1034) 2008-03-22 13:50:59 -05:00
Dirkjan Ochtman
ade2841b93 ui: copy overlay from both direct and indirect parentui 2008-03-20 22:46:35 +01:00
Matt Mackall
4794cecf39 pager: remove pager code from core 2008-03-20 11:12:35 -05:00
Peter Arrenbrecht
27b0107abf ui: make chuild ui feed output to parentui's active buffer 2008-03-20 11:12:35 -05:00
Alexis S. L. Carvalho
1c6d82d6fb two fixes for the pager stuff
- open pipe in binary mode

- don't start a pager if stdout is not a tty (this prevents test-ssh
  from hanging if you set ui.usepager=True in run-tests.py)
2008-03-19 16:54:35 -03:00
David Soria Parra
fba7246b03 Use the pager given by the environment to display long output
Unix systems usually have a PAGER environment variable set.
If it is set, mercurial will use the pager application to display
output.

Two configuration variables are available to influence the behaviour of the
pager. ui.pager sets the pager application. The pager is
only used if ui.usepager is true. By default ui.usepager is disabled.
2008-03-18 22:12:34 +01:00
Jesse Glick
b63e70848a Ensure that absolutized paths from hgrc do not contain ../ segments. 2008-01-08 22:40:51 -05:00