Commit Graph

741 Commits

Author SHA1 Message Date
Nicolas Dumazet
7e56ad61ee merge with stable 2010-12-01 11:02:12 +09:00
Steve Borho
f938c786bf Merge with stable 2010-11-24 13:43:40 -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
1701ac1b51 util: clarify purpose of MBTextWrapper class
It's easy to get confused and scared of an Unicode monster when
skimming through this code: document that this is really just
about column-counting.
2010-11-09 13:43:35 +09:00
Matt Mackall
a3ff3a53e2 util: make wrap() require a width argument
This keeps hgweb's help engine from poking at file descriptors that
don't exist.
2010-10-10 18:02:52 -05:00
Augie Fackler
42c8b2cf07 termwidth: move to ui.ui from util 2010-10-10 10:06:36 -05:00
Patrick Mezard
9765952244 util: remove needbinary(), no longer used for external patching 2010-10-09 15:13:08 -05:00
Matt Mackall
51b3b09c8f backout most of 26e0b9a8ce0d 2010-09-24 12:46:54 -05:00
Brodie Rao
7362459729 cleanup: use x in (a, b) instead of x == a or x == b 2010-09-23 00:02:31 -05:00
Patrick Mezard
614db673f4 Merge with stable 2010-09-20 22:29:13 +02:00
Patrick Mezard
979ccf4590 Use lexists() instead of exists() where appropriate 2010-09-20 21:46:56 +02:00
Nicolas Dumazet
90787c08f9 util: get rid of extra trailing whitespace in parsedate abort message 2010-08-30 13:29:44 +09:00
Augie Fackler
d89ff49a61 parsebool: accept always as true and never as false 2010-08-30 10:28:25 -05:00
Augie Fackler
cb7412977d parsebool: create new function and use it for config parsing 2010-08-28 21:50:35 -05:00
Augie Fackler
a4e145ed4e util: clean up trailing whitespace 2010-08-28 21:49:53 -05:00
Martin Geisler
bad6437907 path_auditor: delegate checking of nested repos to a callback 2010-08-29 23:56:19 +02:00
Martin Geisler
3a252b7f3e util: use 'auditor' as consistent name for path auditors 2010-08-29 23:56:19 +02:00
Martin Geisler
4f7d586f86 util: add optional path auditor argument to canonpath
The canonpath function will default to creating its own path auditor,
but in some cases it will be useful to use a specialized auditor,
e.g., one that wont abort if a path lies within a subrepository.
2010-08-29 23:56:19 +02:00
Brodie Rao
d1905b7d87 mail/hgweb: support service names for ports (issue2350)
This adds util.getport(port) which tries to parse port as an int, and
failing that, looks it up using socket.getservbyname(). Thus, the
following will work:

    [smtp]
    port = submission

    [web]
    port = http

This does not apply to ports in URLs used in clone, pull, etc.
2010-08-28 12:31:07 -04:00
Sol Jerome
859b297e3f util: avoid using hashlib on Python < 2.5 (issue2278)
The following patch allows the use of python2.4 with a standalone
hashlib rather than assuming that python2.5 is in use when hashlib is
imported successfully.
2010-08-17 17:38:19 -05:00
Martin Geisler
bfea979db3 util: remove lexists, Python 2.4 introduced os.path.lexists 2010-08-25 16:23:32 +02:00
Steve Losh
b2ecd09159 util: add an interpolate() function to for replacing multiple values
util.interpolate can be used to replace multiple items in a string all at once
(and optionally apply a function to the replacement), without worrying about
recursing:

    >>> import util
    >>> s = '$foo, $spam'
    >>> util.interpolate(r'\$', { 'foo': 'bar', 'spam': 'eggs' }, s)
    'bar, eggs'
    >>> util.interpolate(r'\$', { 'foo': 'spam', 'spam': 'foo' }, s)
    'spam, foo'
    >>> util.interpolate(r'\$', { 'foo': 'spam', 'spam': 'foo' }, s, lambda s: s.upper())
    'SPAM, FOO'

The patch also changes filemerge.py to use this new function.
2010-08-18 18:18:26 -04:00
Sol Jerome
c9dfe23c62 util: avoid using hashlib on Python < 2.5 (issue2278)
The following patch allows the use of python2.4 with a standalone
hashlib rather than assuming that python2.5 is in use when hashlib is
imported successfully.
2010-08-17 17:38:19 -05:00
Matt Mackall
c0eb9c1315 Merge with stable 2010-08-06 12:59:13 -05:00
Matt Mackall
10293e99b9 chunkbuffer: use += rather than cStringIO to reduce memory footprint
This significantly refactors the read() loop to use a queue of chunks.
The queue is alternately filled to at least 256k and then emptied by
concatenating onto the output buffer.

For very large read sizes, += uses less memory because it can resize
the target string in place.
2010-08-06 12:18:33 -05:00
Benoit Boissinot
ccef97c636 chunkbuffer: split big strings directly in chunkbuffer 2010-07-25 13:10:57 +02:00
Benoit Boissinot
316c7a862b chunkbuffer: targetsize isn't used outside of read() 2010-07-24 17:23:08 +02:00
Benoit Boissinot
e344473c84 chunkbuffer: use list instead of cStringIO 2010-07-24 15:21:39 +02:00
Benoit Boissinot
8505039010 chunkbuffer: use for/else to detect end of iteration 2010-07-24 15:20:29 +02:00
Renato Cunha
43a9dd63ec util: use fakebuffer as buffer in py3k
There's no buffer type in py3k, util.py has a function, called
fakebuffer, that implements a similar API. This patch implements
fakebuffer as a memoryview wrapper in py3k.
2010-07-14 22:59:57 -03:00
Renato Cunha
937ac7ab4b util: improved the check for the existence of the 'buffer' builtin
2to3 is unable to translate '__builtin__' calls to 'builtins' when
hasattr is used (as in hasattr(__builtin__, buffer)). Translating the
check to the format

try:
    whatever
except NameError
    # define whatever
    __builtin__.whatever = whatever

is a correct way of checking for the name and has the benefit of being
translated by 2to3. This patch implements the same idea for the
aforementioned example.
2010-07-14 22:59:43 -03:00
Maxim Khitrov
1cf52a2e29 http: deliver hook output to client 2010-06-30 18:15:23 -05:00
FUJIWARA Katsunori
9cce255bec replace Python standard textwrap by MBCS sensitive one for i18n text
Mercurial has problem around text wrapping/filling in MBCS encoding
environment, because standard 'textwrap' module of Python can not
treat it correctly. It splits byte sequence for one character into two
lines.

According to unicode specification, "east asian width" classifies
characters into:

   W(ide), N(arrow), F(ull-width), H(alf-width), A(mbiguous)


W/N/F/H can be always recognized as 2/1/2/1 bytes in byte sequence,
but 'A' can not. Size of 'A' depends on language in which it is used.

Unicode specification says:

   If the context(= language) cannot be established reliably they
   should be treated as narrow characters by default

but many of class 'A' characters are full-width, at least, in Japanese
environment.

So, this patch treats class 'A' characters as full-width always for
safety wrapping.

This patch focuses only on MBCS safe-ness, not on writing/printing
rule strict wrapping for each languages

MBCS sensitive textwrap class is originally implemented
by ITO Nobuaki <daydream.trippers@gmail.com>.
2010-06-06 17:20:10 +09:00
Adrian Buehlmann
e782bd53a4 clone: print number of linked/copied files on --debug 2010-05-31 13:47:51 +02:00
Adrian Buehlmann
a5e4e78e6f util.copyfiles: don't try os_link() again if it failed before
If the os_link() call on the first file in the directory fails [1],
we switch mode to using shutil.copy() for all remaining files.

[1] happens for example on Windows for every file when cloning from a UNC
path without specifying --pull.
2010-05-28 17:28:34 +02:00
Yuya Nishihara
7c75e66e92 util: give appropriate default args to atomictempfile()
mode='w+b' is the default of python's TemporaryFile().
2010-05-21 19:54:40 +09:00
Patrick Mezard
d05da88022 Merge with crew-stable 2010-04-26 22:42:46 +02:00
Patrick Mezard
b7c02777e0 util: fix default termwidth() under Windows
sys.stdout.write('-'*80 + '\n')

or

  sys.stdout.write('-'*80 + '\r')

do not work on Windows as they do on unix. On a 80 columns Windows console, the
extra CR or LF are interpreted as if belonging to the next line, so the first
command displays 2 lines (only one on unix) and the second one leave the line
visible and move back to the following line. To avoid this, we sacrifice one
column under Windows.
2010-04-26 22:30:40 +02:00
Benoit Boissinot
18b2a0f2b6 merge with stable 2010-04-14 09:09:43 +02:00
Benoit Boissinot
1bad57968f checklink: use an explicit prefix for the temporary file 2010-04-14 08:48:26 +02:00
Benoit Boissinot
4e16e2221b merge with stable 2010-04-13 22:10:24 +02:00
Benoit Boissinot
293ba231eb checkexec: use an explicit prefix for the temporary file 2010-04-13 21:54:59 +02:00
Matt Mackall
c9d0f4131a Merge with stable 2010-03-30 13:09:25 -05:00
Ronny Pfannschmidt
45a62d091b util: fake the builtin buffer if it's missing (jython) 2010-03-23 11:36:19 +01:00
Augie Fackler
9105fced5e util.termwidth: check stderr first as it's least likely to be redirected 2010-03-15 14:53:34 -05:00
Steve Losh
0c8f350f3b util: use the built-in any() and all() methods if they are available 2010-02-16 09:31:35 -05:00
Steve Losh
6e5e6283eb util: add any() and all() functions for Python 2.4 compatibility
This patch adds these two very useful functions to the mercurial.util module,
because they are not present in Python 2.4.
2010-02-12 19:59:09 -05:00
Augie Fackler
59918314ce util: fix trailing whitespace found by check-code 2010-02-08 08:18:49 -06:00
Patrick Mezard
4b42e59a7a util: make spawndetached() handle subprocess early terminations
The file-based synchronization introduced by 670de588e29e hangs when the child
process fails before terminating the handshake, which the previous pipe-based
version handled correctly. To fix this, the parent polling loop was fixed to
detect premature terminations of the child process.
2010-02-06 16:50:00 +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
Patrick Mezard
052695b2e4 cmdutil: hide child window created by win32 spawndetached()
Hiding the child process window is not strictly necessary but it avoids opening
an empty shell window when running hg serve as well as a task in the task bar.
The window is hidden after the process is already started causing a single
flicker.
2010-01-10 18:13:34 +01:00
Patrick Mezard
48eee05938 Find right hg command for detached process
On Windows, Mercurial can be run from the python script of from a frozen
executable. In the first case, we have to call the python interpreter since the
script is not executable. Frozen executable can be called directly.

Fix 3/3 for issue421
2010-01-06 21:11:58 +01:00
Sune Foldager
0d1feca701 handle file URIs correctly, according to RFC 2396 (issue1153)
The new code aims to implement the RFC correctly for file URIs.
Previously they were handled incorrectly in several ways, which
could cause problem on Windows in particular.
2009-12-03 11:06:55 +01:00
Dirkjan Ochtman
c81462828e util: sort paths in walkrepos() (fixes test failures in test-hgwebdir) 2009-11-06 22:54:51 +01:00
Dirkjan Ochtman
12c5890a70 kill trailing whitespace 2009-11-05 10:44:36 +01:00
Nicolas Dumazet
3f248fed39 util: use sys.argv[0] if $HG is unset and 'hg' is not in PATH
This is necessary when the executable name is not 'hg'. For example,
if your system-wide mercurial is name 'hgs', sys.argv[0] is more
accurate than 'hg'.
2009-09-21 19:21:32 +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
Matt Mackall
20668220a1 Merge with -stable 2009-10-08 00:59:46 -05:00
Matt Mackall
daf9754427 Merge with -crew-stable 2009-10-07 23:25:41 -05:00
Adrian Buehlmann
db3cee7306 util: move rename into posix.py and windows.py 2009-10-07 20:32:07 +02:00
Adrian Buehlmann
d2944ad3db util: state docstring of rename more precisely 2009-10-07 20:16:43 +02:00
Adrian Buehlmann
692aa6b826 util.rename: do not abort if os.unlink fails (issue1840) 2009-10-06 10:45:23 +02:00
Steve Borho
7ec5773565 Merge with crew-stable 2009-10-06 16:08:38 -05:00
Matt Mackall
721ca9098c Fix for issue1848 2009-10-03 15:57:48 -05:00
Mads Kiilerich
097282895a util.system: Use subprocess instead of os.system
subprocess allows the environment and working directory to be specified
directly, so the hacks for making temporary changes while forking is no longer
necessary.

This also fixes failures on solaris where the temporary changes can't be undone
because there is no unsetenv.
2009-09-20 22:19:18 +02:00
Matt Mackall
3e6199cea0 Merge with -stable 2009-09-30 21:42:51 -05:00
Martin Geisler
3e05f2c2a8 ui: guard against UnicodeDecodeErrors in ui.wrap 2009-09-29 01:08:18 +02:00
Martin Geisler
72cc7c5356 util: do not corrupt multi-byte characters in wrap 2009-09-27 01:44:46 +02:00
Martin Geisler
42c594dc7e Merge with crew-stable 2009-09-27 09:38:53 +02:00
Martin Geisler
298efc8d54 util, minirst: do not crash with COLUMNS=0 2009-09-03 21:07:06 +02:00
Carey Evans
28b2e6acc5 util: Fix date format for 12-hour time. 2009-08-21 21:52:57 +12:00
Simon Heimberg
ffdea59f2d util: quicker fspath, do not lower names when the length is different 2009-07-29 14:21:18 +02:00
Nicolas Dumazet
6adbb3c99f util: canonpath: simplify logic
if root == os.sep, then endswithsep(root) is True as well: one test is enough
2009-08-22 15:47:03 +02:00
Patrick Mezard
a1609c7698 Merge with crew-stable 2009-08-23 13:03:10 +02:00
Matt Mackall
e3dc8aa6db fix memory usage of revlog caches by limiting cache size [issue1639] 2009-07-09 17:10:07 -05:00
Martin Geisler
2f4412b3b9 util: remove unused bufsize argument
Removed it correctly this time: the subprocess default is 0, not -1
and so we must pass -1 explicitly. Added a comment to that effect.
2009-07-09 11:59:18 +02:00
Bryan O'Sullivan
6ba3698e94 Merge backed out change 2009-07-08 17:03:16 -07:00
Bryan O'Sullivan
b467399b6f Backed out changeset 6a565336bae3: it caused a 5x performance regression on OS X 2009-07-08 17:01:18 -07:00
Martin Geisler
607267cbbc util: wrap at termwidth-2 by default 2009-07-16 23:25:25 +02:00
Simon Heimberg
4ba52122d6 util: use propertycache in opener instead of __getattr__ 2009-07-10 17:54:04 +02:00
Matt Mackall
eb6cba34d7 Merge with stable 2009-07-09 19:49:02 -05:00
Martin Geisler
a94a165c74 merge with crew-stable 2009-07-09 11:59:56 +02:00
Bryan O'Sullivan
c5ab2a3c14 Merge OS X performance regression fix 2009-07-08 17:03:50 -07:00
Alejandro Santos
3183e52503 compat: use // for integer division 2009-07-05 11:00:44 +02:00
Martin Geisler
a9670d9567 util: remove unused bufsize argument in popen[23] 2009-05-09 17:34:11 +02:00
Martin Geisler
e8bc5f4f01 util: remove ignored mode argument in popen[23] 2009-05-09 17:32:57 +02:00
Martin Geisler
1454ed1684 commands: wrap short descriptions in 'hg help'
The code for wrapping a single line of text with a hanging indent was
duplicated in commands and help -- it's now moved to a new function
called wrap in util.

The function defaults to a line width is 78 chars, and this un-wraps
some command line flag descriptions, hence the test output changes.
2009-06-24 19:15:58 +02:00
Benoit Boissinot
62eea686e0 atomictempfile: fix exception in __del__ if mktempcopy fails (self._fp is None)
Make what is going on more obvious by explicitely getting the 'closed'
attribute from _fp, instead of from the gettatr proxy.
2009-06-13 13:14:02 +02:00
Benoit Boissinot
125a85ec87 use new style classes 2009-06-10 15:10:21 +02:00
Martin Geisler
d8ad0f17b4 util: simplify range expression
The n index variable was unused. Every iteration would pop one element
off of parts, so the for loop can be replaced with a while loop.
2009-05-26 22:37:26 +02:00
Matt Mackall
a30eb02911 cmdutils: Take over glob expansion duties from util 2009-05-24 16:38:29 -05:00
Matt Mackall
f1f37a33cf match: move util match functions over 2009-05-24 02:56:14 -05:00
Matt Mackall
2658db5c8c util: privatize globre 2009-05-24 02:56:14 -05:00
Matt Mackall
b287cf72fe match: refactor patkind
add patkind(pat) to match
change external users
change util.patkind to _patsplit
2009-05-24 02:56:14 -05:00
Matt Mackall
532c58d931 match: change all users of util.matcher to match.match 2009-05-24 02:56:14 -05:00
Patrick Mezard
324692dc75 subrepo: force en_US.UTF-8 locale when calling svn
Parser only knows about en_US output. Forcing the encoding to UTF-8 might not
be the best thing to do since the caller may receive some of the subversion
output, but at least it should prevent conversion errors from svn client.
2010-01-02 16:42:00 +01:00
Patrick Mezard
a0b47f1b48 subrepo: normalize svn output line-endings 2010-01-02 16:03:25 +01:00
Martin Geisler
5b0900d7be util: use "is" for True/False/None comparisons 2009-05-20 10:50:23 +02:00
Simon Heimberg
e859b5a899 util: use set instead of dict 2009-05-19 09:57:06 +02:00
Bryan O'Sullivan
496cd5e84c util: make atomictempfile saner if mktempcopy fails 2009-05-14 14:12:32 -07:00
Peter Arrenbrecht
a75765cf7f drop unused imports 2009-05-14 15:35:46 +02:00
Bryan O'Sullivan
ff0948b137 util.termwidth: a file-like object may legitimately lack a fileno() method
Spotted in the wild when running a hook while pushing over HTTPS.
2009-05-11 11:53:27 -07:00
Bryan O'Sullivan
64e91f0ca1 atomictempfile: delegate to posixfile instead of inheriting from it 2009-03-26 13:12:11 -07:00
Simon Heimberg
09ac1e6c92 separate import lines from mercurial and general python modules 2009-04-28 17:40:46 +02:00
Simon Heimberg
f29f0db784 util: overwrite sha1 and _fastsha1 2009-05-08 09:59:15 +02:00
Martin Geisler
97b9a7a062 util: simplify pipefilter and avoid subprocess race
The subprocess module is not thread safe. Spawning a thread to read
the output leads to exceptions like this when Mercurial exits:

  Exception exceptions.TypeError: TypeError("'NoneType' object is not
  callable",) in <bound method Popen.__del__ of <subprocess.Popen
  object at 0x9ed0dcc>> ignored

The bug is already reported in the Python bug tracker:

  http://bugs.python.org/issue1731717
2009-05-07 01:33:44 +02:00
Matt Mackall
01454e7a1b util: kill unused Popen3 2009-05-04 14:22:33 -05:00
Martin Geisler
8fdb40802d util: stop overwriting sha1, overwrite _fastsha1 instead
Some modules (like revlog) would import util.sha1 as _sha1. This
defeats the purpose of having util.sha1 overwrite itself with a faster
version -- revlog would end up always calling the slow version. By
always delegating to util._fastsha1 we avoid this at the cost of an
extra (but unconditional) indirection.
2009-05-04 22:14:52 +02:00
Martin Geisler
6533e94352 util: remove md5
This hash function is broken and should not be used by new code. It is
currently only used by keepalive.
2009-05-04 21:30:39 +02:00
Sune Foldager
b19fc2c469 util: remove warnings when importing md5 and sha 2009-05-04 20:29:05 +02:00
Martin Geisler
21ba2e96f6 util: initialize md5 and sha1 without using extra global variables
This lets the functions skip the "if _sha1 is None" test on each call.
2009-05-03 00:03:35 +02:00
Martin Geisler
11190d5aaa util: always use subprocess 2009-05-02 23:05:35 +02:00
Patrick Mezard
695b5f0d5f Fix missing import from 4bea569e9933 merge 2009-04-30 08:38:20 +02:00
Patrick Mezard
0cdb05f6a7 Merge with crew-stable 2009-04-29 23:56:20 +02:00
Sune Foldager
2f3ee06863 util.rename: use temporary file name for rename-targets on windows
Use a temporary file name as target for a forced rename on Windows. The
target file name is not opened at any time; just renamed into and then
unlinked. Using a temporary instead of a static name is necessary since
otherwise a hg crash can leave the file lying around, blocking future
attempts at renaming.
2009-04-29 09:30:28 +02:00
Martin Geisler
2c8901a1b9 turn some comments back into module docstrings 2009-04-26 01:24:49 +02:00
Martin Geisler
8e4bc1e9ad put license and copyright info into comment blocks 2009-04-26 01:13:08 +02:00
Martin Geisler
750183bdad updated license to be explicit about GPL version 2 2009-04-26 01:08:54 +02:00
Matt Mackall
2f9b02c62d replace util.sort with sorted built-in
This is marginally faster for small and moderately-sized lists
2009-04-26 16:50:44 -05:00
Matt Mackall
9ec97bdefe util: take propertycache from context.py 2009-04-26 16:50:44 -05:00
Matt Mackall
8a63c10958 util: kill configparser wrapper 2009-04-26 16:50:43 -05:00
Martin Geisler
44aa7e92d1 util: use built-in set instead of util.unique 2009-04-22 00:56:06 +02:00
Martin Geisler
1deb417a82 util: use built-in set and frozenset
This drops Python 2.3 compatibility.
2009-04-22 00:55:32 +02:00
Martin Geisler
cc72b62ca4 util: return boolean result directly in util.binary 2009-04-22 17:14:58 +02:00
Dirkjan Ochtman
fe39d83f68 cleanup: remove all trailing whitespace 2009-03-23 13:11:11 +01:00
Matt Mackall
5871cdf2c8 audit: be even pickier (issue1450) 2009-03-04 17:02:16 -06:00
Sune Foldager
3fb25f365e util: don't overwrite os-specific functions with general ones 2009-04-04 18:12:43 +02:00
Justin Peng
d4938a90ee Correct a bug on date formats with '>' or '<' accompanied by space characters. 2009-04-01 09:11:00 -07:00
Matt Mackall
642f4d7151 move encoding bits from util to encoding
In addition to cleaning up util, this gets rid of some circular dependencies.
2009-04-03 14:51:48 -05:00
Matt Mackall
2cddde0437 move util.Abort to error.py 2009-04-03 13:20:52 -05:00
Steve Borho
67420334f3 windows: hoist expand_glob() back into util.py
The windows version of expand_glob() requires patkind(). To
avoid a circular dependency, move function back into util.py.
2009-03-26 22:07:01 -05:00
Matt Mackall
0952760f82 util: split out posix, windows, and win32 modules 2009-03-26 13:54:44 -05:00
Alexander Solovyov
475ce753d3 templater: ability to display diffstat for log-like commands 2009-03-23 10:41:42 +01:00
Peter Arrenbrecht
19591b6a8c cleanup: drop unused assignments 2009-03-23 13:13:06 +01:00
Matt Mackall
7c27807553 audit: check for casefolding of .hg (issue1450) 2009-02-16 17:37:23 -06:00
Matt Mackall
f547c37df5 rename: simplify forced renaming
This should help work around virus scanner issues with rename on Windows.
2009-02-16 17:37:23 -06:00
Will Maier
fbbafcd5d7 Use shutil.copystat in copyfile(). 2009-02-09 07:55:42 -06:00
Mads Kiilerich
d775f5aa2a Make util.find_exe alway returns existing file, fixing issue1459
It seems like the old behaviour with different handling for commands with and
without path was intended, but I think this behaviour of util.find_exe is
better:
* Always returns existing file
* or None if command not found - no default
* Windows: Returned file thus always ends with extension from PATHEXT

This fixes http://www.selenic.com/mercurial/bts/issue1459. The change might
fix other unintended behaviour too.
2009-01-25 21:20:13 +01:00
Matt Mackall
6a6762635c simplify colwidth a bit 2009-01-23 14:51:09 -06:00
Shun-ichi GOTO
fccc1f5345 Also find correct column width of wide characters.
Use unicodedata.east_asian_width() to determine wide/full width
characters if available. Otherwise, return character count as before.
2009-01-21 20:29:47 +09:00
Matt Mackall
104a85dee5 error: move SignatureError 2009-01-12 13:51:43 -06:00
Matt Mackall
7f3bf9b19d error: move SignalInterrupt
now derived from KeyboardInterrupt to simplify catches
2009-01-12 11:48:05 -06:00
Matt Mackall
534da54d07 error: move UnexpectedOutput (now ResponseError) 2009-01-12 11:28:28 -06:00
Matt Mackall
356502607f refactor version code
- simplify version detection code
- move detection code into setup.py
- move version reading function into util.py
- drop version.py code

This makes hg more closely follow its own recommendation of how to deal with
versioning your builds: use hg id in your build script.
2009-01-10 18:02:38 -06:00
Matt Mackall
a25d874c56 Merge with -stable 2008-12-31 18:00:35 -06:00
Matt Mackall
71a02e35c5 audit: reject paths with .hg (issue 1450)
Spotted by Peter Arrenbrecht
2008-12-31 16:27:20 -06:00
Alexander Solovyov
c1774bb6c3 python implementation of diffstat
Implemented as two functions: diffstat, which yields lines of text,
formatted as a usual diffstat output, and diffstatdata, which is called
inside diffstat to do real performing and yield file names with
appropriate data (numbers of added and removed lines).
2008-12-25 10:48:24 +02:00
Dirkjan Ochtman
265b2d6c5c merge with crew-stable 2008-12-19 18:49:02 +01:00
Dirkjan Ochtman
600f058f30 hgweb: mq repos should be in non-recursive collections, too 2008-12-19 18:24:49 +01:00
Dirkjan Ochtman
8215a72dd6 merge with crew-stable 2008-12-19 08:20:19 +01:00
Benoit Allard
6edf6273f0 hgweb: recurse down collections only if ** in [paths]
collections: direct child repos only
paths *: direct child repos only (like collections)
paths **: recursive discovery

When ** is used, the mq repository (if any) is also shown.
2008-12-18 22:32:48 +01:00
Patrick Mezard
42823196e7 Merge with crew-stable 2008-12-10 00:29:10 +01:00
Patrick Mezard
1ab0600f40 util: disable walkrepo() recursive behaviour
Revert b1aea76f700 and c6d3b233571e for performances reasons. Traversing
checkout working directories may be too expensive.
2008-12-10 00:16:12 +01:00
Benoit Boissinot
de1bbc2aa9 exceptions should inherit the Exception class 2008-12-06 15:53:57 +01:00
Matt Mackall
013115d873 encoding: normalize some silly encoding names 2008-12-02 13:05:40 -06:00
Mads Kiilerich
f97a1f6cd5 util: use existing never() instead of custom lambda 2008-11-27 00:57:32 +01:00
Matt Mackall
c163f654f6 Merge with crew 2008-11-25 16:24:22 -06:00
Matt Mackall
648df6f0b1 dispatch: generalize signature checking for extension command wrapping 2008-11-18 16:02:14 -06:00
Brendan Cully
f4cee1477f templater: return data in increasing chunk sizes
Currently hgweb is not streaming its output -- it accumulates the
entire response before sending it. This patch restores streaming
behaviour. To avoid having to synchronously write many tiny fragments,
this patch also adds buffering to the template generator. Local
testing of a fetch of a 100,000 line file with wget produces a slight
slowdown overall (up from 6.5 seconds to 7.2 seconds), but instead of
waiting 6 seconds for headers to arrive, output begins immediately.
2008-11-21 15:51:40 -08:00
Patrick Mezard
2e3aa68a1d Fix util._statfiles_clustered() failing at root of a windows drive
Report and initial fix by Andrei Vermel <avermel@mail.ru>.
2008-11-01 15:15:14 +03:00
Benoit Boissinot
214af7ec3c factor out the url handling from httprepo
Create url.py to handle all the url handling:
- proxy handling
- workaround various python bugs
- handle username/password embedded in the url
2008-10-27 21:50:01 +01:00
Benoit Allard
31ab3aeaed hgwebdir: show nested repositories (issue1336) 2008-10-22 18:23:32 +02:00
Thomas Arendsen Hein
593bff360d Add util.popen3 fallback, simplify import of Popen3 2008-10-19 12:19:55 +02:00
Thomas Arendsen Hein
b7ce96daba Fix util.popen2 for Python 2.3
1. trigger ImportError early, so fallbacks are activated
2. util.popen2 replaces previous usage of os.popen2, not popen2.popen2
2008-10-19 12:13:25 +02:00
Patrick Mezard
45970973da util: handle EINVAL in _statfiles_clustered()
Raised when osutil.listdir is called on a non-directory entry.
2008-10-18 20:50:08 +02:00
Patrick Mezard
f7eb935395 util: subprocess close_fds option is unix only 2008-10-18 15:49:15 +02:00
Petr Kodl
681e2c1a41 Take advantage of fstat calls clustering per directory if OS support it.
util module implements two versions of statfiles function

_statfiles calls lstat per file

_statfiles_clustered takes advantage of optimizations in osutil.c, stats all
files in directory at once when new directory is hit and caches the results

util.statfiles dispatches to appropriate version during module loading

The speedup on directory tree with 2k directories and 63k files is about
factor of 1.8 (1.3s -> 0.8s for hg diff - hg startup overhead about .2s)

At this point only Win32 now benefit from this patch.
Rest of OSes use the non clustered implementation.
2008-10-09 10:29:47 -04:00
Dirkjan Ochtman
67bd09df5b python2.6: use subprocess if available 2008-10-05 21:35:26 +02:00
Dirkjan Ochtman
6b51480caa merge with crew-stable 2008-08-12 17:47:08 +02:00
Matt Mackall
bfc02d4c70 util: set_flags should survive failure to create link 2008-08-10 21:55:23 -05:00
Matt Mackall
e03f4e2f73 util: set_flags shouldn't know about repo flag formats 2008-08-10 21:55:06 -05:00
Adrian Buehlmann
34afc460b4 move filename encoding functions from util.py to new store.py 2008-07-24 16:32:51 +02:00
Benoit Boissinot
664b2fafe8 merge with -stable 2008-07-23 16:14:45 +02:00
Benoit Boissinot
9d636a4b09 make mq and tags hardlink safe
The code didn't check for modes like "r+" or "rb+".
Many thanks to agriffis for noticing it.
2008-07-23 16:08:20 +02:00
Matt Mackall
a65ef7bc5d util: add sort helper 2008-06-27 18:28:45 -05:00
Matt Mackall
b2155285a8 rename checkfolding to checkcase 2008-06-26 13:58:24 -05:00
Matt Mackall
d462e1fc26 simplify flag handling
add _checklink var to dirstate
introduce dirstate.flagfunc
switch users of util.execfunc/linkfunc to flagfunc
change manifestdict.set to take a flags string
change ctx.fileflags to ctx.flags
change gitmode func to a dict
remove util.execfunc/linkfunc
2008-06-26 13:46:34 -05:00
Paul Moore
c966bce328 Add a new function, fspath
The function, given a relative filename and a root, returns the filename
modified to use the case actually stored in the filesystem (or None if the
file does not exist). The returned name is relative to the root, but retains
the path separators used in the input path. (This is not strictly necessary,
but retaining the path separators minimises misleading test suite failures).

A win32-specific implementation (using win32api.FindFiles) is possible, but it
has not been implemented as testing seems to demonstrate that the
win32-specific code is not significantly faster (thanks to the caching of
results in the generic code).
2008-06-06 19:23:23 +01:00
Matt Mackall
b74465983b remove default arg from patkind 2008-05-12 11:37:08 -05:00
Matt Mackall
fd009cd512 walk: kill util.cmdmatcher and _matcher 2008-05-12 11:37:07 -05:00
Dirkjan Ochtman
2f149e4634 replace usage of os.popen() with util.popen()
To make this possible, I added a mode parameter to both implementations of
util.popen(), defaulting to 'r' (as it does in the Python stdlib).
2008-04-14 14:34:38 +02:00
Christian Ebert
af73383537 Let util.binary check entire data for \0 (issue1066, issue1079) 2008-04-08 13:19:36 +02:00
Bryan O'Sullivan
8250520fe1 Merge 2008-04-09 15:28:30 -07:00
Bryan O'Sullivan
6ab8739d08 Tidy code, fix typo 2008-04-09 15:27:57 -07:00
Dirkjan Ochtman
34d6bea8db python 2.6 compatibility: compatibility wrappers for hash functions 2008-04-04 22:36:40 +02:00
Patrick Mezard
a8a4885e0a util: check fileno() validity in win32 set_binary() 2008-03-21 21:56:55 +01:00
Patrick Mezard
9672ec918b util: test fileno() availability in win32 set_binary()
Fix suggested by Alexander Belchenko <bialix@ukr.net>
2008-03-20 22:41:40 +01:00
Eric Hopper
63836614e1 hgwebdir: Tiny fix for webdir on non-symlink capable platforms. 2008-03-17 12:40:02 -07:00
Eric Hopper
0a50218866 Allow hgwebdir collections to follow symlinks. 2008-03-15 12:42:34 -07:00
Eric Hopper
798a7f0917 Check for patches repo with os.path.isdir not os.path.exists 2008-03-02 08:51:02 -08:00
Matt Mackall
44c538327c dates: Fix bare times to be relative to "today" 2008-03-11 17:42:51 -05:00
Matt Mackall
555abf8390 dates: improve timezone handling
datestr:
- add format specifiers %1 and %2 for timezone hours and minutes
- remove timezone and timezone format options
- correctly find timezone hours and minutes for fractional and negative timezones
- update users

strdate:
- correctly find timezone hours and minutes for fractional and negative timezones
2008-03-11 17:42:41 -05:00
Matt Mackall
309ee9f391 dates: fix fractional timezone display rounding bug 2008-03-10 02:54:37 -05:00
Joel Rosdahl
4f8012378a Remove unused imports 2008-03-06 22:23:41 +01:00
Peter Arrenbrecht
7f8994bad6 util: make walkrepos() return .hg/patches if present 2008-02-21 20:56:06 +01:00
Stefan Rank
e62243ce74 Also search for .hgrc if mercurial.ini not found on windows 2008-02-20 21:31:42 +01:00
Paul Moore ext:(%22)
2c78824696 Added hgexecutable support for py2exe/frozen scripts 2007-12-20 20:02:51 +00:00
Matt Mackall
ebf85d18e1 util: get rid of is_win_9x wart 2007-12-18 14:01:42 -06:00
Shun-ichi GOTO
903870798f Workaround for "Not enough space" error due to the bug of Windows.
Large write requests fail when stdout is switched to binary mode.
As a workaround, limit the data size to write once.
2007-12-14 16:47:41 +01:00
Steve Borho
dafb712d34 fix typo in sshargs
the original typo dated back to early 2005
2007-12-13 14:25:51 -06:00
Steve Borho
caa5fee772 win32: fix ssh://host:port when using Plink
Moves ssh argument building to platform specific utils code.
The win32 version looks for plink in ssh command string and
uses '-P' in lieu of '-p' for specifying a port
2007-12-12 16:44:26 -06:00
Manuel Holtgrewe
4a33cb8d98 Do not display passwords with pull/push/incoming/outgoing
Passwords specified in the repository URL are now displayed as '***'
when accessing the remote repository.
2007-11-05 20:29:32 +01:00
Maxim Dounin
8561d688a1 Fix file-changed-to-dir and dir-to-file commits (issue660).
Allow adding to dirstate files that clash with previously existing
but marked for removal. Protect from reintroducing clashes by revert.

This change doesn't address related issues with update. Current
workaround is to do "clean" update by manually removing conflicting
files/dirs from working directory.
2007-11-05 20:05:44 +03:00
Patrick Mezard
6aa1e21320 Fix Windows os.popen bug with interleaved stdout/stderr output
See python bug 1366 "popen spawned process may not write to stdout under windows" for more details.
2007-11-01 12:05:14 +01:00
Walter Doerwald
c1832411b0 Simplify utils.walkrepos(). 2007-08-28 18:00:07 +02:00
Thomas Arendsen Hein
a1c1677af4 Fix bad behaviour when specifying an invalid date (issue700)
commit (aborts _after_ typing in a commit message)
backout (aborted after the initial revert)
tag (edited .hgtags and couldn't commit)
import (patch applied, then commit fails)
qnew (aborts on bad dates, but writes any valid date into the # Date header)
qrefresh (like qnew)
sign (like tag)
fetch (merge, merge, merge, merge, abort)
2008-02-17 21:34:28 +01:00
Thomas Arendsen Hein
48cd266d6d merge with crew 2008-02-16 13:34:11 +01:00
Thomas Arendsen Hein
728ba019da Make annotae/grep print short dates with -q/--quiet.
Move shortdate() from templatefilters to util to avoid code duplication.
2008-02-16 13:33:38 +01:00
Patrick Mezard
5d1baa1a2e util: always define a dummy lookup_reg() 2008-02-13 23:09:28 +01:00
Alexis S. L. Carvalho
38c9e04993 util.pathto: return '.' instead of an empty string
This could happen with something like
pathto(repo.root, 'foo/bar', 'foo/bar')
2008-02-15 10:38:37 -02:00
Thomas Arendsen Hein
3d8e3d2b46 merge with main 2008-02-14 00:13:20 +01:00
Dirkjan Ochtman
5df65fdd07 better handle errors with date parsing (issue983)
Windows cannot always handle a 1970-01-01 parameter to time.mktime().
2008-02-13 16:46:43 +01:00
Alexis S. L. Carvalho
918227be30 Make files in .hg inherit the permissions from .hg/store 2008-02-09 18:38:54 -02:00
Matt Mackall
7fb82b40e9 ignore: split up huge patterns
Some versions of Python silently mishandle large regexes, so split
them up at a conservative 20k.
2008-02-11 16:13:43 -06:00
Matt Mackall
ad1e6058b9 filemerge: add config item for GUI tools
<tool>.gui indicates whether a tool requires a GUI to run
2008-02-03 19:29:05 -06:00
Matt Mackall
2c7d69802c merge: add registry look up bits to tool search 2008-02-03 19:29:05 -06:00
Matt Mackall
a849fab9e4 templater: move email function to util 2008-01-31 14:44:19 -06:00
Jesse Glick
e01183da16 Permit glob patterns to use nested curly braces. 2008-01-25 15:54:25 -05:00
Thomas Arendsen Hein
ddce807d45 merge with crew-stable 2008-01-22 00:55:01 +01:00
Thomas Arendsen Hein
133747d109 Fix double import of 're'. 2008-01-21 22:00:44 +01:00
Shun-ichi GOTO
da69eb2702 Fix not to use os.sep directly.
This change is intended for MBCS support.
2008-01-09 21:30:37 +09:00
Shun-ichi GOTO
fa59648c70 Add util.splitpath() and use it instead of using os.sep directly.
This change is intended to allow hooking splitpath() by win32mbcs
extension for MBCS support.
2008-01-09 21:30:36 +09:00
Shun-ichi GOTO
188e44cf4b Add endswithsep() and use it instead of using os.sep and os.altsep directly.
This change is intended to allow hooking endswithsep() by win32mbcs
extension for MBCS support.
2008-01-09 21:30:35 +09:00
Bryan O'Sullivan
5b8903b6d7 util: drop params added during experimentation 2008-01-04 13:56:31 -08:00
Bryan O'Sullivan
497bf2ca7a fetch: hide authentication details 2008-01-04 11:58:27 -08:00
Thomas Arendsen Hein
347da85c36 Removed tabs and trailing whitespace in python files 2007-12-29 19:49:48 +01:00
Patrick Mezard
db911b9d0f util: filter all st_mode with 0777 in checkexec 2007-12-29 01:14:45 +01:00
Matt Mackall
b35a91a7c0 util: simplify unique 2007-12-27 23:55:40 -06:00
Thomas Arendsen Hein
462c1975db Fix chmod of writable but unowned files (issue530)
This could happen e.g. in group writable local repositories where a file
should become executable on update.

(Patch by Benoit Boissinot attached to issue530)
2007-12-25 14:05:26 +01:00
Matt Mackall
c9efd52e9e util: simplify unique 2007-12-27 23:55:40 -06:00
Matt Mackall
50455803c5 remove unused util.localsub function 2007-12-27 23:55:40 -06:00
Matt Mackall
1baaf41264 atomictempfile: avoid chmod weirdness on Linux vfat 2007-12-27 23:55:40 -06:00
Matt Mackall
bdea7ebd1b checkexec: fix VFAT tempfile droppings with more modern Linux kernels
More recent Linux kernels don't pretend to allow any bogus chmods on
VFAT.
2007-12-27 23:55:40 -06:00
Matt Mackall
614e20b215 util: remove set_exec and set_link methods 2007-12-27 22:47:41 -06:00
Matt Mackall
717ff7e6f8 util: add new set_flags method
This is more efficient than calling set_link and set_exec
2007-12-27 22:27:45 -06:00
Thomas Arendsen Hein
b29abebc1e merge with crew-stable 2007-12-25 14:30:10 +01:00
Benoit Boissinot
c5049e31fc explicitely use integer division 2007-10-11 16:19:12 +02:00
Matt Mackall
0804290ab7 revlog: fix caching of buffer objects 2007-10-11 00:46:53 -05:00
Matt Mackall
8a3a3e49fe chunkiter: handle large reads more efficiently
- for large reads, don't attempt to read more than necessary
- if we've gathered the exact number of bytes needed, avoid a string copy
2007-10-11 00:46:52 -05:00
Matt Mackall
d3f1e8a8cf chunkiter: simplify iter logic 2007-10-11 00:46:49 -05:00
Matt Mackall
614d4b8b33 chunkbuffer: removed unused method and arg 2007-10-11 00:46:48 -05:00
Rafael Villar Burke
1b278771bf Execution bit detection fixes for VFAT on Linux
On Linux VFAT execution mode can be modified, but changes don't
persist a filesy stem remount. The current test can be trickled by
this. We can help with the det ection of VFAT checking whether new
files get created with the execution bits on
 (as usually these partitions are mounted with the exec option, for
convenience)
.
2007-10-05 01:52:53 +02:00
Bryan O'Sullivan
e317f81ab3 Add osutil module, containing a listdir function.
This is similar to os.listdir, only it returns a sorted list of tuples.
2007-10-05 15:01:06 -07:00
Bryan O'Sullivan
5e33599d0f Merge with crew. 2007-10-02 13:49:36 -07:00
Bryan O'Sullivan
65b17f114c util: add default argument to strdate 2007-10-02 13:46:59 -07:00
Benoit Boissinot
7cf891935c merge with -stable 2007-10-02 20:25:35 +02:00
Steve Borho
9f12241241 set_exec: do not chmod a symlink 2007-10-02 20:22:33 +02:00
Patrick Mezard
7c1d0710ee Merge with crew-stable 2007-09-10 23:53:23 +02:00