Commit Graph

25733 Commits

Author SHA1 Message Date
Gregory Szorc
bf31c39d5d fileset: use absolute_import 2015-08-08 18:34:37 -07:00
Gregory Szorc
5f5e77fde2 demandimport: support lazy loading for absolute_import
Before, we didn't support lazy loading if absolute_import was in
effect and a fromlist was used. This meant that "from . import X"
wasn't lazy and performance could suffer as a result.

With this patch, we now support lazy loading for this scenario.
As part of developing this, I discovered issues when module names
are defined. Since the enforced import style only allows
"from X import Y" or "from .X import Y" in very few scenarios
when absolute_import is enabled - scenarios where Y is not a
module and thus there is nothing to lazy load - I decided to drop
support for this case instead of chasing down the errors. I don't
think much harm will come from this. But I'd like to take another
look once all modules are using absolute_import and I can see the
full extent of what is using names in absolute_import mode.
2015-08-08 16:13:27 -07:00
Gregory Szorc
2a92fddf91 demandimport: support keyword arguments on _hgextimport
__import__ supports keyword arguments since Python 2.5. This
proxy should too.

An upcoming patch will use this feature.
2015-08-08 17:07:34 -07:00
Gregory Szorc
fd4a9d9759 demandimport: refactor logic and add documentation
demandimport doesn't currently support absolute imports (level >= 0).
In preparation for this, we add some documentation and a code branch
to handle the absolute_import case.
2015-08-08 16:24:57 -07:00
Gregory Szorc
c5d1f82f1f demandimport: add __future__ to ignore list
__future__ is special. We should definitely not be trying to lazy
load it.
2015-08-08 17:12:37 -07:00
Gregory Szorc
463e808be1 demandimport: remove support for Python < 2.5
The removed code was to support an __import__ function that doesn't
support the "level" argument. This argument was added in Python 2.5,
which we no longer support.
2015-08-08 15:01:27 -07:00
Gregory Szorc
177174bac6 dispatch: use absolute_import
A mixed, ambiguous import has been removed!
2015-08-08 14:42:48 -07:00
Gregory Szorc
788d5ef232 commands: break import cycle
This was the easiest link in the chain to break as there was only
one use of commandserver in commands.py. Other files had multiple
users.
2015-08-08 14:30:39 -07:00
Gregory Szorc
a935029795 cmdutil: break import cycle
This was the easiest place to break the chain, as there were only
2 uses of the imported module in the file.
2015-08-08 00:47:19 -07:00
Yuya Nishihara
59f7e7c7df revset: make balanced addsets by orset() without using _combinesets()
As scmutil.revrange() was rewritten to not use _combinesets(), we no longer
need _combinesets().
2015-07-05 12:50:09 +09:00
Yuya Nishihara
73b047cec9 revrange: evaluate all revset specs at once
This provides an opportunity for revset to optimize given expressions. For
example, "-r0 -r1 -r2" can be optimized to "_list(0 1 2)".
2015-07-05 12:35:42 +09:00
Yuya Nishihara
cfbb764a2a revset: add matchany() to construct OR expression from a list of specs
This will allow us to optimize "-rREV1 -rREV2 ..." command-line options.
2015-08-07 21:39:38 +09:00
Yuya Nishihara
938e25baff revset: split post-parsing stage from match()
_makematcher() will be reused by new matchany(ui, specs, repo=None) function
I'll add by the next patch.
2015-08-07 21:31:16 +09:00
Gregory Szorc
9440bd18c5 copies: use absolute_import 2015-08-08 00:41:13 -07:00
Gregory Szorc
90bae1ad52 config: use absolute_import 2015-08-08 00:28:53 -07:00
Gregory Szorc
68dd6a9cac changelog: use absolute_import 2015-08-08 00:26:49 -07:00
Gregory Szorc
acca109d80 changegroup: use absolute_import 2015-08-08 00:35:37 -07:00
Gregory Szorc
e1217593c5 bundlerepo: use absolute_import 2015-08-08 00:36:35 -07:00
Gregory Szorc
5f5a2cec0b bundle2: use absolute_import 2015-08-07 19:54:08 -07:00
Gregory Szorc
093007295f branchmap: use absolute_import 2015-08-07 19:51:55 -07:00
Gregory Szorc
565027bd3e bookmarks: use absolute_import 2015-08-07 19:49:21 -07:00
Gregory Szorc
d30eb7e23d archival: use absolute_import 2015-08-07 19:47:49 -07:00
Gregory Szorc
c6929b7a7e ancestor: use absolute_import
A few months ago, import-checker.py was taught to enforce a more
well-defined import style for files with absolute_import. However,
we stopped short of actually converting source files to use
absolute_import because of problems with certain files.

Investigation revealed the following problems with switching to
absolute_import universally:

1) import cycles result in import failure on Python 2.6
2) undetermined way to import C/pure modules

While these problems need to be solved, they can be put off.
This patch starts a series of converting files to absolute_import
that won't exhibit any of the aforementioned problems.
2015-08-07 19:45:48 -07:00
Augie Fackler
11540756a2 discovery: always use batching now that all peers support batching
Some peers will transparently downgrade batched requests to
non-batched ones, but that simplifies code for everyone using
batching.
2015-08-05 14:21:46 -04:00
Augie Fackler
c93fd0260e wireproto: make wirepeer look-before-you-leap on batching
This means that users of request batching don't need to worry
themselves with capability checking. Instead, they can just use
batching, and if the remote server doesn't support batching for some
reason the wirepeer code will transparently un-batch the requests.

This will allow for some slight simplification in a handful of
places. Prior to this change, largefiles would have been silently
broken against a server which did not support batching.
2015-08-05 14:15:17 -04:00
Augie Fackler
6a6926de03 batching: migrate basic noop batching into peer.peer
"Real" batching only makes sense for wirepeers, but it greatly
simplifies the clients of peer instances if they can be ignorant to
actual batching capabilities of that peer. By moving the
not-really-batched batching code into peer.peer, all peer instances
now work with the batching API, thus simplifying users.

This leaves a couple of name forwards in wirepeer.py. Originally I had
planned to clean those up, but it kind of unclarifies other bits of
code that want to use batching, so I think it makes sense for the
names to stay exposed by wireproto. Specifically, almost nothing is
currently aware of peer (see largefiles.proto for an example), so
making them be aware of the peer module *and* the wireproto module
seems like some abstraction leakage. I *think* the right long-term fix
would actually be to make wireproto an implementation detail that
clients wouldn't need to know about, but I don't really know what that
would entail at the moment.

As far as I'm aware, no clients of batching in third-party extensions
will need updating, which is nice icing.
2015-08-05 14:51:34 -04:00
Pierre-Yves David
d7dbab10fd histedit: do not stay on a cleaned nodes on abort
There is case where nodes are neither in tmpnodes nor leaf but still get
removed. For example, if you used the "edit" action, made a commit and run
--abort. The commit you made is not tracked by histedit, yet it will likely be
cleaned up with its parent. The commit may not tracked because no replacements
computations are done in the --abort case.
2015-08-03 06:13:05 -07:00
Pierre-Yves David
d31b5ec741 histedit: also update away from tmpnodes
The working copy may be on a tmpnodes, we need to update away before it is
stripped from the repository.
2015-08-03 06:11:45 -07:00
Pierre-Yves David
8eb6cf86e6 histedit: use revset to check if we need to update during abort
The for loop is already quite more complicated than necessary and we are about
to add some logic. Instead, we use a simple revset. Revset laziness should
provide us with similar performance.
2015-08-03 06:08:37 -07:00
Pierre-Yves David
063bf1acfb histedit: remove useless 'else' clause
This 'else: pass' clause have no effect. We drop it for clarity.
2015-08-03 05:57:45 -07:00
Pierre-Yves David
138cd324a8 histedit: make cleanupnode more robust
The goal of this function is to strip content out of the repository. We do not
really care if this content is visible or cleanup node not and we should proceed
anyway. None of the internal actions are subject to this, however, a third party
extension running arbitrary commands during histedit is affected by this.
2015-07-31 15:46:49 -07:00
Durham Goode
4126c0d435 convert: fix git convert using servers branches
The conversion from git to hg was reading the remote branch list directly from
the origin server. If the origin's branch had moved forward since the last git
fetch, it would return a git hash which didn't exist locally, and therefore the
branch was not converted.

This changes it to rely on the local repo's refs/remotes list of branches
instead, so it's completely cut off from the server.
2015-07-29 13:21:03 -07:00
Yuya Nishihara
8c83cdaaac revrange: drop old-style parser in favor of revset (API)
Now revset can parse nullary ":" operator and existing "foo+bar" tags, we
don't need the old-style parser.

This means scmutil.revsingle(), revpair() and revrange() no longer accept
a binary nodeid. An integer revision is still allowed as it isn't ambiguous.
2015-01-24 22:28:14 +09:00
Yuya Nishihara
b26ded0d8d tag: do not pass binary nullid to scmutil.revsingle()
Future patches will remove the old-style parser that happen to accept a
binary nodeid. A binary nodeid shouldn't be passed to scmutil.revrange()
because it is ambiguous. For example, bin('20' * 19 + '30') is valid binary
nodeid, but it can also be parsed as a revset expression, '0'.
2015-03-15 14:45:26 +09:00
Yuya Nishihara
a85993b95a revset: port parsing rule of old-style ranges from scmutil.revrange()
The old-style parser will be removed soon.
2015-07-18 23:30:17 +09:00
Yuya Nishihara
137f249748 debugrevspec: pass lookup function to visualize fallback mechanism
The next patch will move the exceptional parsing of old-style ranges
to revset.tokenize(). This patch will allow us to see the result tree.

Note that the parsing result of '-a-b-c-' is incorrect at this changeset.
It will be fixed soon.
2015-07-18 23:02:18 +09:00
Anton Shestakov
73dce8b9d6 highlight: exit early on textual and unknown files (issue3005)
When highlight extension encountered files that pygments didn't recognize, it
used to fall back to text lexer. Also, pygments uses TextLexer for .txt files.
This lexer is noop by design.

On bigger files, however, doing the noop highlighting resulted in noticeable
extra CPU work and memory usage: to show a 1 MB text file, hgweb required about
0.7s more (on top of ~3.8s, Q8400) and consumed about 100 MB of RAM more (on
top of ~150 MB).

Let's just exit the function when it's clear that nothing will be highlighted.

Due to how this pygmentize function works (it modifies the template in-place),
we can just return from it and everything else will work as if highlight
extension wasn't enabled.
2015-08-02 19:18:35 +08:00
Pierre-Yves David
a2cfbc8b70 histedit: extract a simpler function to process replacement on abort
The process replacement is building a full mapping to allow moving bookmarks and
creating obsolescence marker. We do not need the full logic for abort so we
extract it. It will be useful as abort is missing some data about the
replacement and can crash when third party extensions push it a bit too far.
2015-08-03 14:16:51 -07:00
Pierre-Yves David
d41570d94c merge with stable 2015-08-03 14:05:42 -07:00
Pierre-Yves David
6b2961e47a histedit: backout 3e883e7ec57b
The faulty changeset use obsolescence marker to roll the repository back on
--abort. This is a problematic approach because --abort should be as close as an
actually transaction rollback as possible stripping all created data from the
repository (cf `hg rebase --abort` stripping all created changesets). Instead
3e883e7ec57b made all content created during the aborted histedit still
available in the repository adding obsolescence marker to make them hidden. This
will cause trouble to evolution user as a re-run of the same histedit (with
success) will likely result in the very same node to be "recreated" while
obsolescence marker would be in place for them. And canceling an obsoletion is
still a fairly complicated process.

This also rollback using obsmarkers instead of strip to clean up temporary node
on successful histedit run because the two change were not split in separated
changeset. Rolling that part back does not have significant consequence a will
have to be resubmitted independently
2015-07-31 15:11:07 -07:00
Matt Mackall
2721e01d73 Added signature for changeset 99a2ae70688b 2015-07-31 11:56:28 -05:00
Matt Mackall
d585ecbe64 i18n: fix unclosed inline span in pt_BR
This was causing test-gendoc.t to complain:

WARNING: Inline interpreted text or phrase reference start-string
without end-string.
2015-07-31 10:49:15 -05:00
Matt Mackall
43b8b00309 merge with i18n 2015-07-31 10:26:57 -05:00
FUJIWARA Katsunori
895418cefb i18n-ja: synchronized with bcb4578674eb 2015-07-31 18:39:48 +09:00
Wagner Bruna
1a4e90ed7e i18n-pt_BR: synchronized with 6aaad589ef8a 2015-07-29 11:37:36 -03:00
Matt Harbison
e8c6c3b443 dirstate: ensure mv source is marked deleted when walking icasefs (issue4760)
Previously, importing a case-only rename patch on a case insensitive filesystem
caused the original file to be marked as '!' in status.  The source was being
forgotten properly in patch.workingbackend.close(), but the call it makes to
scmutil.marktouched() then put the file back into the 'n' state (but it was
still missing from the filesystem).

The cause of this was scmutil._interestingfiles() would walk dirstate,
and since dirstate was able to lstat() the old file via the new name,
was treating this as a forgotten file, not a removed file.
scmutil.marktouched() re-adds forgotten files, so dirstate got out of
sync with the filesystem.

This could be handled with less code in the "kind == regkind or kind
== lnkkind" branch of dirstate._walkexplicit(), but this avoids
filesystem accesses unless case collisions occur. _discoverpath() is
used instead of normalize(), since the dirstate case is given first
precedence, and the old file is still in it. What matters is the
actual case in the filesystem.
2015-07-27 21:27:24 -04:00
Matt Harbison
eea8aa5335 extdiff: allow modifications in subrepos to be copied back
This check was a legacy bit from when the file data was being fetched manually
with 'ctx[wfn]', but archive() does that now.  2032c5b369f5 seems to indicate
that this avoided a problem where a merge adds a file to another branch, and
that test still passes.

Unfortunately, I don't see a way to create a test that modifies the file in the
temporary directory before the command exits.

I wonder if the os.lstat() call needs to be wrapped in an exception handler for
the case where archive didn't create a file because the file didn't exist in
that revision.  But I wasn't able to trigger a problem without it on a real
repository.
2015-07-27 17:39:09 -04:00
Yuya Nishihara
445c9fa91e ignore: fix path concatenation of .hgignore on Windows
Since 862fc5f60fef, .hgignore is ignored on Windows because a pat may have
a drive letter, but pathutil.join is posixpath.join.

  "z:\foo\bar/z:\foo\bar\.hgignore"

Instead, this patch uses os.path.join() and util.localpath() to process both
parts as file-system paths.

Maybe we can remove os.path.join() at dirstate._ignore because 'include:' is
resolved relative to repo root? It was introduced by 29ce78e5f35c.
2015-07-27 22:14:40 +09:00
Wagner Bruna
f6ce8ccc47 repair: fix typo in warning message 2015-07-26 09:28:52 -03:00
Anton Shestakov
e2a7644272 monoblue: link to branches on summary page
"Tags" and "Bookmarks" sections on this page already have the similar links,
and so does the "Branches" on summary page in gitweb, so let's do the same in
monoblue.
2015-07-26 18:05:10 +08:00