Commit Graph

31275 Commits

Author SHA1 Message Date
Gregory Szorc
becdf838b6 parsers: use Python memory allocator in commonancestorsheads() 2017-03-09 12:02:59 -08:00
Gregory Szorc
5deb9bd0a7 osutil: use Python memory allocator in _listdir
The Python memory allocator has performance advantages
for small allocations.
2017-03-09 11:56:47 -08:00
Gregory Szorc
68f48d2e6f bdiff: use Python memory allocator in fixws
Python has its own memory allocation APIs. For allocations
<= 512 bytes, it allocates memory from arenas. This means that
average small allocations don't call the system allocator, which
makes them faster. Also, arena allocations cut down on memory
fragmentation, which can matter for performance in long-running
processes.

Another advantage of using the Python memory allocator is that
allocations are tracked by Python. This is a bigger deal in
Python 3, as modern versions of Python have some decent built-in
tools for examining memory usage, leaks, etc.

This patch converts a trivial malloc() + free() in the bdiff code
to use the Python allocator APIs. Since the object being
operated on is a line, chances are it will use an arena. So,
this could have a net positive impact on performance (although
I didn't measure it).
2017-03-09 11:54:25 -08:00
Pierre-Yves David
3248bb0252 localrepo: fix deprecation warning version of wfile
The patch lingered a bit too long in my local clone and I messed up when I
updated the version number. Since nobody caught it, I'm fixing the version after
the fact.
2017-03-16 11:17:55 -07:00
Pierre-Yves David
fc2b521909 util: explicitly tests for None
Changeset 3b9cdb72931f removed the mutable default value, but did not explicitly
tested for None. Such implicit checking can introduce semantic and performance
issue. We move to an explicit check for None as recommended by PEP8:

https://www.python.org/dev/peps/pep-0008/#programming-recommendations
2017-03-15 15:07:14 -07:00
Pierre-Yves David
8561a8e8ff context: simplify call to icase matcher in 'match()'
The two function takes the very same arguments. We make this clearer and less
error prone by dispatching on the function only and having a single call point
in the code.
2017-03-15 15:38:02 -07:00
Pulkit Goyal
73e25e061d py3: make sure using bytes status char rather than ascii values
'MAR!?IC' is converted to their ascii values when slicing through it. This
patch uses pycompat.iterbytestr() to get bytes value.
2017-03-16 09:13:13 +05:30
Jun Wu
9ab84eb3ce shelve: get rid of ui.backupconfig 2017-03-16 14:27:41 -07:00
Jun Wu
bef3efe46f rebase: get rid of ui.backupconfig 2017-03-16 14:40:34 -07:00
Jun Wu
96f89b96ad mq: get rid of ui.backupconfig 2017-03-16 14:39:18 -07:00
Jun Wu
d49afd55dd histedit: get rid of ui.backupconfig 2017-03-16 14:36:35 -07:00
Jun Wu
436e791f48 record: get rid of ui.backupconfig 2017-03-16 14:34:35 -07:00
Jun Wu
e7a5a37c7c import: get rid of ui.backupconfig 2017-03-16 14:23:49 -07:00
Jun Wu
e7394336ca clone: get rid of ui.backupconfig 2017-03-16 14:18:50 -07:00
Jun Wu
a1b35a50eb commit: get rid of ui.backupconfig 2017-03-16 14:15:20 -07:00
Durham Goode
2e0dd44c19 branchmap: handle nullrev in setcachedata
906be86990 recently changed to switch from:

  self._rbcrevs[rbcrevidx:rbcrevidx + _rbcrecsize] = rec

to

  pack_into(_rbcrecfmt, self._rbcrevs, rbcrevidx, node, branchidx)

This causes an exception if rbcrevidx is -1 (i.e. the nullrev). The old code
handled this because python handles out of bound sets to arrays gracefully. The
new code throws because the self._rbcrevs buffer isn't long enough to write 8
bytes to.  Normally it would've been resized by the immediately preceding line,
but because the 0 length buffer is greater than the idx (-1) times the size, no
resize happens.

Setting the branch for the nullrev doesn't make sense anyway, so let's skip it.
This was caught by external tests in the Facebook extensions repo, but I've
added a test here that catches the issue.
2017-03-15 15:48:57 -07:00
Yuya Nishihara
4744dd2998 py3: call codecs.escape_encode() directly
string_escape doesn't exist on Python 3, but fortunately the undocumented
codecs.escape_encode() function exists on CPython 2.6, 2.7, 3.5 and PyPy 5.6.
So let's use it for now.

http://stackoverflow.com/a/23151714
2017-03-15 23:28:39 +09:00
Yuya Nishihara
5ce2afb81d templatekw: make join() escape values of extras (BC) (issue5504)
Since extras may contain blob, the default template escapes its values:

  'extra': '{key}={value|stringescape}'

join() should follow the output style of the default template.
2017-03-15 23:21:30 +09:00
Yuya Nishihara
02022fc3c5 util: wrap s.encode('string_escape') call for future py3 compatibility 2017-03-15 23:06:50 +09:00
Yuya Nishihara
faf4fbd798 py3: prove hg tip works 2017-03-13 09:24:53 -07:00
Yuya Nishihara
99a868d61d py3: call strftime() with native str type
Since strftime() may contain non-ascii character if locale set, we use
strfrom/tolocal().

Now "hg tip" works.
2017-03-13 09:19:07 -07:00
Yuya Nishihara
af7f25fdb3 encoding: add converter between native str and byte string
This kind of encoding conversion is unavoidable on Python 3.
2017-03-13 09:12:56 -07:00
Yuya Nishihara
dcade16cf7 encoding: factor out unicode variants of from/tolocal()
Unfortunately, these functions will be commonly used on Python 3.
2017-03-13 09:11:08 -07:00
Yuya Nishihara
ec012a1a69 py3: use next() to obtain next item from inner generator of generatorset
.next attribute does not exist on Python 3. As this function seems to really
care about the overhead of the Python interpreter, I follow the way of micro
optimization.
2017-03-13 08:53:31 -07:00
Yuya Nishihara
02b9a6d074 py3: rewrite itervalues() as values() by importer
I'm not a great fan of these importer magics, but this should be okay since
"itervalues" seems as unique name as "iteritems".
2017-03-13 08:44:57 -07:00
Yuya Nishihara
fad2547154 py3: use portable way to stringify cache key of repoview 2017-03-12 17:20:42 -07:00
Kostia Balytskyi
688382aced exewrapper: prefer HackableMercurial python if availbale
Currently hg.exe will only try to load python27.dll from hg-python
subdir if PYTHONHOME environment variable is not set. I think that
it is better to check whether 'hg-python' subdir exists and load
python from it in that case, regardless of environment. This allows
for reliable approach of distributing Mercurial with its own Python.
2017-03-13 12:44:13 -07:00
Pierre-Yves David
56371ac490 import-checkers: split tests of the tool from running it on the source
We did such splits for other tools already. The 'test-check-*.t' performs the
check of the source code while the regular tests verifies the tools works.

One of the benefit is that is provides a simple file to reuse in third party
extensions.
2017-03-14 23:07:08 -07:00
Yuya Nishihara
eea0ef4b6e py3: use bytestr wrapper in revsetlang.tokenize()
This backs out a2d8ce9531e1 and wraps program by bytestr() instead.
2017-03-16 21:36:21 +09:00
Yuya Nishihara
a665b1ac40 py3: use bytestr wrapper in revsetlang.formatspec()
This backs out e6d1d689544f and wraps expr by bytestr() instead.
2017-03-16 21:33:25 +09:00
Yuya Nishihara
791afb08eb pycompat: add bytestr wrapper which mostly acts as a Python 2 str
This allows us to handle bytes in mostly the same manner as Python 2 str,
so we can get rid of ugly s[i:i + 1] hacks:

  s = bytestr(s)
  while i < len(s):
      c = s[i]
      ...

This is the simpler version of the previous RFC patch which tried to preserve
the bytestr type if possible. New version simply drops the bytestr wrapping
so we aren't likely to pass a bytestr to a function that expects Python 3
bytes.
2017-03-08 22:48:26 +09:00
Yuya Nishihara
8b296e4cfa tests: allow running doctests selectively on Python 3
Currently most doctests fail on Python 3, but I want to add some.
2017-03-08 22:13:32 +09:00
Pierre-Yves David
b9d210d680 context: explicitly tests for None
Changeset c832083e5671 removed the mutable default value, but did not explicitly
tested for None. Such implicit testing can introduce semantic and performance
issue. We move to an explicit testing for None as recommended by PEP8:

https://www.python.org/dev/peps/pep-0008/#programming-recommendations
2017-03-15 15:33:24 -07:00
Pierre-Yves David
4fa55e8b7e filemerge: explicitly tests for None
Changeset 3495cae22a41 removed the mutable default value, but did not explicitly
tested for None. Such implicit testing can introduce semantic and performance
issue. We move to an explicit testing for None as recommended by PEP8:

https://www.python.org/dev/peps/pep-0008/#programming-recommendations
2017-03-15 15:11:52 -07:00
Pierre-Yves David
50e7f5d5fd hgweb: explicitly tests for None
Changeset 11e325d162fe removed the mutable default value, but did not explicitly
tested for None. Such implicit testing can introduce semantic and performance
issue. We move to an explicit testing for None as recommended by PEP8:

https://www.python.org/dev/peps/pep-0008/#programming-recommendations
2017-03-15 15:11:04 -07:00
Pierre-Yves David
c05c73d498 hgweb: explicitly tests for None in webutil
Changeset 45c7a22dbdc0 removed the mutable default value, but did not explicitly
tested for None. Such implicit testing can introduce semantic and performance
issue. We move to an explicit testing for None as recommended by PEP8:

https://www.python.org/dev/peps/pep-0008/#programming-recommendations
2017-03-15 15:10:09 -07:00
Pierre-Yves David
be968edfac match: explicitly tests for None
Changeset ba7f2a1cc2d2 removed the mutable default value, but did not explicitly
tested for None. Such implicit testing can introduce semantic and performance
issue. We move to an explicit testing for None as recommended by PEP8:

https://www.python.org/dev/peps/pep-0008/#programming-recommendations
2017-03-15 15:08:45 -07:00
Pierre-Yves David
0d3c7adc2c mq: explicitly tests for None
Changeset 97936471dc8d removed the mutable default value, but did not explicitly
tested for None. Such implicit testing can introduce semantic and performance
issue. We move to an explicit testing for None as recommended by PEP8:

https://www.python.org/dev/peps/pep-0008/#programming-recommendations
2017-03-15 15:05:54 -07:00
Pierre-Yves David
9f5b98723a rebase: explicitly tests for None
Changeset 33b71926122d removed the mutable default value, but did not explicitly
tested for None. Such implicit checking can introduce semantic and performance
issue. We move to an explicit check for None as recommended by PEP8:

https://www.python.org/dev/peps/pep-0008/#programming-recommendations
2017-03-15 15:03:43 -07:00
Rishabh Madan
8a9d68951e py3: use iter() instead of iterkeys() 2017-03-16 04:53:23 +05:30
Augie Fackler
821171d27f Added signature for changeset dcc2d404963a 2017-03-02 20:19:45 -05:00
Augie Fackler
a0e0376310 merge with i18n 2017-03-02 20:07:35 -05:00
Wagner Bruna
c77d653cee i18n-pt_BR: synchronized with 11b8e606c473 2017-03-02 11:08:20 -03:00
FUJIWARA Katsunori
7f697ba8f8 i18n-ja: synchronized with 11b8e606c473 2017-03-01 16:43:22 +09:00
Yuya Nishihara
ee998576d8 worker: flush messages written by child processes before exit
I found some child outputs were lost while testing the previous patch. Since
os._exit() does nothing special, we need to do that explicitly.
2017-02-25 12:48:50 +09:00
Yuya Nishihara
fa0a3203ec worker: add basic test to ensure child processes are managed well
This should catch the bug fixed by "worker: ignore meaningless exit status
indication returned by os.waitpid()."

Before, worker.py was untested since test repositories are relatively small.
2017-02-25 12:33:37 +09:00
eloimorlaas
293313403e record: update help to describe ui.interface
hg help record was not accurate if using another interface than the text one
2017-02-23 11:23:17 -08:00
Rishabh Madan
d0ac5a9dcb ui: replace obsolete default-push with default:pushurl (issue5485)
Default-push has been deprecated in favour of default:pushurl. But "hg clone" still
inserts this in every hgrc file it creates. This patch updates the message by replacing
default-push with default:pushurl and also makes the necessary changes to test files.
2017-02-25 16:57:21 +05:30
FUJIWARA Katsunori
47ba9fae77 worker: ignore meaningless exit status indication returned by os.waitpid()
Before this patch, worker implementation assumes that os.waitpid()
with os.WNOHANG returns '(0, 0)' for still running child process. This
is explicitly specified as below in Python API document.

    os.WNOHANG
        The option for waitpid() to return immediately if no child
        process status is available immediately. The function returns
        (0, 0) in this case.

On the other hand, POSIX specification doesn't define the "stat_loc"
value returned by waitpid() with WNOHANG for such child process.

    http://pubs.opengroup.org/onlinepubs/9699919799/functions/waitpid.html

CPython implementation for os.waitpid() on POSIX doesn't take any care
of this gap, and this may cause unexpected "exit status indication"
even on POSIX conformance platform.

For example, os.waitpid() with os.WNOHANG returns non-zero "exit
status indication" on FreeBSD. This implies os.kill() with own pid or
sys.exit() with non-zero exit code, even if no child process fails.

To ignore meaningless exit status indication returned by os.waitpid(),
this patch skips subsequent steps forcibly, if os.waitpid() returns 0
as pid.

This patch also arranges examination of 'p' value for readability.

FYI, there are some issues below about this behavior reported for
CPython.

    https://bugs.python.org/issue21791
    https://bugs.python.org/issue27808
2017-02-25 01:07:52 +09:00
Siddharth Agarwal
7d1a6f9777 bundle2: fix assertion that 'compression' hasn't been set
`n.lower()` will return `compression`, not `Compression`.
2017-02-13 11:43:12 -08:00