Commit Graph

273 Commits

Author SHA1 Message Date
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
Kirill Smelkov
cbdc1f53db prompt: kill matchflags
Python already lets one to embed RE flags directly in a regex, which
is a much nicer way to do things:

(?iLmsux)
        (One or more letters from the set "i", "L", "m", "s", "u", "x".)
        ...

matchflags was introduced in 14a7e862c60f, and the record extension is the only
user. I've killed matchflag, and adjusted record code appropriately.
2007-12-28 00:03:55 -06:00
Matt Mackall
faa2e2041c ui: allow default when prompting 2007-12-27 22:49:01 -06:00
Thomas Arendsen Hein
d02cbcaa88 merge with crew-stable 2007-12-27 13:39:59 +01:00
Thomas Arendsen Hein
0a782ae200 Make ui.prompt repeat on "unrecognized response" again (issue897)
(this was accidentally changed in 18945c2eb022)
2007-12-27 10:32:33 +01:00
Osku Salerma
7f9d71b715 Use VISUAL in addition to EDITOR when choosing the editor to use. 2007-12-05 20:40:01 +09:00
Steve Borho
465647eece workaround for raw_input() on Windows
Since change 0f20f68c768c, Mercurial has set_binary() on stdin, stdout, and stderr.
On Windows, this had the side effect of causing raw_input() to emit trailing carriage
returns on it's returned strings.  This was causing web authentication problems.
2007-12-03 17:28:26 -06:00
Dirkjan Ochtman
7b9cb3b6fc Don't try to determine interactivity if ui() called with interactive=False.
WSGI applications are not supposed to refer to sys.stdin. In af5aceab19f4,
hgweb and hgwebdir were fixed to pass interactive=False to their ui()'s, but
sys.stdin.isatty() was still called by the ui objects. This change makes sure
only the ui.fixconfig() method will call ui.isatty() (by making the
ui._readline() method, which is currently only called from ui.prompt(),
private). ui.fixconfig() is changed to let config files override the initial
interactivity setting, but not check isatty() if interactive=False was
specified in the creation of the ui.
2007-09-25 19:05:34 +02:00
Bryan O'Sullivan
46880a1c4f record: improve docs, improve prompts 2007-08-09 17:29:16 -07:00
Thomas Arendsen Hein
e05f361209 os.isatty isn't available on Windows, so use sys.stdin.isatty() 2007-08-01 10:33:21 +02:00
Bryan O'Sullivan
80c88dabf8 ui: get readline and prompt to behave better depending on interactivity 2007-07-31 16:28:05 -07:00
Thomas Arendsen Hein
c6d47ef08c Catch illegal boolean values in hgrc nicely.
With hg 0.9.3 the section and parameter name wasn't printed,
with hg 0.9.4 there was a traceback for ValueError.
2007-06-26 20:37:15 +02:00
Thomas Arendsen Hein
61d51838df New config option: ui.report_untrusted (defaults to True) 2007-06-25 22:41:15 +02:00
Thomas Arendsen Hein
4d29c6dc8e Updated copyright notices and add "and others" to "hg version" 2007-06-19 08:51:34 +02:00
Thomas Arendsen Hein
483231d996 Cleanup of whitespace, indentation and line continuation. 2007-06-19 08:06:37 +02:00
Matt Mackall
b99ae11550 dirstate: pull ignore smarts out of ui 2007-06-18 13:24:34 -05:00
Matt Mackall
cdeb6ec2da extensions: kill ui readhooks
Move .hgrc extension loading into localrepo
2007-06-18 13:24:34 -05:00
Matt Mackall
8395ca26f3 extensions: pull extension-aware bits out of ui 2007-06-18 13:24:34 -05:00
Patrick Mezard
a55efff966 ui: make readsections() abort when configuration cannot be read. 2007-06-03 22:11:25 +02:00
Bryan O'Sullivan
ebb57c99be ui: Rename has_config to has_section. 2007-05-27 13:50:59 -07:00
Matt Mackall
04561e556e revlog: simplify revlog version handling
- pass the default version as an attribute on the opener
- eliminate config option mess
2007-03-22 19:52:38 -05:00
Thomas Arendsen Hein
c019d21898 merge with crew-stable 2007-03-14 22:43:57 +01:00
Thomas Arendsen Hein
678e517eae Only hg repositories override [paths], not simple directories (fixes issue510) 2007-03-14 22:38:40 +01:00
Thomas Arendsen Hein
1be2af280f Abort on empty username so specifying a username can be forced.
This behaviour was introduced by d5601ef79d86 and broken by c608116532fe.
Added test for this.
2007-01-24 23:04:51 +01:00
Alexis S. L. Carvalho
6dc09d1834 Fix hg showconfig traceback with values that aren't strings 2007-02-15 10:15:08 -02:00
Thomas Arendsen Hein
f599c21b8e merge with stable 2007-01-24 23:07:09 +01:00
Patrick Mezard
784a42ef92 Flush stderr after write.
stderr can be buffered under win32 when redirected to a file,
including stdout.
2007-01-10 20:35:27 +01:00