Commit Graph

261 Commits

Author SHA1 Message Date
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