Commit Graph

18744 Commits

Author SHA1 Message Date
Wagner Bruna
d0831e7086 help: fix typos 2017-05-31 19:23:23 -03:00
FUJIWARA Katsunori
80da112aee win32mbcs: avoid unintentional failure at colorization
Since 1d07d9da84a0, pycompat.bytestr() wrapped by win32mbcs returns
unicode object, if an argument is not byte-str object. And this causes
unexpected failure at colorization.

pycompat.bytestr() is used to convert from color effect "int" value to
byte-str object in color module. Wrapped pycompat.bytestr() returns
unicode object for such "int" value, because it isn't byte-str.

If this returned unicode object is used to colorize non-ASCII byte-str
in cases below, UnicodeDecodeError is raised at an operation between
them.

  - colorization uses "ansi" color mode, or

    Even though this isn't default on Windows, user might use this
    color mode for third party pager.

  - ui.write() is buffered with labeled=True

    Buffering causes "ansi" color mode internally, regardless of
    actual color mode. With "win32" color mode, extra escape sequences
    are omitted at writing data out.

    For example, with "win32" color mode, "hg status" doesn't fail for
    non-ASCII filenames, but "hg log" does for non-ASCII text, because
    the latter implies buffered formatter.

There are many "color effect" value lines in color.py, and making them
byte-str objects isn't suitable for fixing on stable. In addition to
it, pycompat.bytestr will be used to get byte-str object from any
types other than int, too.

To resolve this issue, this patch does:

  - replace pycompat.bytestr in checkwinfilename() with newly added
    hook point util._filenamebytestr, and

  - make win32mbcs reverse-wrap util._filenamebytestr
    (this is a replacement of 1d07d9da84a0)

This patch does two things above at same time, because separately
applying the former change adds broken revision (from point of view of
win32mbcs) to stable branch.

"_" prefix is added to "filenamebytestr", because it is win32mbcs
specific hook point.
2017-05-31 23:44:33 +09:00
Gregory Szorc
3156c627f0 exchange: print full reason variable
This commit essentially reverts 62ad9c1dbce9.

urllib2.URLError receives a "reason" argument. It isn't always a
tuple. Mozilla has experienced at least IndexError failures due
to the reason[1] access.
https://bugzilla.mozilla.org/show_bug.cgi?id=1364687
2017-05-24 15:25:24 -07:00
FUJIWARA Katsunori
6e23c59850 dispatch: setup color before pager for correct console information on windows
Before this patch, "hg CMD --pager on" on Windows shows output
unintentionally decorated with ANSI color escape sequences, if color
mode is "auto". This issue occurs in steps below.

  1. dispatch() invokes ui.pager() at detection of "--pager on"
  2. stdout of hg process is redirected into stdin of pager process
  3. "ui.formatted" = True, because isatty(stdout) is so before (2)
  4. color module is loaded for colorization
  5. color.w32effects = None, because GetConsoleScreenBufferInfo()
     fails on stdout redirected at (2)
  6. "ansi" color mode is chosen, because of "not w32effects"
  7. output is colorized in "ansi" mode because of "ui.formatted" = True

Even if "ansi" color mode is chosen, ordinarily redirected stdout
makes ui.formatted() return False, and colorization is avoided. But in
this issue case, "ui.formatted" = True at (3) forces output to be
colorized.

For correct console information on win32, it is needed to ensure that
color module is loaded before redirection of stdout for pagination.

BTW, if any of enabled extensions has "colortable" attribute, this
issue is avoided even before this patch, because color module is
imported as a part of loading such extension, and extension loading
occurs before setting up pager. For example, mq and keyword have
"colortable".
2017-05-23 03:29:23 +09:00
Pierre-Yves David
8f0cd8c82a obsolete: invalidate "volatile" set cache after merging marker
Adding markers to the repository might affect the set of obsolete changesets. So we
most remove the "volatile" set who rely in that data. We add two missing
invalidations after merging markers. This was caught by code change in the evolve
extensions tests.

This issues highlight that the current way to do things is a bit fragile,
however we keep things simple for stable.
2017-05-17 15:39:37 +02:00
Mads Kiilerich
d682210796 graft: fix graft across merges of duplicates of grafted changes
Graft used findmissingrevs to find the candidates for graft duplicates in the
destination. That function operates with the constraint:

  1. N is an ancestor of some node in 'heads'
  2. N is not an ancestor of any node in 'common'

For our purpose, we do however have to work correctly in cases where the graft
set has multiple roots or where merges between graft ranges are skipped. The
only changesets we can be sure doesn't have ancestors that are grafts of any
changeset in the graftset, are the ones that are common ancestors of *all*
changesets in the graftset. We thus need:

  2. N is not an ancestor of all nodes in 'common'

This change will graft more correctly, but it will also in some cases make
graft slower by making it search through a bigger and unnecessary large sets of
changes to find duplicates. In the general case of grafting individual or
linear sets, we do the same amount of work as before.
2017-05-11 17:18:40 +02:00
Gregory Szorc
3ffdc76e66 sslutil: reference fingerprints config option properly (issue5559)
The config option is "host:fingerprints" not "host.fingerprints".

This warning message is bad and misleads users.
2017-05-08 09:30:26 -07:00
Martin von Zweigbergk
4d9ae1bf1a bitmanipulation: add missing include of string.h
That's where memcpy() is declared.
2017-06-02 10:32:39 -07:00
Pulkit Goyal
4dc6c9b676 py3: implement __bytes__ for committablectx
Before this method, calling bytes on workingctx or memctx calls
basectx.__bytes__ since the magic method was not defined for this class. When it
calls the method from basectx class, it returns TypeError because None is passed
into it.

After this commit `hg update -C` works on Python 3 if eol is not enabled.
2017-06-01 02:25:18 +05:30
Pulkit Goyal
2e30032f2c py3: convert exception to bytes to pass into ui.warn()
Here encoding.strtolocal() is used because exc maybe an IOError which could
contain a valid non-ascii unicode.
2017-06-02 10:35:21 +05:30
Pulkit Goyal
3708dfc09e py3: convert bool variables to bytes before passing into ui.debug()
We can't pass unicodes to ui.debug() and hence we need to convert things to
bytes before passing them.
2017-06-01 02:14:26 +05:30
Pulkit Goyal
b73ca160f7 py3: use dict.update() instead of constructing lists and adding them
dict.items() returned a list on Python 2 and whereas on Python 3 it returns a
view object. So we required a work around. Using dict.update() is better then
constructing lists as it should save us on gc churns.
2017-06-01 01:14:02 +05:30
FUJIWARA Katsunori
b7a92ca8d3 help: describe about choice of :prompt as a fallback merge tool explicitly
"merge-tools" help topic has described that the merge of the file
fails if no tool is found to merge binary or symlink, since
9da9bced2226 (or Mercurial 1.7), which based on (already removed)
MergeProgram wiki page.

But even at that revision, and of course now, merge of the file
doesn't fail automatically for binary/symlink. ":prompt" (or
equivalent logic) is used, if there is no appropriate tool
configuration for binary/symlink.
2017-05-06 02:33:00 +09:00
Matt Harbison
8f2d75af2f help: call out specific replacement configuration settings
As an aside, I'm having trouble parsing the help text meaning for HG when it is
unset or empty.  How can it be the frozen name or searched if it is empty?
2017-05-03 22:56:53 -04:00
Matt Harbison
44c7a911a4 help: spelling fixes 2017-05-03 22:07:47 -04:00
Matt Harbison
f50de2183a help: attempt to clarify that pager usage is not output length based
This may be too subtle of a change to get the point across, but when I first
read the original text, I thought maybe the pager would only be invoked if
writing more than a screenful.  The distinction between this and a pager that
simply exits after printing less than a screenful is important on Windows, given
the inability of `more` to color output.
2017-05-03 22:05:23 -04:00
Matt Harbison
ed8a9665e2 help: document color/pager pitfalls on Windows
Even though I figured this out a few weeks ago, I was initially puzzled where
the color went when I upgraded to 4.2 on a different Windows machine.  Let's
point users reading the help into the right direction.

I wonder if we should be even more explicit about cmd.exe/MSYS/pager/color
interplay, but at least all of the breadcrumbs are here (I think).
2017-05-03 21:58:11 -04:00
Pierre-Yves David
a5a7702af1 pager: drop the support for 'pager.enable=<bool>'
This option was never released except for a release candidate. Dropping
compatibility with this option will free the 'pager.enable' config option for
other usage in the future.
2017-05-02 17:18:13 +02:00
Pierre-Yves David
bf9fa9e05b pager: rename 'pager.enable' to 'ui.paginate'
This aligns with what we do for color (see cea7a760c58d). Pager is a central
enough notion that having the master config in the [ui] section makes senses. It
will helps with consistency, discoverability. It will also help having a simple
and clear example hgrc mentioning pager.

The previous form of the option had never been released in a non-rc version but
we keep it around for convenience. If both are set, 'ui.pager' take priority.
2017-05-01 16:36:50 +02:00
Pierre-Yves David
f6556e7dce color: special case 'always' in 'ui.color'
This lift the confusing case, where 'ui.color=always' would actually not always
use color.
2017-05-02 20:19:09 +02:00
Pierre-Yves David
9b05154b04 color: turn 'ui.color' into a boolean (auto or off)
Previously, 'ui.color=yes' meant "always show color", While
"ui.color=auto" meant "use color automatically when it appears
sensible".

This feels problematic to some people because if an administrator has
disabled color with "ui.color=off", and a user turn it back  on using
"color=on", it will get surprised (because it breaks their output when
redirected to a file.) This patch changes ui.color=true to only move the
default value of --color from "never" to "auto".

I'm not really in favor of this changes as I suspect the above case will
be pretty rare and I would rather keep the logic simpler. However, I'm
providing this patch to help the 4.2 release in the case were others
decide to make this changes.

Users that want to force colors without specifying --color on the
command line can use the 'ui.formatted' config knob, which had to be
enabled in a handful of tests for this patch.

Nice summary table (credit: Augie Fackler)

That is, before this patch:

+--------------------+--------------------+--------------------+
|                    | not a tty          | a tty              |
|                    | --color not set    | --color not set    |
|                    |                    |                    |
+--------------------+--------------------+--------------------+
| [ui]               |                    |                    |
| color (not set)    | no color           | no color           |
|                    |                    |                    |
+--------------------+--------------------+--------------------+
| [ui]               |                    |                    |
| color = auto       | no color           | color              |
|                    |                    |                    |
+--------------------+--------------------+--------------------+
| [ui]               |                    |                    |
| color = yes        | *color*            | color              |
|                    |                    |                    |
+--------------------+--------------------+--------------------+
| [ui]               |                    |                    |
| color = no         | no color           | no color           |
|                    |                    |                    |
+--------------------+--------------------+--------------------+
(if --color is specified, it always clobbers the setting in [ui])

and after this patch:

+--------------------+--------------------+--------------------+
|                    | not a tty          | a tty              |
|                    | --color not set    | --color not set    |
|                    |                    |                    |
+--------------------+--------------------+--------------------+
| [ui]               |                    |                    |
| color (not set)    | no color           | no color           |
|                    |                    |                    |
+--------------------+--------------------+--------------------+
| [ui]               |                    |                    |
| color = auto       | no color           | color              |
|                    |                    |                    |
+--------------------+--------------------+--------------------+
| [ui]               |                    |                    |
| color = yes        | *no color*         | color              |
|                    |                    |                    |
+--------------------+--------------------+--------------------+
| [ui]               |                    |                    |
| color = no         | no color           | no color           |
|                    |                    |                    |
+--------------------+--------------------+--------------------+
(if --color is specified, it always clobbers the setting in [ui])
2017-05-02 20:01:54 +02:00
Pierre-Yves David
28b8d7eb26 pager: document the 'pager.enable' option
The 'config' helps was missing help about pager enabling/disabling.
2017-05-01 16:43:43 +02:00
Pierre-Yves David
50e449e083 pager: advertise the config option in the default hgrc
Same as for 'ui.color', this is a critical part of the UI and we want user to
find this config knob easily.
2017-05-01 18:07:23 +02:00
Pierre-Yves David
ba569a8325 pager: document the 'pager' config section
There as a 'hg help pager' section but the 'hg help config.pager' was missing.
2017-05-01 16:52:11 +02:00
Pierre-Yves David
0600a78b19 config: drop pager from the recommended extension
The extension is deprecated, we should having exposing it to users.
2017-05-01 15:51:57 +02:00
Pierre-Yves David
c674366f10 config: use "churn" as an example extension
"Churn" is not the useful example we have, but this is the one used in
'hg help config.extensions'. As we need something to replace the deprecated
'pager' extension in the example config, we are adding 'churn'.
2017-05-01 15:51:47 +02:00
Yuya Nishihara
532f16e237 discovery: prevent crash caused by prune marker having no parent data
If a marker has no parent information, parents field is set to None, which
caused TypeError. I think this shouldn't normally happen, but somehow
I have such marker in my repo.
2017-04-19 23:10:05 +09:00
Pierre-Yves David
39d62892b4 color: point to the global help in the example hgrc
This is probably the best way to have users learn more is they need too.
2017-05-01 15:40:41 +02:00
Pierre-Yves David
d8acfa70c4 color: reflect the new default in the example hgrc
Color is enabled by default so un-commenting the line would not have any effect.
We'll point to the help in the next changeset.
2017-05-01 15:39:50 +02:00
Pierre-Yves David
6a7374c4a8 color: point to the config help in global help topic
We point out at the help of the config option for user who wants to learn more
about the possible config value.

The suggested command returns some other extra (color related) results, but this
is bug to fix outside of the freeze.
2017-05-01 15:38:57 +02:00
Pierre-Yves David
d12d7fe72c color: reflect the new default in global help topic
We point out that color is enabled by default.
2017-05-01 15:38:07 +02:00
Martin von Zweigbergk
7f6a3bb427 docs: describe ui.color consistently with --color
The --color option is described to accept "boolean, always, auto,
never, or debug". Let's use a similar description for ui.color. Also
fix the formatting to use double quotes as we seem to use for about
half the values in config.txt (the other half uses double
backticks). Also use uppercase Boolean for consistency within the
file.
2017-05-01 11:04:10 -07:00
FUJIWARA Katsunori
8f34219d1a lock: avoid unintentional lock acquisition at failure of readlock
Acquiring lock by vfs.makelock() and getting lock holder (aka
"locker") information by vfs.readlock() aren't atomic action.
Therefore, failure of the former doesn't ensure success of the latter.

Before this patch, lock is unintentionally acquired, if ENOENT
causes failure of vfs.readlock() while 5 times retrying, because
lock._trylock() returns to caller silently after retrying, and
lock.lock() assumes that lock._trylock() returns successfully only if
lock is acquired.

In this case, lock symlink (or file) isn't created, even though lock
is treated as acquired in memory.

To avoid this issue, this patch makes lock._trylock() raise
LockHeld(EAGAIN) at the end of it, if lock isn't acquired while
retrying.

An empty "locker" meaning "busy for frequent lock/unlock by many
processes" might appear in an abortion message, if lock acquisition
fails. Therefore, this patch also does:

  - use '%r' to increase visibility of "locker", even if it is empty
  - show hint message to explain what empty "locker" means
2017-05-01 19:59:13 +09:00
FUJIWARA Katsunori
cb1cfe7f12 lock: avoid unintentional lock acquisition at failure of readlock
Acquiring lock by vfs.makelock() and getting lock holder (aka
"locker") information by vfs.readlock() aren't atomic action.
Therefore, failure of the former doesn't ensure success of the latter.

Before this patch, lock is unintentionally acquired, if
self.parentlock is None (this is default value), and lock._readlock()
returns None for ENOENT at vfs.readlock(), because these None are
recognized as equal to each other.

In this case, lock symlink (or file) isn't created, even though lock
is treated as acquired in memory.

To avoid this issue, this patch retries lock acquisition immediately,
if lock._readlock() returns None "locker".

This issue will be covered by a test added in subsequent patch,
because simple emulation of ENOENT at vfs.readlock() easily causes
another issue.  "raising ENOENT only at the first vfs.readlock()
invocation" is too complicated for unit test, IMHO.
2017-05-01 19:58:52 +09:00
FUJIWARA Katsunori
60903a6565 httppeer: unify hint message for PeerTransportError
Another raising PeerTransportError for "incomplete response" in
httppeer.py uses this (changed) hint message. This unification reduces
cost of translation.
2017-05-01 05:52:36 +09:00
FUJIWARA Katsunori
1ff2143781 revset: add i18n comments to error messages for followlines predicate
This patch also includes un-quoting "descend" keyword for similarity
to other error messages (this seems too trivial as a separated patch).
2017-05-01 05:52:36 +09:00
FUJIWARA Katsunori
6eec3cc46a help: apply bulk fixes for indentation and literal blocking issues
There are some paragraphs, which aren't rendered in online help as
expected because of indentation and literal blocking issues.

- hgext/rebase.py

  - paragraph before example code ends with ":", which treats
    subsequent indented paragraphs as normal block

    => replace ":" with "::" to treat subsequent paragraphs as literal block

- help/pager.txt

  - paragraph before a list of --pager option values ends with "::",
    which treats subsequent indented paragraphs as literal block

    => replace "::" with ":" to treat subsequent paragraphs as normal block

  - the second line of explanation for no/off --pager option value is
    indented incorrectly (this also causes failure of "make" in doc)

    => indent correctly

- help/revisions.txt

  - explanation following example code of "[revsetalias]" section
    isn't suitable for literal block

    => un-indent explanation paragraph to treat it as normal block

  - indentation of "For example" before example of tag() revset
    predicate matching is meaningless

  - descriptive text for tag() revset predicate matching isn't
    suitable for literal block

    => un-indent concatenated two paragraphs to treat them as normal block
2017-05-01 05:52:32 +09:00
FUJIWARA Katsunori
625808858d help: use hg role of mini reST to make hyper link in HTML page 2017-05-01 05:38:52 +09:00
FUJIWARA Katsunori
3c93d9ace7 help: use mercurial as a subject of colorization and pagination
Now, colorization and pagination are in Mercurial core.
2017-05-01 05:35:57 +09:00
Yuya Nishihara
c11e91f8ff pager: use less as a fallback on Unix
This seems reasonable choice per discussion, and the default-default of Git.
See also the inline-comment for why.

https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-April/097042.html
2017-04-28 20:51:14 +09:00
Matt DeVore
212fc81929 help: explain how to access subtopics in internals 2017-04-19 17:04:22 -07:00
Matt DeVore
2eace305ec log: document the characters ---graph uses to draw
The meaning of : vs | was undocumented and non-obvious.
2017-04-18 14:51:32 -07:00
Denis Laxalde
82be200bb6 hgweb: change text of followlines links to "older / newer"
DAG directions "descending" / "ascending" arguably do not make much sense in
the web interface where changes are usually listed by "dates".
2017-04-24 10:48:07 +02:00
Denis Laxalde
d141711562 hgweb: do not show "descending" link in followlines UI for filelog heads
When on a filelog head, we are certain that there will be no descendant so the
target of the "descending" link will lead to an empty log result. Do not
display the link in this case.
2017-04-24 10:32:15 +02:00
Denis Laxalde
d7d47fec65 context: optimize linkrev adjustment in blockancestors() (issue5538)
We set parent._descendantrev = child.rev() when walking parents in
blockancestors() so that, when linkrev adjustment is perform for these, it
starts from a close descendant instead of possibly topmost introrev. (See
`self._adjustlinkrev(self._descendantrev)` in filectx._changeid().)

This is similar to changeset 8758896efb1c, which added a "f._changeid"
instruction in annotate() for the same purpose.
However, here, we set _descendantrev explicitly instead of relying on the
'_changeid' cached property being accessed (with effect to set _changeid
attribute) so that, in _parentfilectx() (called from parents()), we go through
`if '_changeid' in vars(self) [...]` branch in which instruction
`fctx._descendantrev = self.rev()` finally appears and does what we want.

With this, we can roughly get a 3x speedup (including in example of issue5538
from mozilla-central repository) on usage of followlines revset (and
equivalent hgweb request).
2017-04-24 18:33:23 +02:00
Boris Feld
46290fc257 record: update help message to use operation instead of "record" (issue5432)
Update the hunk selector help message to use the operation name instead
of using "record" for all operations. Extract the help message in the same way
as other single and multiple message line.
Update tests to make sure that both "revert" and "discard" variants are tested.
2017-04-24 17:13:24 +02:00
Denis Laxalde
7cc06d2fbf context: start walking from "introrev" in blockancestors()
Previously, calling blockancestors() with a fctx not touching file would
sometimes yield this filectx first, instead of the first "block ancestor",
because when compared to its parent it may have changes in specified line
range despite not touching the file at all.

Fixing this by starting the algorithm from the "base" filectx obtained using
fctx.introrev() (as done in annotate()).

In tests, add a changeset not touching file we want to follow lines of to
cover this case. Do this in test-annotate.t for followlines revset tests and
in test-hgweb-filelog.t for /log/<rev>/<file>?linerange=<from>:<to> tests.
2017-04-20 21:40:28 +02:00
Augie Fackler
2f7c844e98 sshpeer: try harder to snag stderr when stdout closes unexpectedly
Resolves test failures on FreeBSD, but I'm not happy about the fix.

A previous version of this also wrapped readline by putting the hack
in the _call method on doublepipe. That was confusing for readers and
wasn't necessary - just doing this on read() is sufficient to fix the
bugs I'm observing. We can always come back and do readline later if
needed.
2017-04-13 16:09:40 -04:00
Gregory Szorc
1c728c872c show: add basic labels to work template
`hg show work` is much more usable if output is colored. This patch
implements coloring via label() in a very hacky way.

In a default Mercurial install, you'll see yellow node labels for all
phases. Branches and bookmarks use the same formatting as the commit
message. So this change doesn't help much in a default install. But if
you have a custom colors defined for these things, output is much more
readable.

The implementation obviously needs some work. But for a minor change
on a feature that isn't convered by BC, this seems like a clear win
for the feature in 4.2.
2017-04-18 11:10:08 -07:00
Gregory Szorc
a0449ff50c show: rename "underway" to "work"
Durham and I both like this better than "underway." We can add aliases
and bikeshed on the name during the 4.3 cycle, as this whole extension is
highly experimental.
2017-04-18 10:49:46 -07:00
Augie Fackler
3d0bf6c892 freeze: merge default into stable for 4.2 code freeze 2017-04-18 12:24:34 -04:00
Augie Fackler
78231e34ab Merge stable with security patch. 2017-04-18 11:22:42 -04:00
Yuya Nishihara
e76c15f04b progress: retry ferr.flush() and .write() on EINTR (issue5532)
See the inline comment how this could mitigate the issue.

I couldn't reproduce the exact problem on my Linux machine, but there are
at least two people who got EINTR in progress.py, and it seems file_write()
of Python 2 is fundamentally broken [1]. Let's make something in on 4.2.

 [1]: https://hg.python.org/cpython/file/v2.7.13/Objects/fileobject.c#l1850
2017-04-13 22:31:17 +09:00
Yuya Nishihara
71733ed667 progress: extract stubs to restart ferr.flush() and .write() on EINTR 2017-04-13 22:27:25 +09:00
Augie Fackler
b2bd435955 dispatch: protect against malicious 'hg serve --stdio' invocations (sec)
Some shared-ssh installations assume that 'hg serve --stdio' is a safe
command to run for minimally trusted users. Unfortunately, the messy
implementation of argument parsing here meant that trying to access a
repo named '--debugger' would give the user a pdb prompt, thereby
sidestepping any hoped-for sandboxing. Serving repositories over HTTP(S)
is unaffected.

We're not currently hardening any subcommands other than 'serve'. If
your service exposes other commands to users with arbitrary repository
names, it is imperative that you defend against repository names of
'--debugger' and anything starting with '--config'.

The read-only mode of hg-ssh stopped working because it provided its hook
configuration to "hg serve --stdio" via --config parameter. This is banned for
security reasons now. This patch switches it to directly call ui.setconfig().
If your custom hosting infrastructure relies on passing --config to
"hg serve --stdio", you'll need to find a different way to get that configuration
into Mercurial, either by using ui.setconfig() as hg-ssh does in this patch,
or by placing an hgrc file someplace where Mercurial will read it.

mitrandir@fb.com provided some extra fixes for the dispatch code and
for hg-ssh in places that I overlooked.
2017-04-12 11:23:55 -07:00
Gregory Szorc
34d4f7ff46 repair: use rawvfs when copying extra store files
If we use the normal vfs, store encoding will be applied when we
.join() the path to be copied. This results in attempting to copy
a file that (likely) doesn't exist. Using the rawvfs operates on
the raw file path, which is returned by vfs.readdir().

Users at Mozilla are encountering this, as I've instructed them to
run `hg debugupgraderepo` to upgrade to generaldelta. While Mercurial
shouldn't deposit any files under .hg/store that require encoding, it
is possible for e.g. .DS_Store files to be created by the operating
system.
2017-04-08 11:36:39 -07:00
Gregory Szorc
a205e76c91 repair: iterate store files deterministically
An upcoming test will add a 2nd file. Since readdir() is
non-deterministic, add a sorted() to make traversal deterministic.
2017-04-08 11:35:00 -07:00
Gregory Szorc
6fb64a9cca changegroup: store old heads as a set
Previously, the "oldheads" variable was a list. On a repository at
Mozilla with 46,492 heads, profiling revealed that list membership
testing was dominating execution time of applying small changegroups.

This patch converts the list of old heads to a set. This makes
membership testing significantly faster. On the aforementioned
repository with 46,492 heads:

$ hg unbundle <file with 1 changeset>
before: 18.535s wall
after:   1.303s

Consumers of this variable only check for truthiness (`if oldheads`),
length (`len(oldheads)`), and (most importantly) item membership
(`h not in oldheads` - which occurs twice). So, the change to a set
should be safe and suitable for stable.

The practical effect of this change is that changegroup application
and related operations (like `hg push`) no longer exhibit an O(n^2)
CPU explosion as the number of heads grows.
2017-03-23 19:54:59 -07:00
Simon Farnsworth
ddbe7287e7 subrepo: move prompts out of the if (issue5505)
Prompts weren't available in the else clause
2017-03-20 04:36:55 -07:00
Gregory Szorc
aff9286eb0 exchange: use v2 bundles for modern compression engines (issue5506)
Previously, `hg bundle zstd` on a non-generaldelta repo would
attempt to use a v1 bundle. This would fail because zstd is not
supported on v1 bundles.

This patch changes the behavior to automatically use a v2 bundle
when the user explicitly requests a bundlespec that is a compression
engine not supported on v1. If the bundlespec is <engine>-v1, it is
still explicitly rejected because that request cannot be fulfilled.
2017-03-16 12:33:15 -07:00
Gregory Szorc
3bbb6e2c52 exchange: reject new compression engines for v1 bundles (issue5506)
Version 1 bundles only support a fixed set of compression engines.
Before this change, we would accept any compression engine for v1
bundles, even those that may not work on v1. This could lead to
an error.

We define a fixed set of compression engines known to work with v1
bundles and we add checking to ensure a newer engine (like zstd)
won't work with v1 bundles.

I also took the liberty of adding test coverage for unknown compression
names because I noticed we didn't have coverage of it before.
2017-03-16 12:23:56 -07:00
Augie Fackler
5811358454 pycompat: verify sys.argv exists before forwarding it (issue5493)
ISAPI_WSGI doesn't set up sys.argv, so we have to look for the
attribute before assuming it exists.
2017-03-07 13:24:24 -05:00
Yuya Nishihara
8af2b4d601 filemerge: optionally strip quotes from merge marker template (BC)
For consistency with the other template options. Quotes are necessary if
you want to preserve leading/trailing whitespace, which would be stripped
by config parser.
2017-02-25 19:36:02 +09:00
Yuya Nishihara
9466c3179f commit: optionally strip quotes from commit template (BC)
For consistency with the other template options.
2017-02-25 19:32:39 +09:00
Yuya Nishihara
5fbb2d3cd5 graphlog: optionally strip quotes from graphnode template (BC)
For consistency with the other template options.
2017-02-25 19:28:16 +09:00
Yuya Nishihara
649f9bf987 dispatch: ignore further SIGPIPE while handling KeyboardInterrupt
I got the following error by running "hg log" and quitting the pager
immediately. Any output here may trigger another SIGPIPE, so only thing
we can do is to swallow the exception and exit with an error status.

  Traceback (most recent call last):
    File "./hg", line 45, in <module>
      mercurial.dispatch.run()
    File "mercurial/dispatch.py", line 83, in run
      status = (dispatch(req) or 0) & 255
    File "mercurial/dispatch.py", line 167, in dispatch
      req.ui.warn(_("interrupted!\n"))
    File "mercurial/ui.py", line 1224, in warn
      self.write_err(*msg, **opts)
    File "mercurial/ui.py", line 790, in write_err
      self._write_err(*msgs, **opts)
    File "mercurial/ui.py", line 798, in _write_err
      self.ferr.write(a)
    File "mercurial/ui.py", line 129, in _catchterm
      raise error.SignalInterrupt
  mercurial.error.SignalInterrupt

Perhaps this wasn't visible before ee4f321cd621 because the original stderr
handle was restored very late.
2017-04-17 23:53:19 +09:00
Yuya Nishihara
b132ffa375 worker: print traceback for uncaught exception unconditionally
This is what a Python interpreter would do if there were no os._exit().
2017-04-15 13:04:55 +09:00
Yuya Nishihara
7144ff068f worker: propagate exit code to main process
Follows up 560cc0db7f01.
2017-04-15 13:27:44 +09:00
Yuya Nishihara
aabbe05fb5 dispatch: print traceback in scmutil.callcatch() if --traceback specified
Otherwise, traceback wouldn't be printed for a known exception occurred in
worker processes.
2017-04-15 13:02:34 +09:00
Yuya Nishihara
1ea92e7f19 dispatch: mark callcatch() as a private function 2017-04-15 12:58:06 +09:00
Yuya Nishihara
e952ac99ea templatefilters: fix crash by string formatting of '{x|splitlines}'
Before, it crashed because mapping['templ'] was missing. As it didn't support
the legacy list template from the beginning, we can simply use hybridlist().
2017-04-15 10:51:17 +09:00
Yuya Nishihara
3a01d624e0 templatekw: factor out showdict() helper
Make it less cryptic for common cases.
2017-04-05 21:57:05 +09:00
Yuya Nishihara
e83ec90299 templatekw: have showlist() take mapping dict with no **kwargs expansion (API)
See the previous commit for why.

splitlines() does not pass a mapping dict, which would probably mean the
legacy template didn't work from the beginning.
2017-04-05 21:47:34 +09:00
Yuya Nishihara
14174e42d0 templatekw: change _showlist() to take mapping dict with no **kwargs expansion
There was a risk that a template keyword could conflict with an argument
name (e.g. 'name', 'values', 'plural', etc.) Let's make it less magical.
2017-04-05 21:40:38 +09:00
Yuya Nishihara
e7f0402cb5 templatekw: rename 'args' to 'mapping' in showlist()
The name 'args' provides no information. Call it 'mapping' as in templater.py.
2017-04-05 21:32:32 +09:00
Yuya Nishihara
ae7c681de5 templatekw: eliminate unnecessary temporary variable 'names' from _showlist()
Replace 'names' with the optional argument 'plural'.
2017-04-05 21:27:44 +09:00
Pierre-Yves David
257e9cf217 color: update the help with the new default
The default is now "auto" we update the help to match reality.
2017-04-17 20:22:00 +02:00
Pierre-Yves David
c9ad04b92a upgrade: register all format variants in a list
Now that all known format variants exists outside of the function, we can gather
them in a lists. This build a single entry point other code can use (current
target: extensions).

The repository upgrade code is updated to simply use entries from this list.

As a side effect this will also allow extensions to register their own format
variants, to do this "properly" we should introduce a "registrar" for this
category of object. However I prefer to keep this series simple, and that will
be adventure for future time.
2017-04-12 16:48:13 +02:00
Pierre-Yves David
1d4581993a upgrade: move descriptions and selection logic in individual classes
Our goal here is to get top level definition for all the format variants. Having
them defined outside of the function enabled other users of that logic.

They are two keys components of a format variant:

1) the name and various descriptions of its effect,

2) the code that checks if the repo is using this variant and if the config
   enables it.

That second items make us pick a class-based approach, since different variants
requires different code (even if in practice, many can reuse the same logic).
Each variants define its own class that is then used like a singleton.  The
class-based approach also clarify the definitions part a bit since each are
simple assignment in an indented block.

The 'fromdefault' and 'fromconfig' are respectively replaced by a class
attribute and a method to be called at the one place where "fromconfig"
matters.

Overall, they are many viable approach for this, but this is the one I picked.
2017-04-12 16:34:05 +02:00
Pierre-Yves David
62412d4eb9 upgrade: introduce a 'formatvariant' class
The 'deficiency' type has multiple specificities. We create a dedicated class to
host them. More logic will be added incrementally in future changesets.
2017-04-10 23:34:43 +02:00
Pierre-Yves David
285b20d327 upgrade: implement '__hash__' on 'improvement' class
The pythonomicon request its implementation.
2017-04-17 13:07:31 +02:00
Pierre-Yves David
258609b002 upgrade: implement '__ne__' on 'improvement' class
The pythonomicon request its implementation.
2017-04-17 13:07:22 +02:00
Pierre-Yves David
97de39f32f color: also enable by default on windows
I've not found anything related to color + windows on the bug tracker. So I'm
suggesting we get bolder and turn it on for windows too in the release
candidate. We can always backout this changeset if we find serious issue on
windows.
2017-04-16 02:34:08 +02:00
Pierre-Yves David
1a7077c9d6 color: turn on by default (but for windows)
Color support is all in core for a couple of months. I've browsed the bug tracker
without finding any blocker bug. So I'm moving forward and enable color on by
default before '4.2-rc'. In the worse case, having it on in the release
candidate will help us to find blocker bug and we can turn it off for the final
release.

I remember people talking about issue with Windows during the freeze so I'm
keeping it off by default on that OS.

We could do various cleaning of the color used and the label issued.  However
the label are probably already in our backward compatibility envelope since the
color extensions has been around since for ever and I do not think the color
choice themself should be considered BC. So I think we should rather gives color
to all user sooner than later.

A couple of test needs to be updated to avoid having color related control code
spoil the tested output.
2017-04-16 02:32:51 +02:00
Gregory Szorc
79225ac4bc bundle2: ignore errors seeking a bundle after an exception (issue4784)
Many have seen a "stream ended unexpectedly" error. This message is
raised from changegroup.readexactly() when a read(n) operation fails
to return exactly N bytes.

I believe most occurrences of this error in the wild stem from
the code changed in this patch. Before, if bundle2's part applicator
raised an Exception when processing/applying parts, the exception
handler would attempt to iterate the remaining parts. If I/O
during this iteration failed, it would likely raise the
"stream ended unexpectedly" exception.

The problem with this approach is that if we already encountered
an I/O error iterating the bundle2 data during application, then
any further I/O would almost certainly fail. If the original stream
were closed, changegroup.readexactly() would obtain an empty
string, triggering "stream ended unexpectedly" with "got 0." This is
the error message that users would see. What's worse is that the
original I/O related exception would be lost since a new exception
would be raised. This made debugging the actual I/O failure
effectively impossible.

This patch changes the exception handler for bundle2 application to
ignore errors when seeking the underlying stream. When the underlying
error is I/O related, the seek should fail fast and the original
exception will be re-raised. The output changes in
test-http-bad-server.t demonstrate this.

When the underlying error is not I/O related and the stream can be
seeked, the old behavior is preserved.
2017-04-16 11:55:08 -07:00
Gregory Szorc
6b50f59909 error: rename RichIOError to PeerTransportError
This is a more descriptive name. RichIOError was introduced just
hours ago, so it doesn't need to be marked as BC.
2017-04-16 11:12:37 -07:00
Gregory Szorc
4f9cd469df httppeer: don't send empty Vary request header
As part of writing test-http-bad-server.t, I noticed that some
requests include an empty Vary HTTP request header.

The Vary HTTP request header indicates which headers should be taken
into account when determining if a cached response can be used. It also
accepts the special value of "*".

The previous code unconditionally added a Vary header. This could lead
to an empty header value. While I don't believe this violates the HTTP
spec, this is weird and just wastes bytes. So this patch changes
behavior to only send a Vary header when it has a value.

Some low-level wire protocol byte reporting tests changed. In some
cases, the exact point of data termination changed. However, the
behavior being tested - that clients react when the connection is
closed in the middle of an HTTP request line or header - remains
unchanged.
2017-04-16 11:28:02 -07:00
Pierre-Yves David
551d0f8ee6 checkheads: upgrade the obsolescence postprocessing logic (issue4354)
The previous logic had many shortcoming (eg: looking at the head only, not
handling prune, etc...), the new logic use a more robust approach:

For each head, we check if after the push all changesets exclusive to this heads
will be obsolete. If they are, the branch considered be "replaced".

To check if a changeset will be obsolete, we simply checks:

* the changeset phase

* the existence of a marker relevant to the "pushed set" that affects the
  changesets..

This fixes two major issues of the previous algorithm:

* branch partially rewritten (eg: head but not root) are no longer detected as
  replaced,

* Prune are now properly handled.

(This implementation was introduction in the evolve extension, version 6.0.0.)

This new algorithm has an extended number of tests, a basic one is provided
in this patch. The others will be introduced in their own changeset for clarity.

In addition, we stop trying to process heads unknown locally, we do not have
enough data to take an informed decision so we should stop pretending we do.
This reflect a test that is now update.
2017-04-15 02:55:18 +02:00
Pierre-Yves David
d03144db9c hidden: extract the code generating "filtered rev" error for wrapping
The goal is to help experimentation in extensions (ie: evolve) around more
advance messages.
2017-04-15 18:13:10 +02:00
Matt Harbison
6d898e296f serve: add support for Mercurial subrepositories
I've been using `hg serve --web-conf ...` with a simple '/=projects/**' [paths]
configuration for awhile without issue.  Let's ditch the need for the manual
configuration in this case, and limit the repos served to the actual subrepos.

This doesn't attempt to handle the case where a new subrepo appears while the
server is running.  That could probably be handled with a hook if somebody wants
it.  But it's such a rare case, it probably doesn't matter for the temporary
serves.

The main repo is served at '/', just like a repository without subrepos.  I'm
not sure why the duplicate 'adding ...' lines appear on Linux.  They don't
appear on Windows (see 3f4ff1bdf101), so they are optional.

Subrepositories that are configured with '../path' or absolute paths are not
cloneable from the server.  (They aren't cloneable locally either, unless they
also exist at their configured source, perhaps via the share extension.)  They
are still served, so that they can be browsed, or cloned individually.  If we
care about that cloning someday, we can probably just add the extra entries to
the webconf dictionary.  Even if the entries use '../' to escape the root, only
the related subrepositories would end up in the dictionary.
2017-04-15 18:05:40 -04:00
Matt Harbison
0181beb642 hgwebdir: allow a repository to be hosted at "/"
This can be useful in general, but will also be useful for hosting subrepos,
with the main repo at /.
2017-03-31 23:00:41 -04:00
Gregory Szorc
2d0781917d httppeer: eliminate decompressresponse() proxy
Now that the response instance itself is wrapped with error
handling, we no longer need this code. This code became dead
with the previous patch because the added code catches
HTTPException and re-raises as something else.
2017-04-14 00:03:30 -07:00
Gregory Szorc
4958a4d6ca httppeer: wrap HTTPResponse.read() globally
There were a handful of places in the code where HTTPResponse.read()
was called with no explicit error handling or with inconsistent
error handling. In order to eliminate this class of bug, we globally
swap out HTTPResponse.read() with a unified error handler.

I initially attempted to fix all call sites. However, after
going down that rabbit hole, I figured it was best to just change
read() to do what we want. This appears to be a worthwhile
change, as the tests demonstrate many of our uncaught exceptions
go away.

To better represent this class of failure, we introduce a new
error type. The main benefit over IOError is it can hold a hint.
I'm receptive to tweaking its name or inheritance.
2017-04-14 00:33:56 -07:00
Gregory Szorc
8637678d4e phases: emit phases to pushkey protocol in deterministic order
An upcoming test will report exact bytes sent over the wire protocol.
Without this change, the ordering of phases listkey data is
non-deterministic.
2017-04-13 22:12:04 -07:00
Gregory Szorc
2ccb65a5bc keepalive: send HTTP request headers in a deterministic order
An upcoming patch will add low-level testing of the bytes being sent
over the wire. As part of developing that test, I discovered that the
order of headers in HTTP requests wasn't deterministic. This patch
makes the order deterministic to make things easier to test.
2017-04-13 18:04:38 -07:00
Denis Laxalde
9e99218a46 revset: properly parse "descend" argument of followlines()
We parse "descend" symbol as a Boolean using getboolean (prior extraction by
getargsdict already checked that it is a symbol).

In tests, check for error cases and vary Boolean values here and there.
2017-04-15 11:29:42 +02:00
Denis Laxalde
f3c282d63c revsetlang: add a getboolean helper function
This will be used to parse followlines's "descend" argument.
2017-04-15 11:26:09 +02:00
Pierre-Yves David
53505593ab track-tags: write all tag changes to a file
The tag changes information we compute is now written to disk. This gives
hooks full access to that data.

The format picked for that file uses a 2 characters prefix for the action:

    -R: tag removed
    +A: tag added
    -M: tag moved (old value)
    +M: tag moved (new value)

This format allows hooks to easily select the line that matters to them without
having to post process the file too much. Here is a couple of examples:

 * to select all newly tagged changeset, match "^+",
 * to detect tag move, match "^.M",
 * to detect tag deletion, match "-R".

Once again we rely on the fact the tag tests run through all possible
situations to test this change.
2017-03-28 10:15:02 +02:00
Pierre-Yves David
cd08df0c89 track-tags: compute the actual differences between tags pre/post transaction
We now compute the proper actuall differences between tags before and after the
transaction. This catch a couple of false positives in the tests.

The compute the full difference since we are about to make this data available
to hooks in the next changeset.
2017-03-28 10:14:55 +02:00
Pierre-Yves David
ac782d2423 track-tags: introduce first bits of tags tracking during transaction
This changeset introduces detection of tags changes during transaction. When
this happens a 'tag_moved=1' argument is set for hooks, similar to what we do
for bookmarks and phases.

This code is disabled by default as there are still various performance
concerns.  Some require a smarter use of our existing tag caches and some other
require rework around the transaction logic to skip execution when unneeded.
These performance improvements have been delayed, I would like to be able to
experiment and stabilize the feature behavior first.

Later changesets will push the concept further and provide a way for hooks to
know what are the actual changes introduced by the transaction. Similar work
is needed for the other families of changes (bookmark, phase, obsolescence,
etc). Upgrade of the transaction logic will likely be performed at the same
time.

The current code can report some false positive when .hgtags file changes but
resulting tags are unchanged. This will be fixed in the next changeset.

For testing, we simply globally enable a hook in the tag test as all the
possible tag update cases should exist there. A couple of them show the false
positive mentioned above.

See in code documentation for more details.
2017-03-28 06:38:09 +02:00
Pierre-Yves David
0736144919 tags: introduce a function to return a valid fnodes list from revs
This will get used to compare tags between two set of revisions during a
transaction (pre and post heads). The end goal is to be able to track tags
movement in transaction hooks.
2017-03-28 05:06:56 +02:00
Denis Laxalde
631e6988ca context: possibly yield initial fctx in blockdescendants()
If initial 'fctx' has changes in line range with respect to its parents, we
yield it first. This makes 'followlines(..., descend=True)' consistent with
'descendants()' revset which yields the starting revision.

We reuse one iteration of blockancestors() which does exactly what we want.

In test-annotate.t, adjust 'startrev' in one case to cover the situation where
the starting revision does not touch specified line range.
2017-04-14 14:25:06 +02:00
Denis Laxalde
559326afdb context: add an assertion checking linerange consistency in blockdescendants()
If this assertion fails, this indicates a flaw in the algorithm. So fail fast
instead of possibly producing wrong results.

Also extend the target line range in test to catch a merge changeset with all
its parents.
2017-04-14 14:09:26 +02:00
Kostia Balytskyi
64a48b9fb1 windows: add win32com.shell to demandimport ignore list
Module 'appdirs' tries to import win32com.shell (and catch ImportError as an
indication of failure) to check whether some further functionality should
be implemented one or another way [1]. Of course, demandimport lets it down, so
if we want appdirs to work we have to add it to demandimport's ignore list.

The reason we want appdirs to work is becuase it is used by setuptools [2] to
determine egg cache location. Only fairly recent versions of setuptools depend
on this so people don't see this often.


[1] https://github.com/ActiveState/appdirs/blob/master/appdirs.py#L560
[2] aae0a92811/pkg_resources/__init__.py (L1369)
2017-04-14 12:34:26 -07:00
Bryan O'Sullivan
60b68c00eb stdio: raise StdioError if something goes wrong in ui.flush
The prior code used to ignore all errors, which was intended to
deal with a decade-old problem with writing to broken pipes on
Windows.

However, that code inadvertantly went a lot further, making it
impossible to detect *all* I/O errors on stdio ... but only sometimes.

What actually happened was that if Mercurial wrote less than a stdio
buffer's worth of output (the overwhelmingly common case for most
commands), any error that occurred would get swallowed here.  But
if the buffering strategy changed, an unhandled IOError could be
raised from any number of other locations.

Because we now have a top-level StdioError handler, and ui._write
and ui._write_err (and now flush!) will raise that exception, we
have one rational place to detect and handle these errors.
2017-04-11 14:54:12 -07:00
Bryan O'Sullivan
dd48bd8237 stdio: raise StdioError if something goes wrong in ui._write_err
The prior code used to ignore certain classes of error, which was
not the right thing to do.
2017-04-11 14:54:12 -07:00
Bryan O'Sullivan
7b0fee3bf9 stdio: raise StdioError if something goes wrong in ui._write 2017-04-11 14:54:12 -07:00
Bryan O'Sullivan
ebffdb4558 stdio: catch StdioError in dispatch.run and clean up appropriately
We attempt to report what went wrong, and more importantly exit the
program with an error code.

(The exception we catch is not yet raised anywhere in the code.)
2017-04-11 14:54:12 -07:00
Bryan O'Sullivan
84ac0ade7c stdio: add machinery to identify failed stdout/stderr writes
Mercurial currently fails to notice failures to write to stdout or
stderr. A correctly functioning command line tool should detect
this and exit with an error code.

To achieve this, we need a little extra plumbing, which we start
adding here.
2017-04-11 14:54:12 -07:00
Bryan O'Sullivan
287bd28acf atexit: switch to home-grown implementation 2017-04-11 14:54:12 -07:00
Bryan O'Sullivan
0c663fe04d ui: add special-purpose atexit functionality
In spite of its longstanding use, Python's built-in atexit code is
not suitable for Mercurial's purposes, for several reasons:

* Handlers run after application code has finished.

* Because of this, the code that runs handlers swallows exceptions
  (since there's no possible stacktrace to associate errors with).
  If we're lucky, we'll get something spat out to stderr (if stderr
  still works), which of course isn't any use in a big deployment
  where it's important that exceptions get logged and aggregated.

* Mercurial's current atexit handlers make unfortunate assumptions
  about process state (specifically stdio) that, coupled with the
  above problems, make it impossible to deal with certain categories
  of error (try "hg status > /dev/full" on a Linux box).

* In Python 3, the atexit implementation is completely hidden, so
  we can't hijack the platform's atexit code to run handlers at a
  time of our choosing.

As a result, here's a perfectly cromulent atexit-like implementation
over which we have control.  This lets us decide exactly when the
handlers run (after each request has completed), and control what
the process state is when that occurs (and afterwards).
2017-04-11 14:54:12 -07:00
Denis Laxalde
761577866a context: follow all branches in blockdescendants()
In the initial implementation of blockdescendants (and thus followlines(...,
descend=True) revset), only the first branch encountered in descending
direction was followed.

Update the algorithm so that all children of a revision ('x' in code) are
considered. Accordingly, we need to prevent a child revision to be yielded
multiple times when it gets visited through different path, so we skip 'i'
when this occurs. Finally, since we now consider all parents of a possible
child touching a given line range, we take care of yielding the child if it
has a diff in specified line range with at least one of its parent (same logic
as blockancestors()).
2017-04-14 08:55:18 +02:00
Jun Wu
dcf42da6e9 pager: set some environment variables if they're not set
Git did this already [1] [2]. We want this behavior too [3].

This provides a better default user experience (like, supporting colors) if
users have things like "PAGER=less" set, which is not uncommon.

The environment variables are provided by a method so extensions can
override them on demand.

[1]: 6a5ff7acb5/pager.c (L87)
[2]: 6a5ff7acb5/Makefile (L1545)
[3]: https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-March/094780.html
2017-04-13 08:27:19 -07:00
Augie Fackler
fe10e9b912 sshpeer: fix docstring typo 2017-04-13 14:48:18 -04:00
Augie Fackler
6278186d0b util: pass sysstrs to warnings.filterwarnings
Un-breaks the Python 3 build.
2017-04-13 13:12:49 -04:00
Pierre-Yves David
dc3a34b74e vfs: deprecate all old classes in scmutil
Now that all vfs class moved to the vfs module, we can deprecate the old one.
2017-04-03 14:21:38 +02:00
Pierre-Yves David
a185960897 util: add a way to issue deprecation warning without a UI object
Our current deprecation warning mechanism relies on ui object. They are case
where we cannot have access to the UI object. On a general basis we avoid using
the python mechanism for deprecation warning because up to Python 2.6 it is
exposing warning to unsuspecting user who cannot do anything to deal with them.

So we build a "safe" strategy to hide this warnings behind a flag in an
environment variable. The test runner set this flag so that tests show these
warning.  This will help us marker API as deprecated for extensions to update
their code.
2017-04-04 11:03:29 +02:00
Denis Laxalde
160d0b298e gitweb: plug followlines UI in filerevision view
Mostly copy CSS rules from style-paper.css into style-gitweb.css. The only
modification is addition of !important on "background-color" rule for
"pre.sourcelines > span.followlines-selected" selector as the background color
is otherwise overriden by "pre.sourcelines.stripes > :nth-child(4n+4)" rule.
2017-04-13 09:49:48 +02:00
Denis Laxalde
14cc343c76 gitweb: handle "patch" query parameter in filelog view
As for paper style, in d9b8811bed4a, we display "diff" data as an additional
row in the table of revision entries for the gitweb template.
Also, as these additional diff rows have a white background, they may be
confused with log entry rows ("age", "author", "description", "links") of even
parity (parity0 also have a white background). So we disable parity colors for
log entry rows when diff is displayed and fix the color to the
"dark" parity (i.e. parity1 #f6f6f0) so that it's always distinguishable from
2017-04-13 10:04:09 +02:00
Denis Laxalde
8806e20e50 gitweb: add information about "linerange" filtering in filelog view
As for paper style, in a58e79a03a6e, we display a "(following lines
<fromline>:<toline> <a href='...'>back to filelog</a>)" message alongside the
file name when "linerange" query parameter is present.
2017-04-13 09:59:58 +02:00
Gábor Stefanik
387861cc38 util: fix human-readable printing of negative byte counts
Apply the same human-readable printing rules to negative byte counts as to
positive ones. Fixes output of debugupgraderepo.
2017-04-10 18:16:30 +02:00
Gregory Szorc
6c7c4762ec show: implement underway view
This is the beginning of a wip/smartlog view. It is basically a manually
constructed (read: fast) revset function to collect "relevant"
changesets combined with a custom template and a graph displayer.
It obviously needs a lot of work.

I'd like to get *something* usable in 4.2 so `hg show` has some value
to end-users.

Let the bikeshedding begin.
2017-04-12 20:31:15 -07:00
Gregory Szorc
e9dd2f7a3f pycompat: import correct cookie module on Python 3
http.cookielib doesn't exist. http.cookiejar does and it contains the
symbols we need. This fixes test failures on Python 3.
2017-04-12 18:42:20 -07:00
Denis Laxalde
5544045959 hgweb: add a link to followlines in descending direction
We change the content of the followlines popup to display two links inviting
to follow the history of selected lines in ascending (as before) and
descending directions. The popup now renders as:

  follow history of lines <fromline>:<toline>:
  <a href=...>ascending</a> / <a href=...>descending</a>
2017-04-10 17:36:40 +02:00
Denis Laxalde
bd52f5d831 hgweb: handle a "descend" query parameter in filelog command
When this "descend" query parameter is present along with "linerange"
parameter, we get revisions following line range in descending order. The
parameter has no effect without "linerange".
2017-04-10 16:23:41 +02: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
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
Pierre-Yves David
43b1ef004c wireproto: properly report server Abort during 'getbundle'
Previously Abort raised during 'getbundle' call poorly reported (HTTP-500 for
http, some scary messages for ssh). Abort error have been properly reported for
"push" for a long time, there is not reason to be different for 'getbundle'. We
properly catch such error and report them back the best way available. For
bundle, we issue a valid bundle2 reply (as expected by the client) with an
'error:abort' part. With bundle1 we do as best as we can depending of http or
ssh.
2017-02-10 18:20:58 +01:00
Pierre-Yves David
695fa85daa getbundle: cleanly handle remote abort during getbundle
bundle2 allow the server to report error explicitly. This was initially
implemented for push but there is not reason to not use it for pull too. This
changeset add logic similar to the one in 'unbundle' to the
client side of 'getbundle'. That logic make sure the error is properly reported
as "remote". This will allow the server side of getbundle to send clean "Abort"
message in the next changeset.
2017-02-10 18:17:20 +01:00
Pierre-Yves David
d00dbd00d9 bundle1: fix bundle1-denied reporting for pull over ssh
Changeset a0966f529e1b introduced a config option to have the server deny pull
using bundle1. The original protocol has not really been design to allow that
kind of error reporting so some hack was used. It turned the hack only works on
HTTP and that ssh server hangs forever when this is used. After further
digging, there is no way to report the error in a unified way. Using `ooberror`
freeze ssh and raising 'Abort' makes HTTP return a HTTP-500 without further
details. So with sadness we implement a version that dispatch according to the
protocol used.

Now the error is properly reported, but we still have ungraceful abort after
that. The protocol do not allow anything better to happen using bundle1.
2017-02-10 18:06:08 +01:00
Pierre-Yves David
5b07cfa3b3 bundle1: display server abort hint during unbundle
The code was printing the abort message but not the hint. This is now fixed.
2017-02-10 17:56:52 +01:00
Pierre-Yves David
64f57e513b bundle1: fix bundle1-denied reporting for push over ssh
Changeset a0966f529e1b introduced a config option to have the server deny push
using bundle1. The original protocol has not really be design to allow such kind
of error reporting so some hack was used. It turned the hack only works on HTTP
and that ssh wire peer hangs forever when the same hack is used. After further
digging, there is no way to report the error in a unified way. Using 'ooberror'
freeze ssh and raising 'Abort' makes HTTP return a HTTP500 without further
details. So with sadness we implement a version that dispatch according to the
protocol used.

We also add a test for pushing over ssh to make sure we won't regress in the
future. That test show that the hint is missing, this is another bug fixed in
the next changeset.
2017-02-10 17:56:59 +01:00
Pierre-Yves David
e8a7ecc281 bundle2: keep hint close to the primary message when remote abort
The remote hint message was ignored when reporting the remote error and
passed to the local generic abort error. I think I might initially have
tried to avoid reimplementing logic controlling the hint display depending of
the verbosity level. However, first, there does not seems to have such verbosity
related logic and second the resulting was wrong as the primary error and the
hint were split apart. We now properly print the hint as remote output.
2017-02-10 17:56:47 +01:00
FUJIWARA Katsunori
2afd920706 misc: update year in copyright lines
This patch also makes some expected output lines in tests glob-ed for
persistence of them.

BTW, files below aren't yet changed in 2017, but this patch also
updates copyright of them, because:

    - mercurial/help/hg.1.txt

      almost all of "man hg" output comes from online help of hg
      command, and is already changed in 2017

    - mercurial/help/hgignore.5.txt
    - mercurial/help/hgrc.5

      "copyright 2005-201X Matt Mackall" in them mentions about
      copyright of Mercurial itself
2017-02-12 02:23:33 +09:00
Pierre-Yves David
8d733e89bc strip: strip obsmarkers exclusive to the stripped changeset
This is it, `hg strip --rev X` will now also remove obsolescence markers
exclusive to X. Since a previous changeset, the obsmarkers has been backed up
in the strip backup bundle, so it is possible to restore them.

Note: stripping obsmarkers means the precursors of the stripped changeset might no
longer be obsolete after the strip.

Stripping changeset without obsmarkers can be useful when building test case. So
It is possible to disable the stripping of obsmarkers using the
'devel.strip-obsmarkers' config option.

Test change have been carefully validated.
2017-05-20 16:19:59 +02:00
Pierre-Yves David
9461f1ce49 strip: do not include obsolescence markers for the temporary bundle
When stripping, we need to put all non-stripped revisions "above" the stripped
ones in a "temporary-bundle" while we strip the targets revision. Then we
reapply that bundle to restore these non-stripped revisions (with a new revision
numbers). We skip the inclusion of obsolescence markers in that bundle. This is
safe since all obsmarkers we plan to strip will be backed-up in the strip backup
bundle. Including the markers would create issue in some case were we try to
strip a prune markers that is "relevant" to a revision in the
"temporary-bundle".

(note: we do not strip obsmarkers yet)
2017-06-01 12:08:49 +02:00
Pierre-Yves David
e928751835 exclusive-markers: update the dedicated test with list of exclusive markers
We now display data about the "exclusive markers" in the test dedicated to
relevant and exclusive markers computation and usage. Each output have been
carefully validated
2017-06-01 08:44:01 +02:00
Pierre-Yves David
66c1fb799c obsolete: add a function to compute "exclusive-markers" for a set of nodes
This set will be used to select the obsmarkers to be stripped alongside the
stripped changesets. See the function docstring for details.

More advanced testing is introduced in the next changesets to keep this one
simpler. That extra testing provides more example.
2017-05-20 15:02:30 +02:00
Pierre-Yves David
e1977b120c strip: also backup obsmarkers
We are about to give 'strip' the ability to remove obsmarkers. Before we start
removing data we must make sure it is preserved somewhere. So the backup bundle
created by 'strip' now contains obsmarkers.
2017-05-20 15:06:10 +02:00
Augie Fackler
11355eb015 dispatch: convert exception payload to bytes more carefully
We were previously depending on str() doing something reasonable here,
and we can't depend on the objects in question supporting __bytes__,
so we work around the lack of direct bytes formatting.
2017-05-28 15:47:00 -04:00
Augie Fackler
027f2454e7 help: convert flag default to bytes portably
We were relying on %s using repr on (for example) integer values. Work
around that for Python 3 while preserving all the prior magic.
2017-05-28 15:49:29 -04:00
Yuya Nishihara
f287cab367 cmdutil: use isstdiofilename() where appropriate 2017-06-01 23:08:23 +09:00
Yuya Nishihara
e2d98b5aa2 py3: simply use b'%d\n' to format pid in server.py
Spotted by Martin, thanks.
2017-06-01 23:05:29 +09:00
Yuya Nishihara
8840d7ead5 py3: implement __bytes__() on most of our exception classes
We store bytes in exc.args, which should be translated to a byte string
without encode/decode dance.

IOError subclasses are unchanged for now. We'll need to decide how our
IOErrors should be caught.
2017-06-01 22:43:24 +09:00
Yuya Nishihara
9e4fbd65c4 py3: convert __doc__ back to bytes in help.py
pycompat.getdoc() is pretty simple, but we wouldn't want to write handling
of None inline.
2017-06-01 22:24:15 +09:00
Pulkit Goyal
e95681a9cb py3: ensure that we don't concat bytes and str and the end result is bytes
Here obj.__module__ and obj.__name__ are str. Either we can convert them to
bytes or use an r'' and convert back to bytes when concat is done. I preferred
the later one since we are encoding only once here.
2017-06-01 01:41:34 +05:30
Pulkit Goyal
9d6a7aa555 py3: make sure we return strings from __str__ and __repr__
On Python 3:

>>> class abc:
...     def __repr__(self):
...             return b'abc'
...
>>> abc()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __repr__ returned non-string (type bytes)

>>> class abc:
...     def __str__(self):
...             return b'abc'
...
>>> str(abc())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __str__ returned non-string (type bytes)

So the __str__ and __repr__ must return strings.
2017-06-01 00:00:10 +05:30
Pulkit Goyal
4e870f314a py3: replace None with -1 to sort an integer array
In Python 2:

>>> ls = [4, 2, None]
>>> sorted(ls)
[None, 2, 4]

In Python 3:

>>> ls = [4, 2, None]
>>> sorted(ls)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unorderable types: NoneType() < int()

Therefore we replaced None with -1, and the safe part is that, None and -1 are
only the keys which are used for sorting so we don't need to convert the -1's
back to None.
2017-05-31 23:48:52 +05:30