Commit Graph

31143 Commits

Author SHA1 Message Date
Martin von Zweigbergk
d6f2ec5990 branches: enable pager 2017-03-13 11:03:59 -07:00
Yuya Nishihara
0b54547397 py3: fix slicing of bytes in revset.formatspec() 2017-03-12 17:16:43 -07:00
Yuya Nishihara
ce52228976 py3: make set of revset operators and quotes in bytes 2017-03-12 17:13:54 -07:00
Yuya Nishihara
b72ea4927a py3: convert set of revset initial symbols back to bytes
Otherwise tokenize() would fail due to comparison between unicode and bytes.
2017-03-12 17:10:14 -07:00
Yuya Nishihara
a1b53adeff pycompat: add helper to iterate each char in bytes 2017-03-12 17:04:45 -07:00
Augie Fackler
38e6574e36 branchmap: fix python 2.6 by using util.buffer() instead of passing bytearray 2017-03-12 19:47:51 -04:00
Mads Kiilerich
b41f3f4681 rebase: allow rebasing children of wd to wd if a new branch has been set (BC)
The named branch of the leaf changeset can be changed by updating to it,
setting the branch, and amending.

But previously, there was no good way to *just* change the branch of several
linear changes. If rebasing changes with another parent to '.', it would pick
up a pending branch change up. But when rebasing changes that have the same
parent, it would fail with 'nothing to rebase', even when the branch name was
set differently.

To fix this, allow rebasing to same parent when a branch has been set.
2017-03-12 16:44:01 -07:00
Mads Kiilerich
ea3cfbc6fb merge: check current wc branch for 'nothing to merge', not its p1
The working directory will usually be clean or very clean, and wc will usually
have the same branch as its parent. This change will thus usually not make any
difference and is done as a separate change to show that. It will be used in a
later change.
2017-03-12 16:41:46 -07:00
Yuya Nishihara
1aa2b14401 lock: do not encode result of gethostname on Python 2
If a hostname contained non-ascii character, str.encode() would first try
to decode it to a unicode and raise UnicodeDecodeError.
2017-03-12 16:26:34 -07:00
Augie Fackler
be3d23b263 py3: prove hg files --rev works 2017-03-12 03:33:38 -04:00
Augie Fackler
cf064d4eef tests: make a variable for hg binary location in test-check-py3-commands
The number of which calls in here is starting to get silly.
2017-03-12 03:37:45 -04:00
Augie Fackler
3c69b88530 lock: encode result of gethostname into a bytestring 2017-03-12 03:28:50 -04:00
Martijn Pieters
458cf59837 config: avoid using a mutable default
Nothing *currently* mutates this list, but the moment something does it'll be
shared between all config instances. Avoid this eventuality.
2017-03-12 12:56:12 -07:00
Pierre-Yves David
c6f71ed49c localrepo: deprecate 'repo.join' in favor of 'repo.vfs.join'
localrepo have an insane amount of method. Accessing the feature through the
vfs is not really harder and allow us to schedule that method for removal.
2016-08-05 14:09:04 +02:00
Yuya Nishihara
7daa87b335 pycompat: move imports of cStringIO/io to where they are used
There's no point to import cStringIO as io since we have to select StringIO
or BytesIO conditionally.
2017-03-12 12:54:11 -07:00
Mads Kiilerich
d97e14e32b rbc: empty (and invalid) rbc-names file should give an empty name list
An empty file (if it somehow should exist) used to give a list with an empty
name. That didn't do any harm, but it was "wrong". Fix that.
2017-03-12 12:17:30 -07:00
Mads Kiilerich
d6292de3bd rbc: use struct unpack_from and pack_into instead of unpack and pack
These functions were introduced in Python 2.5 and are faster and simpler than
the old ones ...  mainly because we can avoid intermediate buffers:

  $ python -m timeit -s "_rbcrecfmt='>4sI'" -s 's = "x"*10000' -s 'from struct import unpack' 'unpack(_rbcrecfmt, buffer(s, 16, 8))'
  1000000 loops, best of 3: 0.543 usec per loop
  $ python -m timeit -s "_rbcrecfmt='>4sI'" -s 's = "x"*10000' -s 'from struct import unpack_from' 'unpack_from(_rbcrecfmt, s, 16)'
  1000000 loops, best of 3: 0.323 usec per loop

  $ python -m timeit -s "from array import array" -s "_rbcrecfmt='>4sI'" -s "s = array('c')" -s 's.fromstring("x"*10000)' -s 'from struct import pack' -s "rec = array('c')" 'rec.fromstring(pack(_rbcrecfmt, "asdf", 7))'
  1000000 loops, best of 3: 0.364 usec per loop
  $ python -m timeit -s "from array import array" -s "_rbcrecfmt='>4sI'" -s "s = array('c')" -s 's.fromstring("x"*10000)' -s 'from struct import pack_into' -s "rec = array('c')" -s 'rec.fromstring("x"*100)' 'pack_into(_rbcrecfmt, rec, 0, "asdf", 7)'
  1000000 loops, best of 3: 0.229 usec per loop
2016-10-19 02:46:35 +02:00
Augie Fackler
bc09440907 revlog: use bytes() instead of str() to get data from memoryview
Fixes `files -v` on Python 3.
2017-03-12 15:27:02 -04:00
Augie Fackler
d5d09dfdf4 util: teach url object about __bytes__
__str__ tries to do something reasonable, but someone else more
familiar with encoding bugs should check my work.
2017-03-12 03:33:22 -04:00
Augie Fackler
408bc8a668 manifest: ensure paths are bytes (not str) in pure parser 2017-03-12 03:31:54 -04:00
Augie Fackler
518fdf5357 manifest: now that node.bin is available, use it directly
Previously we were getting it through revlog, which is a little unusual.
2017-03-12 03:30:15 -04:00
Augie Fackler
c6a7c91d01 manifest: use node.bin instead of .decode('hex')
The latter doesn't work in Python 3.
2017-03-12 03:29:48 -04:00
Augie Fackler
93c6a91a94 manifest: add __next__ methods for Python 3
Python 3 renamed .next() in the iterator protocol to __next__().
2017-03-12 00:43:20 -05:00
Augie Fackler
f010a9d8ef files: use native string type to load rev opt from dict 2017-03-12 00:51:00 -05:00
Augie Fackler
8c2dacbd98 store: fix many single-byte ops to use slicing in _auxencode 2017-03-12 00:50:44 -05:00
FUJIWARA Katsunori
9d450170ba py3: add "b" prefix to string literals related to module policy
String literals without explicit prefix in __init__.py and policy.py
are treated as unicode object on Python3, because these modules are
loaded before setup of our specific code transformation (the later
module is imported at the beginning of __init__.py).

BTW, "modulepolicy" in __init__.py is initialized by "policy.policy".

This causes issues below;

  - checking "policy" value in other modules causes unintentional result

    For example, "b'py' not in (u'c', u'py')" returns True
    unintentionally on Python3.

  - writing "policy" out fails at conversion from unicode to bytes

    db1ebf457295 fixed this issue for default code path, but "policy"
    can be overridden by HGMODULEPOLICY environment variable (it should
    be rare case for developer using Python3, though).

This patch does:

  - add "b" prefix to all string literals, which are related to module
    policy, in modules above.

  - check existence of HGMODULEPOLICY, and overwrite "policy" only if
    it exists

    For simplicity, this patch omits checking "supports_bytes_environ",
    switching os.environ/os.environb, and so on (Yuya agreed this in
    personal talking)
2017-03-13 04:06:36 +09:00
Yuya Nishihara
bec7ade60c py3: drop unused aliases to array.array which are replaced with bytearray 2017-03-12 11:47:02 -07:00
Pulkit Goyal
a0c31269e8 pycompat: default to BytesIO instead of StringIO 2017-03-13 00:55:14 +05:30
Augie Fackler
87aee9cbf5 repoview: specify setattr values as native strings 2017-03-12 00:48:06 -05:00
Augie Fackler
03a50eb15f revlog: use bytes() to ensure text from _chunks is a reasonable type 2017-03-12 03:32:38 -04:00
Augie Fackler
58dedd9fd0 revlog: extract first byte of revlog with a slice so it's portable 2017-03-12 00:49:49 -05:00
Augie Fackler
9d7c26df45 revsetlang: slice out single bytes instead of indexing
For portability with Python 3.
2017-03-12 00:46:59 -05:00
Augie Fackler
b4f8ffef60 lock: use %d to format integer into a bytestring 2017-03-12 03:29:04 -04:00
Augie Fackler
ef815f4375 parser: use %d instead of %s for interpolating error position
Error position is an int, so we should use %d instead of %s. Fixes
failures on Python 3.
2017-03-12 00:44:59 -05:00
Augie Fackler
949dee72f1 manifest: unbreak pure-python manifest parsing on Python 3 2017-03-12 00:44:21 -05:00
Augie Fackler
d214daa434 context: use portable construction to verify int parsing 2017-03-12 00:43:47 -05:00
Augie Fackler
5e07b24e52 ui: portably bytestring-ify url object 2017-03-12 01:59:23 -05:00
Augie Fackler
edad90c687 scmutil: fix key generation to portably bytestringify integer 2017-03-12 00:47:39 -05:00
Augie Fackler
9c70a09b17 branchmap: stringify int in a portable way
We actually need a bytes in Python 3, and thanks to our nasty source
loader this will portably do the right thing.
2017-03-12 00:42:46 -05:00
Augie Fackler
0c31289213 branchmap: don't use buffer() on Python 3
This is certainly slower than the Python 2 code, but it works, and we
can revisit it later if it's a problem.
2017-03-12 00:49:19 -05:00
Augie Fackler
9a15a28705 py3: use bytearray() instead of array('c', ...) constructions
Portable from 2.6-3.6.
2017-03-12 03:32:21 -04:00
Augie Fackler
b9f0d10d43 summary: don't explicitly str() something we're about to %s
str() is wrong on Python 3 here, and %s implicitly calls str() anyway,
so this was just extra dancing for no reason.
2017-03-11 20:58:26 -05:00
Augie Fackler
d44c41fe19 context: implement both __bytes__ and __str__ for Python 3
They're very similar, for obvious reasons.
2017-03-11 20:57:40 -05:00
Augie Fackler
89600a72c4 context: work around long not existing on Python 3
I can't figure out what this branch is even trying to accomplish, and
it was introduced in 387a3aa50d61 which doesn't really shed any
insight into why longs are treated differently from ints.
2017-03-11 20:57:04 -05:00
Augie Fackler
f080be2c20 phases: explicitly evaluate list returned by map
On Python 3 map() returns a generator, which bool()s to true even if
it had an empty input set. Work around this by using list() on the
map() result.
2017-03-11 20:53:20 -05:00
Augie Fackler
6ba88e41e4 ui: check for --debugger in sys.argv using r-string to avoid bytes on py3
Our source loader was errantly turning this --debugger into a bytes,
which was then causing me to still get a pager when I was using the
debugger on py3. That made life hard.
2017-03-11 20:51:09 -05:00
Pulkit Goyal
f34f53b9de minirst: use bytes.strip instead of str.strip
bytes.strip exists in Python 2.6 and Python 2.7 also.
2017-03-12 22:46:57 +05:30
Pulkit Goyal
48edb15e9c smcposix: pass unicode as first argument to array.array
This is an instance where we can safely convert the first argument, rest are
the cases except one where we are using 'c' which is not there in Python 3. So
that needs to be handled differently. This will help in making `hg help` run on
Python 3.
2017-03-12 22:27:53 +05:30
Pulkit Goyal
7deacd3d03 util: pass encoding.[encoding|encodingmode] as unicodes
We need to pass str to encode() and decode().
2017-03-12 07:35:13 +05:30
Pierre-Yves David
8f0998647c win32text: directly use repo.vfs.join
The 'repo.join' method is about to be deprecated.
2017-03-08 16:52:57 -08:00