Commit Graph

30386 Commits

Author SHA1 Message Date
Pulkit Goyal
22be95eb3e py3: have a bytes version of sys.platform
sys.platform returns unicodes on Python 3. This patch adds up
pycompat.sysplatform which returns bytes.
2016-12-18 00:52:05 +05:30
Pulkit Goyal
06f595a242 py3: have a bytes version of os.altsep
os.altsep returns unicodes on Python 3. We need a bytes version hence added
pycompat.altsep.
2016-12-18 00:44:21 +05:30
Pulkit Goyal
ab21746511 py3: make sure encoding.encoding is a bytes variable
encoding.encoding returns unicodes when locale.getpreferredencoding() is used
to get the preferred encoding. This patch fixes that.
2016-12-17 23:55:25 +05:30
Jun Wu
e912a360fc chg: remove locks
See the previous two patches for the reason. The advantage is a simplified
code base and better throughput when starting multiple servers with multiple
confighashes. The disadvantage is starting multiple servers in parallel with
a single confighash will waste some CPU time, which is probably fine in
common use-cases.

This makes it easier to switch to relative paths to support long unix domain
socket paths.
2016-12-19 22:15:00 +00:00
Jun Wu
24cb48448f chg: start server at a unique address
See the previous patch for motivation. Previously, the server is started at
a globally shared address. This patch appends pid to the address so it
becomes unique.

Note: with Linux pid namespace, the address may be non-unique, but it does
not affect correctness of chg - chg client will receive an redirection and
that's it.
2016-12-19 22:09:49 +00:00
Jun Wu
5508cfe721 chgserver: truncate base address at "." for hash address
Previously, the hash address is just appending "-$HASH" to base address.
This patch makes it truncate the basename address at "." before appending
"-$HASH".

This makes it possible to spawn new servers in a racy situation and the
client could be sure the server it connects is the new server just spawned.

This is a step towards removing the lock.

One of the functionalities of the lock is to make sure the connect will
connect to a server it just created:

  1. start server --address foo
  2. connect to foo # wish "foo" is the server just started

With this change, the client could do:

  1. start server --address foo.tmp$PID
  2. connect to foo.tmp$PID # is the server just started
     (note: if it is not, it does not affect correctness - linux pid
      namespace is not a concern here)
  3. rename foo.tmp$PID to foo

Another functionality of the lock is to avoid starting multiple servers with
a same confighash in parallel. But that also prevents starting multiple
servers with different confighashes in parallel.
2016-12-19 22:07:41 +00:00
Yuya Nishihara
26dd8d740c ui: do not translate empty configsource() to 'none' (API)
It should be processed when displaying data, so we can get "source": "" in
JSON output.
2016-10-23 17:47:00 +09:00
Yuya Nishihara
cf9b8abe16 convert: remove unused-but-set variable introduced in d68d4752d365
Spotted by pyflakes.
2016-12-18 16:20:04 +09:00
Pulkit Goyal
908a677054 py3: replace os.sep with pycompat.ossep (part 4 of 4) 2016-12-17 20:24:46 +05:30
Pulkit Goyal
5629f71f5b py3: replace os.sep with pycompat.ossep (part 3 of 4) 2016-12-17 20:14:24 +05:30
Pulkit Goyal
a7d1fd0177 py3: replace os.sep with pycompat.ossep (part 2 of 4)
This part also replaces some chunks of os.sep with pycompat.ossep.
2016-12-17 20:02:50 +05:30
Pulkit Goyal
f18da7ce65 py3: replace os.sep with pycompat.ossep (part 1 of 4)
os.sep returns unicodes on Python 3. We have pycompat.ossep which returns
bytes. This patch is a part of 4 patch series which will replace all the
occurrences of os.sep to pycompat.ossep
2016-12-17 19:56:30 +05:30
Pulkit Goyal
851ae37944 py3: replace os.pathsep with pycompat.ospathsep
os.pathsep returns unicode on Python 3. We already have pycompat.ospathsep
which return bytes on Python 3. This patch replaces all the occurrences of
os.pathsep in the codebase (excluding tests) to pycompat.ospathsep.
2016-12-17 19:47:17 +05:30
Pulkit Goyal
28d96dbde6 py3: use %d instead of %s for integers
Python 3 returns an error if we use %s as type specifiers for integers.
2016-12-17 19:36:40 +05:30
Martin von Zweigbergk
8f2ed099c1 help: make multirevs just an alias for revsets
The multirevs topis seems to be covered well by the revsets topic, so
just make it an alias and remove multirevs.txt.
2016-12-16 09:48:14 -08:00
Jun Wu
76875fcc1b context: correct metadataonlyctx's parameter
It's "originalctx", not "path" as Yuya pointed in [1].

[1]: www.mercurial-scm.org/pipermail/mercurial-devel/2016-December/091508.html
2016-12-16 21:02:39 +00:00
Pierre-Yves David
9340890321 registrar: raise a programming error on duplicated registering
Previous, registering different object with the same name would silently
overwrite the first value with the second one. We now detect the situation and
raise an error. No extension in test or core had the issues.
2016-12-12 13:32:45 +01:00
Yuya Nishihara
7a1dbb800d py3kcompat: drop unused module
Perhaps this was a predated attempt of Python 3 porting. Python 3.5 supports
%-formatting of bytes.
2016-10-16 17:01:41 +09:00
Yuya Nishihara
6f66b5d1e9 strutil: drop module which no longer be used 2016-10-16 16:59:50 +09:00
Yuya Nishihara
601f618d04 convert: inline strutil.rfindall()
This is the only place where strutil is used. I don't think it's worth to
keep the strutil module, so inline it.

Also, strutil.rfindall() appears to have off-by-one error. 'end = c - 1' is
wrong because 'end' is exclusive.
2016-10-16 16:58:43 +09:00
David Soria Parra
dab6f08428 convert: return commit objects for revisions in the revmap
Source revision data that exists in the revmap are ignored when pulling
data from Perforce as we consider them already imported. In case where
the `convertcmd.convert` algorithm requests a commit object for such
a revision we are creating it.  This is usually the case for parent of
the first imported revision.
2016-12-14 12:07:23 -08:00
David Soria Parra
52774a1f49 convert: encapsulate commit data fetching and commit object creation
Split fetching the `describe` form from Perforce and the commit object creation
into two functions. This allows us to reuse the commit construction for
revisions passed from a revmap.
2016-12-13 21:49:58 -08:00
David Soria Parra
8040456970 convert: do not provide head revisions if we have no changests to import
Don't set a head revision in cases where we have a revmap but no
changesets to import, as convertcmd.convert() treats them as heads of
to-imported revisions.
2016-12-13 21:49:58 -08:00
David Soria Parra
4683ce4a8a convert: allow passing in a revmap
Implement `common.setrevmap` which is used to pass in a file with existing
revision mappings. This functionality is used by `convertcmd.convert` if it
exists and allows implementors such as the p4 converter to make use of an
existing mapping.

We are using the revmap to abort scanning and the repository for more information
if we already have the revision. This means we are allowing incremental imports
in cases where a revmap is provided.
2016-12-14 01:45:57 -08:00
David Soria Parra
cde8421946 convert: use convert_revision for P4 imports
We are using convert_revisions in other importers. In order to unify this
we are also using convert_revision for Perforce in addition to the original
'p4'.
2016-12-13 21:49:58 -08:00
David Soria Parra
eeb4ddccf3 convert: remove unused dictionaries
self.parent, self.lastbranch and self.tags have never been used.
2016-12-14 01:45:17 -08:00
David Soria Parra
5b7b900ca3 convert: self.heads is a list
self.heads is used as a list throughout convert and never a dictionary.
Initialize it correctly to a list.
2016-12-14 01:43:47 -08:00
David Soria Parra
338550df2b convert: don't use long list comprehensions
We are iterating over p4changes. Make the continue condition more clear
and easier to add new conditions in future patches, by removing the list
comprehension and move the condition into the existing for-loop.
2016-12-13 21:49:58 -08:00
Durham Goode
323f27948d changelog: keep track of file end in appender (issue5444)
Previously, changelog.appender.end() would compute the end of the file by
joining all the current appended data and checking the length. This is an O(n)
operation.  449b4adb7d39 introduced a seek call before every revlog write, which
means we are hitting this O(n) behavior n times, which causes changelog writes
during a pull to be n^2.

In our large repo, this caused pulling 100k commits to go from 17s to 130s. With
this fix, it's back to 17s.
2016-12-15 11:00:18 -08:00
Augie Fackler
74b72bf255 tests: fix test-bdiff to handle variance between pure and c bdiff code
Obviously we'd rather patch pure to have the same algorithmic win as
the C code, but this is a quick fix for the pure build since pure
isn't wrong, just not as fast as it could be.
2016-12-15 11:14:00 -05:00
Augie Fackler
7615fa0f90 tests: finish updating test-bdiff to unittest (part 4 of 4) 2016-12-15 11:04:09 -05:00
Augie Fackler
973a0b2065 tests: update more of test-bdiff.py to use unittest (part 3 of 4) 2016-12-15 10:56:26 -05:00
Augie Fackler
d751e0686d tests: update more of test-bdiff.py to use unittest (part 2 of 4) 2016-12-15 10:50:06 -05:00
Augie Fackler
133f8468d3 tests: migrate test-bdiff.py to use unittest (part 1 of 4)
This moves all the test() calls, which were easy and mechanical.
2016-12-15 10:10:15 -05:00
Pierre-Yves David
54022676d2 import-checker: do not enforce lexical sort accross stdlib/local boundary
Before this change, you could get in a start where the checker would either
complain about importing local module before stdlib one or complain about the
local one being wrongly lexically sorted with the stdlib one.

We detect the boundary and avoid complaining about lexical sort across it.
2016-12-15 19:56:48 +01:00
Stanislau Hlebik
da605718f2 cg1packer: fix compressed method
`cg1packer.compressed()` returns True even if `self._type` is 'UN'. This patch
fixes it.
2016-12-14 09:53:56 -08:00
Philippe Pepiot
396c998f12 perf: add historical support of ui.load()
ui.load() has been available since d83ca854 and at the time of writing isn't
available on stable branch breaking benchmarking newer stable revisions.

Add historical portability policy note on contrib/benchmarks
2016-12-15 12:17:08 +01:00
Jun Wu
44c0d5d616 chg: ignore HG_* in confighash
The environment variables `HG_*` are usually used by hooks. Unlike `HGPLAIN`
etc, they do not actually affect hg's behavior. So do not include them in
confighash.

This would avoid spawning an unbound number of chg server processes if
commit hook calls hg frequently.
2016-12-14 02:17:59 +00:00
Pulkit Goyal
9d833da676 py3: make keys of keyword arguments strings
keys of keyword arguments on Python 3 has to be string. We are dealing with
bytes in our codebase so the keys are also bytes. Done that using
pycompat.strkwargs().

Also after this patch, `hg version` now runs on Python 3.5. Hurray!
2016-12-13 20:53:40 +05:30
Jun Wu
1d0e485ba1 error: make it clear that ProgrammingError is for mercurial developers
The word "developer" could refer to users - people using hg are likely to be
developers. Add adjectives to make it refer to mercurial developers only.
2016-12-12 08:01:52 +00:00
Remi Chaintron
cc88d4a3c4 revlog: merge hash checking subfunctions
This patch factors the behavior of both methods into 'checkhash'.
2016-12-13 14:21:36 +00:00
Stanislau Hlebik
420d75485a bookmarks: make bookmarks.comparebookmarks accept binary nodes (API)
Binary bookmark format should be used internally. It doesn't make sense to have
optional parameters `srchex` and `dsthex`. This patch removes them. It will
also be useful for `bookmarks` bundle2 part because unnecessary conversions
between hex and bin nodes will be avoided.
2016-12-09 03:22:26 -08:00
Stanislau Hlebik
420e1ab2a8 bookmarks: rename compare() to comparebookmarks() (API)
Next commit will remove optional parameters from `compare()` function.
Let's rename `compare()` to `comparebookmarks()` to avoid ambiguity from
callers from external extensions.
2016-11-22 01:33:31 -08:00
Gábor Stefanik
b631d16eab graft: support grafting changes to new file in renamed directory (issue5436) 2016-12-05 17:40:01 +01:00
Jun Wu
3f639e27a5 rebase: calculate ancestors for --base separately (issue5420)
Previously, the --base option only works with a single "branch" - if there
is one changeset in the "--base" revset whose branching point(s) is/are
different from another changeset in the "--base" revset, "rebase" will error
out with:

  abort: source is ancestor of destination

This happens if the user has multiple draft branches, and uses "hg rebase -b
'draft()' -d master", for example. The error message looks cryptic to users
who don't know the implementation detail.

This patch changes the logic to calculate the common ancestor for every
"base" changeset separately so we won't (incorrectly) select "source" which
is an ancestor of the destination.

This patch should not change the behavior where all changesets specified by
"--base" have the same branching point(s).

A new situation is: some of the specified changesets could be rebased, while
some couldn't (because they are descendants of the destination, or they do
not share a common ancestor with the destination). The current behavior is
to show "nothing to rebase" and exits with 1.

This patch maintains the current behavior (show "nothing to rebase") even if
part of the "--base" revset could be rebased. A clearer error message may be
"cannot find branching point for X", or "X is a descendant of destination".
The error message issue is tracked by issue5422 separately.

A test is added with all kinds of tricky cases I could think of for now.
2016-11-28 05:45:22 +00:00
Pulkit Goyal
b18d8e2c04 py3: utility functions to convert keys of kwargs to bytes/unicodes
Keys of keyword arguments need to be str(unicodes) on Python 3. We have a lot
of function where we pass keyword arguments. Having utility functions to help
converting keys to unicodes before passing and convert back them to bytes once
passed into the function will be helpful. We now have functions named
pycompat.strkwargs(dic) and pycompat.byteskwargs(dic) to help us.
2016-12-07 21:53:03 +05:30
Pulkit Goyal
3f64a7a3eb py3: make a bytes version of getopt.getopt()
getopt.getopt() deals with unicodes on Python 3 internally and if bytes
arguments are passed, then it will return TypeError. So we have now
pycompat.getoptb() which takes bytes arguments, convert them to unicode, call
getopt.getopt() and then convert the returned value back to bytes and then
return those value.
All the instances of getopt.getopt() are replaced with pycompat.getoptb().
2016-12-06 06:36:36 +05:30
Jun Wu
51bd231f28 parsers: use buffer to store revlog index
Previously, the revlog index passed to parse_index2 must be a "string",
which means we have to read the whole revlog index into memory. This patch
makes the code accept a generic Py_buffer, to be more flexible - it could be
a "string", or anything that implements the buffer interface, like a mmap-ed
region.

Note: ideally we want to remove the "data" field. However, it is still used
in parse_index2:

    if (idx->inlined) {
        cache = Py_BuildValue("iO", 0, idx->data);
        ....
    }
    ....
    tuple = Py_BuildValue("NN", idx, cache);
    ....
    return tuple;

Its only users are revlogio.parseindex and revlog.__init__:

    # revlogio.parseindex
    index, cache = parsers.parse_index2(data, inline)
    return index, getattr(index, 'nodemap', None), cache

    # revlog.__init__
    d = self._io.parseindex(indexdata, self._inline)
    self.index, nodemap, self._chunkcache = d

Maybe we could move the logic (testing inline and returnning "data" object)
to revlog.py. But that should be a separate patch.
2016-12-06 11:44:49 +00:00
Pulkit Goyal
9523fa9b6b fancyopts: switch from fancyopts.getopt.* to getopt.*
In the next patch, we will be creating a bytes version of getopt.getopt() and
doing that will leave getopt as unused import in fancyopts. So before removing
that there are instances in codebase where instead of importing getopt, we
have used fancyopts.getopt. This patch will switch all those cases so that
the next patch can remove the import of getopt from fancyopts without breaking
things.
2016-12-06 06:27:58 +05:30
Pulkit Goyal
617e2aec61 py3: use pycompat.fsdecode() to pass to imp.* functions
When we try to pass a bytes argument to a function from imp library, it
returns TypeError as it deals with unicodes internally. So we can't use bytes
with imp.* functions. Hunting through this, I found we were returning bytes
path variable to loadpath() on Python 3.5 (yes most of our codebase is
dealing with bytes on Python 3 especially the path variables). Passing unicode
does not fails the purpose of loding the extensions and a module object is
returned.
2016-12-05 06:46:51 +05:30