Commit Graph

18022 Commits

Author SHA1 Message Date
Denis Laxalde
6af640ec03 hgweb: fix diff hunks filtering by line range in webutil.diffs()
The previous clause for filter out a diff hunk was too restrictive. We need to
consider the following cases (assuming linerange=(lb, ub) and the @s2,l2
hunkrange):

            <-(s2)--------(s2+l2)->
      <-(lb)---(ub)->
               <-(lb)---(ub)->
                           <-(lb)---(ub)->

previously on the first and last situations were considered.

In test-hgweb-filelog.t, add a couple of lines at the beginning of file "b" so
that the line range we will follow does not start at the beginning of file.
This covers the change in aforementioned diff hunk filter clause.
2017-03-29 12:07:07 +02:00
Denis Laxalde
f25fa2b8d5 summary: display obsolete state of parents
Extend the "parent: " lines in summary to display "(obsolete)" when the parent
is obsolete.
2017-03-25 11:30:08 +01:00
Denis Laxalde
aaf9382123 templates: add "changeset.obsolete" label in command line style
Following respective change in cmdutil.changeset_printer.
2017-03-25 10:40:29 +01:00
Denis Laxalde
f5bac903ae templates: shorten definition of changeset labels in command-line style
We'll add more labels and the line is already quite long, so let's define a
variable to hold all evolution "troubles" labels.
2017-03-28 22:38:45 +02:00
Denis Laxalde
3a0bd7f34e templates: use separate() to build changeset labels in command-line style 2017-03-28 22:36:22 +02:00
Denis Laxalde
5f616436cb templatekw: add an "obsolete" keyword
Definition is the same as the one in evolve extension.
2017-03-25 10:34:11 +01:00
Denis Laxalde
2ae8148594 cmdutil: add a "changeset.obsolete" label in changeset_printer
Until now there were no label to highlight obsolete changesets in log output,
only evolution troubles (unstable, bumped, divergent) are supported. We add a
"changeset.obsolete" label on changeset entries produced by changeset_printer
so that obsolete changesets can be highlighted in log output. This is useful
because, unless using a graph log where obsolete changesets have a 'x' marker,
there's no way to identify obsolete changesets. And even in graph mode, when
working directory's parent is obsolete, we get a '@' marker and we do not see
it as obsolete.
2017-03-25 09:39:07 +01:00
Gregory Szorc
df777290b9 fileset: perform membership test against set for status queries
Previously, fileset functions operating on status items performed
membership tests against a list of items. When there are thousands
of items having a specific status, that test can be extremely
slow. Changing the membership test to a set makes this operation
substantially faster.

On the mozilla-central repo:

$ hg files -r d14cac631ecc 'set:added()'
before: 28.120s
after:   0.860s

$ hg status --change d14cac631ecc --added
0.690s
2017-03-28 14:40:13 -07:00
David Soria Parra
3e94bf58b6 worker: flush ui buffers before running the worker
a91c6275 introduces flushing ui buffers after a worker finished. If the ui was
not flushed before the worker was started, fork will copy the existing buffers
to the worker. This causes messages issued before the worker started to be
written to the terminal for each worker.

We are now flushing the ui before we start a worker and add an appropriate test
which will fail before this patch.
2017-03-28 10:21:38 -07:00
Jun Wu
49dddd702d chgserver: do not copy configs set by environment variables
Config set by environment variables have a source like "$ENVNAME". They
should not be copied because they will be recalculated by
rcutil.rccomponents.
2017-03-28 08:40:12 -07:00
Jun Wu
27200c179a rcutil: extract duplicated logic to a lambda
This simplifies the code a bit.
2017-03-28 07:57:56 -07:00
Jun Wu
97882c200c rcutil: unindent a block
Since global _rccomponents is gone, the code could be simplified.
2017-03-28 07:55:32 -07:00
Jun Wu
d209e31ef0 rcutil: do not cache rccomponents
The function is only called once except for "hg debugconfig", where it is
called twice. So there is no need to cache it.

Caching it will cause issues with chgserver. Instead of dropping the cache
in chgserver, it seems cleaner to just avoid the cache.
2017-03-28 07:54:00 -07:00
Matt Harbison
ac12c54058 ui: rerun color.setup() once the pager has spawned to honor 'color.pagermode'
Otherwise, ui.pageractive is False when color is setup in dispatch.py (without
--pager=on), and this config option is ignored.
2017-03-25 19:17:11 -04:00
Matt Harbison
ca66dceee3 ui: defer setting pager related properties until the pager has spawned
When --pager=on is given, dispatch.py spawns a pager before setting up color.
If the pager failed to launch, ui.pageractive was left set to True, so color
configured itself based on 'color.pagermode'.  A typical MSYS setting would be
'color.mode=auto, color.pagermode=ansi'.  In the failure case, this would print
a warning, disable the pager, and then print the raw ANSI codes to the terminal.

Care needs to be taken, because it appears that leaving ui.pageractive=True was
the only thing that prevented an attempt at running the pager again from inside
the command.  This results in a double warning message, so pager is simply
disabled on failure.

The ui config settings didn't need to be moved to fix this, but it seemed like
the right thing to do for consistency.
2017-03-25 21:12:00 -04:00
Matt Harbison
75ecbbd369 color: stop mutating the default effects map
A future change will make color.setup() callable a second time when the pager is
spawned, in order to honor the 'color.pagermode' setting.  The problem was that
when 'color.mode=auto' was resolved to 'win32' in the first pass, the default
ANSI effects were overwritten, making it impossible to honor 'pagermode=ansi'.
Also, the two separate maps didn't have the same keys.  The symmetric difference
is 'dim' and 'italic' (from ANSI), and 'bold_background' (from win32).  Thus,
the update left entries that didn't belong for the current mode.  This bled
through `hg debugcolor`, where the unsupported ANSI keys were listed in 'win32'
mode.

As an added bonus, this now correctly enables color with MSYS `less` for a
command like this, where pager is forced on:

    $ hg log --config color.pagermode=ansi --pager=yes --color=auto

Previously, the output was corrupted.  The raw output, as seen through the ANSI
blind `more.com` was:

    <-[-1;6mchangeset:   34840:3580d1197af9<-[-1m
    ...

which MSYS `less -FRX` rendered as:

    1;6mchangeset:   34840:3580d1197af91m
    ...

(The two '<-' instances were actually an arrow character that TortoiseHg warned
couldn't be encoded, and notepad++ translated to a single '?'.)

Returning an empty map for 'ui._colormode == None' seems better that defaulting
to '_effects' (since some keys are mode dependent), and is better than None,
which blows up `hg debugcolor --color=never`.
2017-03-25 13:50:17 -04:00
Jun Wu
94b5d9fcfa pager: do not read from environment variable
$PAGER is converted to the pager.pager config item. So it's no longer
necessary to read $PAGER in ui.pager().
2017-03-26 21:43:47 -07:00
Jun Wu
371e8cfb4e ui: simplify geteditor
Now $EDITOR and $VISUAL will affect ui.editor directly. So it's no longer
necessary to test them in ui.geteditor.
2017-03-26 21:41:42 -07:00
Jun Wu
28aef1acdc debugconfig: list environment variables in debug output
Since we print "read config from" for config files, printing environment
variables will make it more consistent.
2017-03-26 21:40:22 -07:00
Jun Wu
cc0447168c rcutil: let environ override system configs (BC)
This is BC because system configs won't be able to override $EDITOR, $PAGER.
The new behavior is arguably more rational.
2017-03-26 21:33:37 -07:00
Jun Wu
4fdac40b3b rcutil: add a method to convert environment variables to config items
Handling config and environ priorities has been messy. Partially because we
don't have config layers - you either get all configs (sys + user), or none.

Ideally, environ like $EDITOR, $PAGER should be able to override the system
configs "ui.editor", "pager.pager". This patch provides the ability to
convert them into config items, so they can be inserted into the middle
config layer between system rc and user rc.
2017-03-26 21:27:02 -07:00
Jun Wu
d4692f9619 rcutil: let rccomponents return different types of configs (API)
The next patches will convert environ to raw config items, and insert the
config items between systemrcpath and userrcpath. This patch teaches
rccomponents to return the type information so the caller could distinguish
between "path" and raw config "items".
2017-03-26 21:04:29 -07:00
Jun Wu
d63b24bd71 rcutil: rename rcpath to rccomponents (API) 2017-03-26 20:48:00 -07:00
Jun Wu
d3c5fd327d rcutil: extract rc directory listing logic
The logic of listing a ".rc" directory is duplicated in two functions,
extract it to a single function to make the code cleaner.
2017-03-26 20:46:05 -07:00
Jun Wu
8c4790a38b rcutil: split osrcpath to return default.d paths (API)
After this change, there are 3 rcpath functions:

  - defaultrcpath
  - systemrcpath
  - userrcpath

This will allow us to insert another config layer in the middle.
2017-03-26 20:21:32 -07:00
Jun Wu
582704c32f rcutil: move scmutil.*rcpath to rcutil (API)
As discussed at [1], the logic around "actual config"s seem to be
non-trivial enough that it's worth a new module.

This patch creates the module and move "scmutil.*rcpath" functions there as
the first step. More methods will be moved to the module in the future.

The module is different from config.py because the latter only cares about
data structure and parsing, and does not care about special case, or system
config paths, or environment variables.

[1]: https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-March/095503.html
2017-03-26 20:18:42 -07:00
Yuya Nishihara
91f8f53f3a statfs: make getfstype() raise OSError
It's better for getfstype() function to not suppress an error. Callers can
handle it as necessary. Now "hg debugfsinfo" will report OSError.
2017-03-25 17:25:23 +09:00
Yuya Nishihara
91e4f106c6 statfs: rename pygetfstype to getfstype
There's no ambiguity now.
2017-03-25 17:24:11 +09:00
Yuya Nishihara
413bbbf814 statfs: refactor inner function as a mapping from statfs to string
The major difference between BSD and Linux is how to get a fstype string.
Let's split the longest part of getfstype() as a pure function.
2017-03-25 17:23:21 +09:00
Yuya Nishihara
6b9644999c statfs: simplify handling of return value
Py_BuildValue() can translate NULL pointer to None.
2017-03-25 17:13:12 +09:00
Pierre-Yves David
368236438f tags: deprecated 'repo.tag'
All user are gone. We can now celebrate the removal of some extra line from the
'localrepo' class.
2017-03-27 16:00:47 +02:00
Pierre-Yves David
b55b067aa6 tags: use the 'tag' function from the 'tags' module in the 'tag' command
There is No need to go through the 'repo' object method anymore.
2017-03-27 16:00:34 +02:00
Pierre-Yves David
8141af4eed tags: move 'repo.tag' in the 'tags' module
Similar logic, pretty much nobody use this method (that creates a tag) so we
move it into the 'tags' module were it belong.
2017-03-27 15:58:31 +02:00
Pierre-Yves David
f1cbb59e75 tags: move '_tags' from 'repo' to 'tags' module
As far as I understand, that function do not needs to be on the local repository
class, so we extract it in the 'tags' module were it will be nice and
comfortable. We keep the '_' in the name since its only user will follow in the
next changeset.
2017-03-27 15:55:07 +02:00
Denis Laxalde
2702418496 hgweb: filter diff hunks when 'linerange' and 'patch' are specified in filelog 2017-03-13 15:17:20 +01:00
Denis Laxalde
69dcb458cd hgweb: add a 'linerange' parameter to webutil.diffs()
This is used to filter out hunks based on their range (with respect to 'node2'
for patch.diffhunks() call, i.e. 'ctx' for webutil.diffs()).

This is the simplest way to filter diff hunks, here done on server side. Later
on, it might be interesting to perform this filtering on client side and
expose a "toggle" action to alternate between full and filtered diff.
2017-03-13 15:15:49 +01:00
Denis Laxalde
996bd4af95 hgweb: handle a "linerange" request parameter in filelog command
We now handle a "linerange" URL query parameter to filter filelog using
a logic similar to followlines() revset.
The URL syntax is: log/<rev>/<file>?linerange=<fromline>:<toline>
As a result, filelog entries only consists of revision changing specified
line range.

The linerange information is propagated to "more"/"less" navigation links but
not to numeric navigation links as this would apparently require a dedicated
"revnav" class.

Only update the "paper" template in this patch.
2017-01-19 17:41:00 +01:00
Jun Wu
faefa92b13 metadataonlyctx: speed up sanity check
Previously the sanity check will construct manifestctx for both p1 and p2.
But it only needs the "manifest node" information, which could be read from
changelog directly.
2017-03-26 12:26:35 -07:00
Denis Laxalde
a70f2fcec7 revset: factor out linerange processing into a utility function
Similar processing will be done in hgweb.webutil in forthcoming changeset.
2017-02-24 18:39:08 +01:00
Denis Laxalde
6b9779860f hgweb: add a "patch" query parameter to filelog command
Add support for a "patch" query parameter in filelog web command similar to
--patch option of `hg log` to display the diff of each changeset in the table
of revisions. The diff text is displayed in a dedicated row of the table that
follows the existing one for each entry and spans over all columns. Only
update "paper" template in this patch.
2017-03-13 10:41:13 +01:00
Denis Laxalde
53e1237344 hgweb: handle "parity" internally in webutil.diffs()
There's apparently no reason to have the "parity" of diff blocks that
webutil.diffs() generates coming from outside the function. So have it
internally managed. We thus now pass a "web" object to webutil.diffs() to get
access to both "repo" and "stripecount" attribute.
2017-03-13 10:40:19 +01:00
Yuya Nishihara
6286308d03 py3: fix manifestdict.fastdelta() to be compatible with memoryview
This doesn't look nice, but a straightforward way to support Python 3.
bytes(m[start:end]) is needed because a memoryview doesn't support ordering
operations. On Python 2, m[start:end] returns a bytes object even if m is
a buffer, so calling bytes() should involve no additional copy.

I'm tired of trying cleaner alternatives, including:

 a. extend memoryview to be compatible with buffer type
    => memoryview is not an acceptable base type
 b. wrap memoryview by buffer-like class
    => zlib complains it isn't bytes-like
2017-03-26 19:06:48 +09:00
Jun Wu
6b0a252616 crecord: use ProgrammingError 2017-03-26 17:00:23 -07:00
Jun Wu
8b5d63a796 transaction: use ProgrammingError 2017-03-26 16:59:30 -07:00
Jun Wu
b99bc99ff6 bundle2: use ProgrammingError 2017-03-26 16:57:25 -07:00
Jun Wu
f331a9612f merge: use ProgrammingError 2017-03-26 16:55:56 -07:00
Jun Wu
809dfffea4 repair: use ProgrammingError 2017-03-26 16:53:28 -07:00
Yuya Nishihara
2a7deb97d4 py3: abuse r'' to preserve str-ness of literals passed to __setattr__() 2017-03-26 16:33:12 +09:00
Yuya Nishihara
5a92909ce0 py3: fix slicing of byte string in revlog.compress()
I tried .startswith('\0'), but data wasn't always a bytes nor a bytearray.
2017-03-26 17:12:06 +09:00
Yuya Nishihara
cb9a6405bb py3: use bytes() to cast to immutable bytes in changelog.appender.write() 2017-03-26 16:31:01 +09:00