Commit Graph

19354 Commits

Author SHA1 Message Date
Yuya Nishihara
38282452e0 templatekw: specify plural form of instability
Follows up ebfef9a04f8d.
2017-08-13 14:12:28 +09:00
Yuya Nishihara
79af97cbbf templatekw: rename termwidth() per convention 2017-08-16 13:57:19 +09:00
Augie Fackler
a80f148d0c py3: introduce a wrapper for __builtins__.{raw_,}input()
In order to make this work, we have to wrap the io streams in a
TextIOWrapper so that __builtins__.input() can do unicode IO on Python
3. We can't just restore the original (unicode) sys.std* because we
might be running a cmdserver, and if we blindly restore sys.* to the
original values then we end up breaking the cmdserver. Sadly,
TextIOWrapper tries to close the underlying stream during its __del__,
so we have to make a sublcass to prevent that.

If you see errors like:

TypeError: a bytes-like object is required, not 'str'

On an input() or print() call on Python 3, the substitution of
sys.std* is probably the root cause.

A previous version of this change tried to put the bytesinput() method
in pycompat - it turns out we need to do some encoding handling, so we
have to be in a higher layer that's allowed to use
mercurial.encoding.encoding. As a result, this is in util for now,
with the TextIOWrapper subclass hiding in encoding.py. I'm not sure of
a better place for the time being.

Differential Revision: https://phab.mercurial-scm.org/D299
2017-07-24 14:38:40 -04:00
Augie Fackler
a5ac7e4cdd extensions: don't give AttributeError bytes message on Python 3
Differential Revision: https://phab.mercurial-scm.org/D353
2017-08-11 15:09:54 -04:00
Augie Fackler
749c36880e extensions: if on py3 and propname is a bytestr, convert to sysstr
Property names are unicodes on Python 3.

Differential Revision: https://phab.mercurial-scm.org/D296
2017-07-25 22:49:43 -04:00
Pulkit Goyal
7d16e8a210 pushvars: add a coreconfigitem for push.pushvars.server
Differential Revision: https://phab.mercurial-scm.org/D359
2017-08-12 04:47:40 +05:30
Phil Cohen
a35c75e991 filemerge: extract _picklabels as a helper function
This shortens `simplemerge()` and is a bit cleaner, IMO.

Differential Revision: https://phab.mercurial-scm.org/D376
2017-08-13 22:46:16 -07:00
Phil Cohen
69c81f7498 simplemerge: write merge result to the localctx, if passed
Differential Revision: https://phab.mercurial-scm.org/D375
2017-08-13 22:46:03 -07:00
Phil Cohen
567a5b0454 simplemerge: use contexts to read file data from, if passed
Differential Revision: https://phab.mercurial-scm.org/D374
2017-08-13 20:06:52 -07:00
Phil Cohen
2238445cd7 filemerge: pass contexts to simplemerge
Otherwise, this should be a no-op.

Differential Revision: https://phab.mercurial-scm.org/D373
2017-08-13 20:06:52 -07:00
Phil Cohen
19ef3a0841 simplemerge: add optional context parameters to simplemerge
Rename the existing parameters for clarity.

These will, in subsequent patches, allow callers to redirect reads (of the
three sides of the merge) and writes (of the result) to the given contexts,
instead of using the filesystem.

While in most cases, the writes will go to a workingfilectx, this opens the
door for it to be a memfilectx in the case of an in-memory merge.

Repo will be necessary in a subsequent comit.

Differential Revision: https://phab.mercurial-scm.org/D372
2017-08-13 20:06:52 -07:00
Phil Cohen
d6994eca65 simplemerge: extract verifytext as a helper function
This will be used in a subsequent commit.

Differential Revision: https://phab.mercurial-scm.org/D371
2017-08-13 20:06:52 -07:00
Martin von Zweigbergk
79f5d2b9d4 commit: use context manager with dirstateguard
When I wrote f33f2b5b4874 (commit: don't let failed commit with
--addremove update dirstate (issue5645), 2017-07-31), Durham's
422ca3501516 (rebase: use one dirstateguard for when using
rebase.singletransaction, 2017-07-20) had not yet landed, so I had to
write it in the old-fashioned way. Now that Durham's patch is in, we
can simplify by using a context manager.

Differential Revision: https://phab.mercurial-scm.org/D406
2017-08-14 23:26:54 -07:00
Martin von Zweigbergk
e037c48f34 commit: move dirstateguard creation out of try-block
This is just a simple refactoring to make the next patch simpler. If
the dirstateguard constructor raises an exception, the finally-block
won't do anything anyway, so this is functionally equivalent (and
there is no except-block).

Differential Revision: https://phab.mercurial-scm.org/D405
2017-08-14 23:26:51 -07:00
Pulkit Goyal
304e4abf3a copies: add more details to the documentation of mergecopies()
This documentation is very helpful for any developer to understand what
copytracing is and what the function does. Since this is the main function of
doing copytracing, I have also included bits about copytracing in it.

This additions are picked from a doc by Stash@Fb. So thanks to him.

Differential Revision: https://phab.mercurial-scm.org/D409
2017-08-16 00:25:20 +05:30
Augie Fackler
cc479af38a httppeer: add support for httppostargs when we're sending a file
This is probably only used in the 'unbundle' command, but the code
ended up being cleaner to make it generic and treat *all* httppostargs
with a non-args request body as though they were file-like in
nature. It also means we get test coverage more or less for free. A
previous version of this change didn't use io.BytesIO, and it was a
lot more complicated.

This also fixes a server-side bug, so anyone using httppostargs should
update all of their servers to this revision or later *before* this
gets to their clients, otherwise servers will hang trying to over-read
the POST body.

Differential Revision: https://phab.mercurial-scm.org/D231
2017-07-26 17:58:19 -04:00
FUJIWARA Katsunori
c8b11bcb1f i18n: get translation entries for description of each compression engines
Now, hggettext can be applied safely on util.py, of which
i18nfunctions contains appropriate objects related to each compression
types.
2017-08-15 21:09:33 +09:00
FUJIWARA Katsunori
cabc81b3e9 i18n: use saved object to get actual function information if available
To list up available compression types instead of
".. bundlecompressionmarker" in "hg help bundlespec" output, proxy
object "docobject" is used, because:

- current online help system requires that __doc__ of registered
  object (maybe, function) is already well formatted in reST syntax

- bundletype() method of compressionengine classes is used to list up
  available compression types, but

- __doc__ of bundletype() object (= "instancemethod") is read-only

On the other hand, hggettext requires original function object, in
order to get document location in source code.

Therefore, description of each compression types isn't yet
translatable. Even if translatable, translators should make much
effort to determine location of original texts in source code.

To get actual function information, this patch makes hggettext use
function object saved as "_origfunc", if it is available. This patch
also changes bundlecompressiontopics() side, in order to explain how
these changes work easily.

This patch is a part of preparations for making description of each
compression types translatable.
2017-08-15 19:27:24 +09:00
Filip Filmar
5ff93579e2 crecord: fixes the formatting of the select status in the status line
The status line in the crecord has the "space" status field which has variable
length depending on the length of the status label in the language of choice.
In English, the status labels are "space: deselect" and "space:select".  The
"deselect" label is 2 glyphs longer.  This makes the terminal output jump
around if the terminal width is just right so that the shorter label makes
the status line 1 line long, and the longer label makes it 2 lines long.

This patch formats the selected status into a fixed-width field.  The field
width is the maximum of the lengths of the two possible labels, to account for
differing translations and label lengths.  This should make the label behavior
uniform across localizations.

There does not seem to be a test for crecord, so I verified the change manually
with a local build of 'hg'.
2017-08-13 00:17:13 -07:00
Yuya Nishihara
9eb2a84457 cext: move PyInt macros to charencode.c properly
Python3 build was broken at 49826c21bae5.
2017-08-14 13:35:26 +09:00
Yuya Nishihara
3b5c5b1b96 py3: change encoding.localstr to a subclass of bytes, not str 2017-08-14 15:50:40 +09:00
Yuya Nishihara
843b049128 bundle2: relax the condition to update transaction.hookargs
This is just a micro optimization. If hookargs is empty, nothing should be
necessary.
2017-08-13 11:10:35 +09:00
Yuya Nishihara
355a92a8ee bundle2: raise ProgrammingError for invalid call of addhookargs()
It should be hard error. Also fixed the error message as s/hooks/hookargs/.
2017-08-13 11:05:56 +09:00
Alex Gaynor
ea20251106 merge: removed sorting in casefolding detection, for a slight performance win
It was not required for the correctness of the algorithm.

Differential Revision: https://phab.mercurial-scm.org/D30
2017-07-14 19:27:28 +00:00
Gregory Szorc
d5338b2208 wireproto: use new peer interface
The wirepeer class provides concrete implementations of peer interface
methods for calling wire protocol commands. It makes sense for this
class to inherit from the peer abstract base class. So we change
that.

Since httppeer and sshpeer have already been converted to the new
interface, peerrepository is no longer adding any value. So it has
been removed. httppeer and sshpeer have been updated to reflect the
loss of peerrepository and the inheritance of the abstract base
class in wirepeer.

The code changes in wirepeer are reordering of methods to group
by interface.

Some Python code in tests was updated to reflect changed APIs.

.. api::

   peer.peerrepository has been removed. Use repository.peer abstract
   base class to represent a peer repository.

Differential Revision: https://phab.mercurial-scm.org/D338
2017-08-10 20:58:28 -07:00
Gregory Szorc
b68a234a46 httppeer: use peer interface
This is similar to what we did to sshpeer. Quirks and all.

Differential Revision: https://phab.mercurial-scm.org/D337
2017-08-06 18:00:19 -07:00
Gregory Szorc
a5f89f74c6 sshpeer: use peer interface
We need the same @property conversion of ui like we did for localpeer.
We renamed _capabilities() to capabilities() to satisfy the new
naming requirement.

However, since we're inheriting from wireproto.wirepeer which inherits
from peer.peerrepository and provides its own code accessing
_capabilities(), we need to keep the old alias around. This wonkiness
will disappear once wirepeer is cleaned up in subsequent commits.

We also implement methods for basepeer that are identical to the
defaults in peer.peerrepository in preparation for the removal of
peerrepository.

Differential Revision: https://phab.mercurial-scm.org/D336
2017-08-06 17:59:48 -07:00
Gregory Szorc
cf126063f8 localrepo: use peer interfaces
We now have a formal abstract base class for peers. Let's
transition the peer classes in localrepo to it.

As part of the transition, we reorder methods so they are grouped
by interface and match the order they are defined in the interface.
We also had to change self.ui from an instance attribute to a
property to satisfy the @abstractproperty requirement.

As part of this change, we uncover the first "bug" as part of
enforcing interfaces: stream_out() wasn't implemented on localpeer!
This isn't technically a bug since the repo isn't advertising the
stream capability, so clients shouldn't be attempting to call it.
But I don't think there's a good reason why this is the case.
We implement a dummy method to satisfy the interface requriements.
We can make localpeer instances streamable as a future enhancement.

# no-check-commit

Differential Revision: https://phab.mercurial-scm.org/D335
2017-08-09 23:52:25 -07:00
Gregory Szorc
1ffc45ea51 repository: implement generic capability methods on peer class
These methods are part of the peer interface, are generic, and can
be implemented in terms of other members of the peer interface. So we
implement them on the peer base class as a convenience.

The implementation is essentially copied from peer.py. The code
in peer.py will eventually be deleted.

Differential Revision: https://phab.mercurial-scm.org/D334
2017-08-06 16:47:25 -07:00
Gregory Szorc
1e5a17ee62 repository: formalize wire protocol interface
There are a well-defined set of commands constituting the wire
protocol. Interaction with these and methods for calling them in
batches are exposed via methods on peer instances.

Let's formalize support for these features in abstract classes.

The command parts come from the existing wireproto.wirepeer class.
The batch methods come from peer.peerrepository.

Ample documentation has been added as part of defining the interfaces.

# no-check-commit

Differential Revision: https://phab.mercurial-scm.org/D333
2017-08-13 11:04:42 -07:00
Gregory Szorc
99b48bdf1a repository: formalize peer interface with abstract base class
There are various interfaces for interacting with repositories
and peers. They form a contract for how one should interact with
a repo or peer object.

The contracts today aren't very well-defined or enforced. There
have been several bugs over the years where peers or repo types
have forgotten to implement certain methods. In addition, the
inheritance of some classes is wonky. For example, localrepository
doesn't inherit from an interface and the god-object nature of
that class means the repository interface isn't well-defined. Other
repository types inherit from localrepository then stub out
methods that don't make sense (e.g. statichttprepository
re-defining locking methods to fail fast).

Not having well-defined interfaces makes implementing alternate
storage backends, wire protocol transports, and repository types
difficult because it isn't clear what exactly needs to be
implemented.

This patch starts the process of attempting to establish more
order to the type system around repositories and peers.

Our first patch starts with a problem space that already has a
partial solution: peers. The peer.peerrepository class already
somewhat defines a peer interface. But it is missing a few things
and the total interface isn't well-defined because it is combined
with wireproto.wirepeer.

Our newly-established basepeer class uses the abc module to
declare an abstract base class with the properties and methods that
a generic peer must implement.

We create a new class that inherits from it. This class will hold
our other future abstract base classes / interfaces so we can expose
a unified base class/interface.

We don't yet use the new interface because subsequent additions
will break existing code without some refactoring first.

A new module (repository.py) was created to hold the interfaces.
I could have put things in peer.py. However, I have plans to
eventually add interfaces to define repository and storage types.
These almost certainly require a new module. And I figured having
all the interfaces live in one module makes sense. So I created
repository.py to be that future home.

Differential Revision: https://phab.mercurial-scm.org/D332
2017-08-13 10:58:48 -07:00
Jun Wu
9f55a1848e util: make nogc effective for CPython
a3022f57803b made `util.nogc` a no-op. It was to optimize PyPy. But it slows
down CPython if many objects (like 300k+) are created.

For example, running `hg log -r .` without extensions in `hg-committed` with
14k+ obsmarkers have the following times:

  before        | after
  hg    | chg   | hg    | chg
  -----------------------------
  1.262 | 0.860 | 1.077 | 0.619 (seconds, best of 20 runs)

Therefore let's re-enable nogc for CPython.

Differential Revision: https://phab.mercurial-scm.org/D402
2017-08-14 22:28:59 -07:00
Augie Fackler
8beb33f58d scmutil: use util.shellquote instead of %r
Changes some output, but also resolves differences with Python 3.

Differential Revision: https://phab.mercurial-scm.org/D301
2017-07-26 23:47:54 -04:00
Boris Feld
8b166b43e2 context: fix troubled deprecation
troubled has been renamed into isunstable but troubled was calling unstable
instead. Fix the mistake.

Differential Revision: https://phab.mercurial-scm.org/D384
2017-08-14 11:20:06 +02:00
Martin von Zweigbergk
5eeba3ed86 exchange: simplify unbundle locking using context managers
Differential Revision: https://phab.mercurial-scm.org/D393
2017-07-28 22:04:27 -07:00
Martin von Zweigbergk
e5ad1ba424 util: add base class for transactional context managers
We have at least three types with a close() and a release() method
where the close() method is supposed to be called on success and the
release() method is supposed to be called last, whether successful or
not. Two of them (transaction and dirstateguard) already have
identical implementations of __enter__ and __exit__. Let's extract a
base class for this, so we reuse the code and so the third type
(transactionmanager) can also be used as a context manager.

Differential Revision: https://phab.mercurial-scm.org/D392
2017-07-28 22:42:10 -07:00
Martin von Zweigbergk
503fee4003 exchange: remove need for "locked" variable
The transactionmanager() constructor just assigned a few variables and
cannot fail, so it's safe to move it inside the earlier try/except.

Differential Revision: https://phab.mercurial-scm.org/D391
2017-08-14 16:26:36 -07:00
Martin von Zweigbergk
2fd87dee7c exchange: drop now-unnecessary "local" from lock name variables
Since 6f17bd68a306 (exchange: drop support for lock-based unbundling
(BC), 2017-08-06), there is no more remote locking.

Differential Revision: https://phab.mercurial-scm.org/D390
2017-08-14 16:14:14 -07:00
Martin von Zweigbergk
96b9a2c44e exchange: remove 'locallocked' member from pushop object
The variable has been used only within a single function since
5d683cc9670f (push: elevate phase transaction to cover entire
operation, 2014-11-21), so there's no need to keep it on the pushop
object.

Differential Revision: https://phab.mercurial-scm.org/D389
2017-07-28 21:49:44 -07:00
Boris Feld
61f35b42fd label: rename log.trouble into log.instability
The renaming is done according to
https://www.mercurial-scm.org/wiki/CEDVocabulary.

Differential Revision: https://phab.mercurial-scm.org/D259
2017-08-03 15:31:54 +02:00
Boris Feld
d833c9f0c7 label: rename trouble.X into instability.X
The renaming is done according to
https://www.mercurial-scm.org/wiki/CEDVocabulary.

Differential Revision: https://phab.mercurial-scm.org/D258
2017-08-03 15:30:41 +02:00
Boris Feld
bd1b933a37 label: rename changeset.troubled into changeset.unstable
The renaming is done according to
https://www.mercurial-scm.org/wiki/CEDVocabulary.

Differential Revision: https://phab.mercurial-scm.org/D257
2017-08-03 14:32:50 +02:00
Boris Feld
971a5a6f59 obsolete: rename bumped volatile set into phasedivergent volatile set
The renaming is done according to
https://www.mercurial-scm.org/wiki/CEDVocabulary.

Differential Revision: https://phab.mercurial-scm.org/D255
2017-08-04 19:39:34 +02:00
Boris Feld
ac541e6eb8 obsolete: rename divergent volatile set into contentdivergent volatile set
The renaming is done according to
https://www.mercurial-scm.org/wiki/CEDVocabulary.

Differential Revision: https://phab.mercurial-scm.org/D254
2017-08-04 19:36:27 +02:00
Boris Feld
98e598e611 obsolete: rename unstable volatile set into orphan volatile set
The renaming is done according to
https://www.mercurial-scm.org/wiki/CEDVocabulary.

Differential Revision: https://phab.mercurial-scm.org/D253
2017-08-04 19:27:39 +02:00
Boris Feld
5489bbeda4 revset: rename bumped into phasedivergent
Don't touch bumped volatile set name, only the revset name. The volatile set
name will be updated in a later patch.

The renaming is done according to
https://www.mercurial-scm.org/wiki/CEDVocabulary.

Differential Revision: https://phab.mercurial-scm.org/D252
2017-08-03 14:08:39 +02:00
Boris Feld
cf0c39bfeb revset: remane divergent into contentdivergent
Don't touch divergent volatile set name, only the revset name. The volatile
set name will be updated in a later patch.

The renaming is done according to
https://www.mercurial-scm.org/wiki/CEDVocabulary.

Differential Revision: https://phab.mercurial-scm.org/D251
2017-08-03 14:01:51 +02:00
Boris Feld
aaaa0c98dc revset: rename unstable into orphan
Don't touch unstable volatile set name, only the revset name. The volatile set
name will be updated in a later patch.

The renaming is done according to
https://www.mercurial-scm.org/wiki/CEDVocabulary.

Differential Revision: https://phab.mercurial-scm.org/D250
2017-08-03 13:48:39 +02:00
Boris Feld
7f8b0aa44f config: rename evolution config into stabilization
Use aliases for backward-compatibility. Though I'm not sure how to emit
compatibility warnings with aliases.

Test configuration are updated in the next patch.

The renaming is done according to
https://www.mercurial-scm.org/wiki/CEDVocabulary.

Differential Revision: https://phab.mercurial-scm.org/D248
2017-08-03 11:38:22 +02:00
Pulkit Goyal
3f92988eda morestatus: move fb extension to core by plugging to hg status --verbose
morestatus extension in fbext use to show more context about the state of the
repo like the repository is in a unfinished merge state, or a rebase is going
on, or histedit is going on, listing the files which need to be resolved and
also suggesting ways to handle the situation.

This patch moves the extension directly to core by plugging it into the
--verbose flag of the status command. So now if you are in any unfinished state
and you do hg status -v, it will show you details and help related to the state.

The extension in fbext also shows context about unfinished update state
which is not ported to core as that plug in hooks to update command which need
to be tackled somewhat differently.

The following configuration will turn the behaviour on by default

[commands]
status.verbose = 1

You can also skip considering some states like bisect as follows:

[commands]
status.skipstates=bisect

This patch also adds test for the feature.

.. feature::

   ``hg status -v`` can now show unfinished state. For example, when in
   an unfinished rebase state, ``hg status -v`` might show::

   # The repository is in an unfinished *rebase* state.
   # No unresolved merge conflicts.
   # To continue:                hg rebase --continue
   # To abort:                   hg rebase --abort

Differential Revision: https://phab.mercurial-scm.org/D219
2017-08-03 05:12:35 +05:30