Commit Graph

31215 Commits

Author SHA1 Message Date
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
Pierre-Yves David
09a5f07adf localrepo: deprecated '_link'
That method had a total on 1 internal user...


G: changed mercurial/localrepo.py
2016-08-05 14:15:45 +02:00
Pierre-Yves David
2634c22ce0 localrepo: use self.wvfs.islink directly
We are about to deprecate the helper function.
2016-08-05 14:19:31 +02:00
Pulkit Goyal
fcc99d385f py3: convert opts back to bytes for status 2017-03-16 10:10:00 +05:30
Gregory Szorc
206cd3557e parsers: handle refcounting of "parents" consistently
Py_None can be refcounted like any other Python object. So
do that.
2017-03-13 17:49:13 -07:00
Martin von Zweigbergk
7b5dab5409 py3: make py3 compat.iterbytestr simpler and faster
With Python 3.4.3, timit says 11.9 usec-> 6.44 usec. With Python
3.6.0, timeit says 14.1 usec -> 9.55 usec.
2017-03-15 09:32:18 -07:00
Martin von Zweigbergk
cf1f0d3920 py3: optimize py3 compat.bytechr using Struct.pack
With Python 3.4.3, timeit says 0.437 usec -> 0.0685 usec. With Python
3.6, timeit says 0.157 usec -> 0.0907 usec. So it's faster on both
versions, but the speedup varies a lot.

Thanks to Gregory Szorc for the suggestion.
2017-03-15 09:30:50 -07:00
Ryan McElroy
5ffd6c8793 tests: properly drop back to root dir in test-status.t 2017-03-15 19:26:20 -07:00
Pulkit Goyal
f9b7821158 dirstate: use list comprehension to get a list of keys
We have used dict.keys() which returns a dict_keys() object instead
of list on Python 3. So this patch replaces that with list comprehension
which works both on Python 2 and 3.
2017-03-16 09:00:27 +05:30
Pulkit Goyal
5a7c5d918e match: slice over bytes to get the byteschr instead of ascii value 2017-03-16 08:03:51 +05:30
Pulkit Goyal
0bad6ee6aa match: make regular expression bytes to prevent TypeError 2017-03-16 07:52:47 +05:30
Pulkit Goyal
7ed6d8245e scmutil: make function name bytes in class filecache
func.__name__ returns unicodes and this leads to keyerror when we try
to do filecache[''] by passing bytes.
2017-03-16 06:32:33 +05:30
Pierre-Yves David
0923ede90f localrepo: deprecate 'wfile'
The method had very few users and the modern form is shorter. So let us
deprecates another method of the localrepo class.
2017-03-15 00:27:17 -07:00
Pierre-Yves David
c8ef80badf eol: use 'wvfs' instead of 'wfile'
Method is about to be deprecated and the modern form is shorter.
2017-03-15 00:31:59 -07:00
Pierre-Yves David
5fc4dd0997 localrepo: use 'wvfs' instead of 'wfile'
Method is about to be deprecated and the modern form is shorter.
2017-03-15 00:29:09 -07:00
Pierre-Yves David
3298e01804 tagmerge: use 'wvfs' instead of 'wfile'
Method is about to be deprecated and the modern form is shorter.
2017-03-15 00:28:58 -07:00
Pierre-Yves David
20c832d095 gpg: use 'wvfs' instead of 'wfile'
Method is about to be deprecated and the modern form is shorter.
2017-03-15 00:28:21 -07:00
Pierre-Yves David
a51384137e test: add a basic 'test-check-pylint.t'
We add a minimal check using pylint for one case we knows we care about:
"mutable default" argument.

We'll likely extend this over time to cover other useful checks but this is a
good starting point.
2016-12-28 23:42:50 +01:00
Pierre-Yves David
2a46795ed1 localrepo: don't use mutable default argument value
Caught by pylint.
2017-03-14 23:50:07 -07:00
Pierre-Yves David
c4d32111df httpclient: don't use mutable default argument value
Caught by pylint.
2017-03-14 23:49:25 -07:00
Pierre-Yves David
654e9bcf93 largefiles: don't use mutable default argument value
Caught by pylint.
2017-03-14 23:49:10 -07:00
Pierre-Yves David
5e3487503b hgk: don't use mutable default argument value
Caught by pylint.
2017-03-14 23:48:25 -07:00