Commit Graph

28169 Commits

Author SHA1 Message Date
FUJIWARA Katsunori
e72a9be81f registrar: introduce new class for registration to replace funcregistrar
_funcregistrarbase differs from funcregistrar in points below:

  - every code paths should use same class derived from
    _funcregistrarbase to register functions in a same category

    funcregistrar expects (3rd party) extensions to use (a class
    derived from) delayregistrar.

  - actual extra setup should be executed in another function

    For example, marking revset predicate as "safe" is executed in a
    class derived from _funcregistrarbase, but putting name of "safe"
    predicate into safesymbols is executed in another function for it.

    funcregistrar expects derived classes to do so.

New class is named as module private one, because code paths, which
register functions, should use not it directly but one derived from
it.
2016-03-08 23:04:53 +09:00
FUJIWARA Katsunori
f9e776bc8b dispatch: make loading extra information from extension extensible
This patch makes loading extra information from extension module at
dispatching extensible. Factoring 'loadcmdtable()' into commands.py is
a part of generalization of loading extra information.

This extensibility assumes registration of new function like below,
for example:

  - revset predicate
  - fileset predicate
  - template keyword
  - template filter
  - template function
  - internal merge tool
  - web command

This patch requires not loader function itself but container module
and the name of it, because listing loader function directly up
implies actual loading module of it, even if it isn't used at runtime
(for example, extensions don't always define revset predicate)
2016-03-08 23:04:53 +09:00
Durham Goode
f5bc3ca716 parsers: optimize filtered headrevs logic
The old native head revs logic would iterate over every node, starting from 0,
and check if every node was filtered (by testing it against the filteredrevs
python set). On large repos with hundreds of thousands of commits, this could
take 150ms.

This new logic iterates over the nodes in reverse order, and skips the filtered
check if we've seen an unfiltered child of the node. This saves approximately a
bagillion filteredrevs set checks, which shaves the time down from 150ms to
20ms during every branch cache write.
2016-03-08 00:20:08 -08:00
FUJIWARA Katsunori
9edf9953ec destutil: choose non-closed branch head at first (BC)
Before this patch, destupdate() returns the tipmost (descendant)
branch head regardless of closed or not. But updating to closed branch
head isn't reasonable for ordinary workflow, because:

  - "hg heads" doesn't show closed heads (= updated parent itself) by
    default

  - subsequent committing on it re-opens closed branch

    even if inactivation of closed head is needed, update destination
    isn't it, because it should be merged into to another branch in
    such case.

This patch chooses non-closed descendant branch head as default update
destination at first. If all descendant branch heads are closed,
destupdate() returns the tipmost closed branch head.

For simplicity, this patch chooses adding _destupdatebranchfallback()
instead largely changing _destupdatebranch().

This patch changes not only normal lookup code path, but also the "no
default branch" code path, for consistency.
2016-03-07 03:14:19 +09:00
Kostia Balytskyi
e31d7d20ae formatter: make labels work with templated output
To describe the bug this fix is addressing, one can do
   ``$ hg status -T "{label('red', path)}\n" --color=debug``
and observe that the label is not applied before my fix and applied with it.
2016-03-08 04:08:33 -08:00
timeless
dd989dbe5f hghave: improve description of Hypothesis 2016-03-08 14:32:03 +00:00
timeless
8f60984480 purge: use absolute_import 2016-03-02 21:39:55 +00:00
timeless
9df52ee9f1 record: use absolute_import 2016-03-02 21:38:32 +00:00
timeless
37728f6a24 relink: use absolute_import 2016-03-02 21:36:14 +00:00
timeless
bf3fcbb8c7 schemas: use absolute_import 2016-03-02 21:33:55 +00:00
timeless
067d78e42f shelve: use absolute_import 2016-03-02 21:30:51 +00:00
timeless
fe1b5c51ca strip: use absolute_import 2016-03-02 21:26:36 +00:00
Martijn Pieters
a7c9554a48 graphmod: augment the graph to include more information about the edges
The walker knows when an edge leads to a direct parent, a grandparent (skipping
revisions not part of the revset) and parents that are missing altogether
(neither it nor a grandparent is in the revset). Add this information to the
parents sequence yielded.
2016-03-04 14:44:32 +00:00
Martijn Pieters
a973afd498 graphmod: refactor state handling
Move ASCII graph state to a dictionary, to clarify what is being tracked. Move
the 'seen' state (tracking currently active edges) into this structure.
2016-03-04 14:44:32 +00:00
Yuya Nishihara
b20edef8a1 templater: move label() function from color extension
ui.label() is no-op by default, so we can just call ui.label() by label()
template function no matter if the color is enabled or not.
2015-06-11 23:04:14 +09:00
Yuya Nishihara
e7ec9f2344 templater: make label() take unknown symbol as color literal
Instead of the mapping hack introduced by d4686e0c15c9, this patch changes the
way how a label symbol is evaluated. This is still hackish, but should be more
predictable in that it doesn't depend on the known color effects.

This change is intended to eliminate the reference to color._effects so that
color.templatelabel() can be merged with templater.label().
2015-06-11 22:58:27 +09:00
timeless
6a754bf667 convert: monotone use absolute_import 2016-03-02 15:50:34 +00:00
timeless
d22428de9f convert: p4 use absolute_import 2016-03-02 15:31:15 +00:00
timeless
9b1f5043ce convert: hg use absolute_import 2016-03-02 15:26:49 +00:00
timeless
de2d02e8b7 convert: cvsps use absolute_import 2016-03-02 14:56:29 +00:00
timeless
96ac5cd883 convert: darcs use absolute_import 2016-03-02 14:23:23 +00:00
timeless
86b7c93478 convert: filemap use absolute_import 2016-03-02 09:00:58 +00:00
timeless
81c64e649e convert: gnuarch use absolute_import 2016-03-02 08:58:01 +00:00
timeless
65e468cce9 convert: git use absolute_import 2016-03-02 20:42:13 +00:00
Durham Goode
ccda03e5b2 branchmap: check node against changelog instead of repo
Testing 'node in repo' requires constructing a changectx, which is a little
expensive.  Testing 'repo.changelog.hasnode(node)' is notably faster. This
saves 10-20ms off of every command, when testing a few thousand nodes from the
branch cache.

I considered changing the implementation of localrepository.__contains__ so
every place would benefit from the change, but since
localrepository.__contains__ uses changectx to check if the commit exists, it
means it supports a wider range of possible inputs (like revs, hashes, '.',
etc), so it seemed unnecessarily risky.
2016-03-07 17:26:47 -08:00
Martin von Zweigbergk
daa3928fb2 changegroup: clear progress callback after changelog processing
The progress callback is replaced by one for manifests after changelog
processing is done, but let's not depend on manifests replacing the
value and instead explicitly clear it.
2016-02-29 09:26:43 -08:00
Martin von Zweigbergk
e8ad80f690 changegroup: progress for added files is not measured in "chunks"
The "prog" class cg1unpacker.apply() has the unit set to
"chunks". This is not correct for files, where the file itself is the
unit. The unit is not usually printed, which is probably why this has
not been fixed yet. It can be show with e.g. "--config
progress.format='topic number unit'".
2016-02-28 22:51:07 -08:00
Martin von Zweigbergk
8d4ca9dc03 changegroup: exclude submanifests from manifest progress
The progress callback for manifests is cleared outside of
_unpackmanifests(), which means it will remain in effect while pulling
subdirectory manifests when using treemanifests. Since the total
number of revisions used for the progress is the number of changesets,
the total number of treemanifest revisions is usually larger than
that. One effect of this is that the ETA is negative. It's hard to
estimate the number of subdirectory revisions, so let's just exclude
them from progress for now.
2016-02-28 21:15:06 -08:00
timeless
ec454c0097 commit: block amend while histedit is in progress (issue4800) 2016-02-14 07:35:50 +00:00
Jun Wu
5ce2fd3a4b chg: limit reconnect attempts
Some users may have hg as a wrapper script which sets sensitive environment
variables (like setting up virtualenv). This will make chg redirect forever
because the environment variables are never considered up to date.
This patch adds a limit (10) for reconnect attempts and warn the user with
a possible solution if the limit is exceeded.
2016-03-02 10:42:58 +00:00
Jun Wu
7f85e71c20 chg: use validate to make sure the server is up to date
This patch uses the newly added validate method to make sure the server has
loaded the up-to-date config and extensions. If the server cannot validate
itself, the client will receive instructions and follow them to try to reach
another server that is more likely to validate itself. The instructions can
be a redirect (connect to another server address) and/or an unlink (stops an
out-dated server).
2016-03-06 14:22:37 +00:00
Jun Wu
4d98436906 chg: implement validate in hgclient
This patch implements the corresponding validate method in hgclient.
It will return instruction strings as is without taking any real action.
2016-03-06 14:21:52 +00:00
Pulkit Goyal
bc36832277 hgclient: use absolute_import and print_function 2016-03-06 03:15:45 +05:30
Pulkit Goyal
df7262ef1e fixpax: use absolute_import and print_function 2016-03-06 03:10:17 +05:30
Pulkit Goyal
2f8a8e257d debugcmdserver: use absolute_import and print_function 2016-03-06 03:06:09 +05:30
Pulkit Goyal
72963156f8 check-config: use absolute_import and print_function 2016-03-06 03:01:46 +05:30
Pulkit Goyal
7790f458a6 casesmash: use absolute_import 2016-03-06 02:25:50 +05:30
Jun Wu
76d7a8fda5 chgserver: implement validate command
validate will load the repo config and check if the server has up-to-date
config to continue serve the client. In case it does not, the server will
send instructions to the client about what to do next, including to retry
with a different address or to unlink an outdated socket file to stop an
old server.
2016-03-05 13:56:59 +00:00
Yuya Nishihara
e7f2a2e46a templater: handle exception when applying map operator to non-iterable object
Before this, "{noniterable % template}" raised an exception. This tries to
provide a better indication for the common case, where a left-hand-side
expression is a keyword.
2016-02-14 13:58:46 +09:00
Yuya Nishihara
a0a8a0401c templater: factor out thin helper that evaluates argument as string
This function is trivial, but it can make it clear that args[i] is a
(func, data) pair.
2016-02-14 13:30:32 +09:00
Yuya Nishihara
ddf9358dea color: make label() template function stringify "expr" argument first
Since label() should return a string (or a thunk to be evaluated to a string),
this change is okay. This helps porting to evalstring() helper. See the next
patch for details.
2016-03-05 00:01:36 +09:00
Yuya Nishihara
40ff3175fd templater: fix shortest() to evaluate int argument and handle error 2016-02-14 13:09:17 +09:00
Yuya Nishihara
7bcf850662 templater: fix pad() to evaluate int argument and handle error 2016-02-14 13:05:09 +09:00
Yuya Nishihara
608ccd9ef6 templater: drop redundant type conversion when evaluating integer argument
A function argument may be an integer. In this case, it isn't necessary to
convert a value to string and back to integer.

Because an argument may be an arbitrary object (e.g. date tuple), TypeError
should be caught as well.
2016-02-14 12:48:14 +09:00
Yuya Nishihara
077f7d6378 templater: factor out function that evaluates argument as integer
We have more bare int()s that may raise ValueError or TypeError. This function
will be used to fix them.
2016-02-14 12:42:25 +09:00
Jun Wu
505fcee270 chgserver: use basename for socket symlink
Previously we use full path and the symlink may point to outside (unsafe)
world if the directory is moved. This patch fixes it by only linking to
basename of the target. Therefore the symbolic link and socket files will
always stay in the same directory.
2016-03-04 13:18:02 +00:00
Julien Cristau
1c82b3fc6d patch: when importing from email, RFC2047-decode From/Subject headers
Reported at https://bugs.debian.org/737498
2016-03-03 18:34:19 +01:00
timeless
6b7ebe1ed5 histedit: reword message when a changeset produces no changes
There are various ways to use histedit such that an item in
the list of things to perform will not result in a change
relative to the previous repository state.

When that happens, histedit does not keep the commit/message.

This changes the note to try to explain to the user that it
will not be present in their history.
2016-03-02 22:39:03 +00:00
timeless
802e23963d tests: replace cat.py with cat in test-histedit-fold-non-commute.t 2016-03-02 22:09:18 +00:00
Danek Duvall
213f203c87 tests: Solaris grep doesn't add a trailing newline when it's missing
The bad-extension tests emits a list of not-loaded extensions, and pipes
that output through grep.  On Solaris, the test-output gets "(no-eol)"
appended because although the message has no trailing newline, GNU grep
adds it.  If we simply add the newline to the message, the problem goes
away for both versions of grep.
2016-03-02 15:01:41 -08:00