Commit Graph

11667 Commits

Author SHA1 Message Date
Siddharth Agarwal
dd9e1b721a util.re: move check for re2 into a separate method
We're going to use the same check for another method in an upcoming patch.
2014-07-15 15:01:52 -07:00
Siddharth Agarwal
fe4e13633a util: remove no longer used compilere 2014-07-15 14:52:40 -07:00
Siddharth Agarwal
b33f19d949 commands: use util.re.compile instead of util.compilere 2014-07-15 14:52:22 -07:00
Siddharth Agarwal
f1a50f9fee config: use util.re.compile instead of util.compilere 2014-07-15 14:50:58 -07:00
Siddharth Agarwal
5e38818cf4 match: use util.re.compile instead of util.compilere 2014-07-15 14:49:45 -07:00
Siddharth Agarwal
d0cd5cb8c7 util: move compilere to a class
We do this to allow us to use descriptors for other related methods.

For now, util.compilere does the same thing. Upcoming patches will remove it.
2014-07-15 14:40:43 -07:00
Siddharth Agarwal
04ca7a05ee util: rename 're' to 'remod'
Upcoming patches will introduce a binding called 're'.
2014-07-15 14:35:19 -07:00
Pierre-Yves David
c58559c32a bundle2-push: drop _pushbundle2extraparts
All core user are now using the new way. We drop the old way.
2014-07-02 15:47:39 +02:00
Pierre-Yves David
1df43f3299 bundle2-push: introduce a list of part generating functions
Instead of explicitly calling a few function to generate part in the bundle, we
now have a list of all part generators. This should make it easier for
extensions to adds new part in the bundle.

This new way to extend the push deprecates the old `_pushbundle2extraparts` way.
2014-07-02 15:26:04 +02:00
Pierre-Yves David
2418b3778f bundle2-push: move changegroup push validation inside _pushb2ctx
When bundle2 push includes more than just changesets, we may have no
changegroup to push yet still have other data to push.

So we now try to performs a bundle2 push in all cases. The check for changegroup
inclusion is moved into the ``_pushb2ctx`` function in charge of creating the
changegroup part.

The bundle2 part is aborted if no actual payload part have been added to the
bundle2.
2014-07-02 12:55:09 +02:00
Pierre-Yves David
9163633b35 push: use stepsdone to control changegroup push through bundle10 or bundle20
We use the newly introduced `pushop.stepsdone` attribute to inform
older methods than changegroup have already been pushed using a newer
method.
2014-07-07 12:30:31 +02:00
Pierre-Yves David
0b263a85d2 push: add a `pushop.stepsdone` attribute
This attribute will record what steps were performed during the bundle2 push.
This will control whenever the old way push must be performed or skipped. This
will ultimately be used by changegroup, phases, obsmarkers, bookmarks and any
other kind of data ones may want to exchange even when bundle2 support is
missing.
2014-07-02 12:48:54 +02:00
Pierre-Yves David
4be695cccc bundle2: add a `bundle20.nbparts` property
This property can be used to know how much parts have been added to the bundle2.
This will be useful to check if any part have been generated for a push.
2014-07-02 16:17:54 +02:00
Pierre-Yves David
5403bb5287 bundle2-push: extract changegroup logic in its own function
We extract the creation of changegroup related parts into its own function.
This precludes the inclusion of more diverse data during the bundle2 push.

We use a closure to carry the logic that need to be perform when processing the
server reply.
2014-07-02 11:42:35 +02:00
Pierre-Yves David
3c5524525e bundle2: call _pushbundle2extraparts a bit sooner
This is the first step of a refactoring that will ease the inclusion of new part
in the bundle2 push and includes more information (like phases) in this push

We need to move the function a bit sooner to be able to group the generation of
`b2x:check:heads` and `b2x:changegroup` part in an external function. We move it
sooner to preserve parts creation order bundle2 tests rely on. At the ends of this
refactoring the `_pushbundle2extraparts` will be replaced by another mechanism
anyway.
2014-07-02 14:09:24 +02:00
FUJIWARA Katsunori
f09e7bc4c8 templatekw: add 'subrepos' keyword to show updated subrepositories
'subrepos' template keyword newly added by this patch shows updated
subrepositories.

For the compatibility with the list of subrepositories shown in the
editor at commit:

  - 'subrepos' is empty, at revisions removing '.hgsub' itself

  - 'subrepos' is calculated between the revision and the first parent
    of it, at merge revisions

To avoid silent regression, this patch also confirms "hg diff" of
".hgsubstate" and parents for each target revisions in the test.
2014-07-15 23:34:13 +09:00
FUJIWARA Katsunori
843d08c987 templatekw: add 'currentbookmark' keyword to show current bookmark easily
Before this patch, complicated template expression below is required
to show current active bookmark if it is associated with the
changeset.

    "{bookmarks % '{ifeq(bookmark, current, \"{bookmark}\")}'}"

This patch add 'currentbookmark' keyword to show current bookmark
easily.
2014-07-15 23:34:13 +09:00
Siddharth Agarwal
869ee24c8b context: extend efficient manifest filtering to when all paths are files
On a repository with over 250,000 files and 700,000 commits, this improves
cases like

hg status --rev <rev> -- <file>  # rev is not .

from 2.1 seconds to 1.4 seconds.

There is further scope for improvement here: for a single file or a small set
of files, it is probably more efficient to use filelog linkrevs when possible.
However there will always be cases where that will fail (multiple commits
pointing to the same file revision, removed files...), so this is independently
useful.
2014-07-16 14:53:03 -07:00
Siddharth Agarwal
5801040e81 revset: remove no longer used _missingancestors revset
This was undocumented.
2014-07-12 00:37:08 -07:00
Siddharth Agarwal
9ea47f6848 revset: replace _missingancestors optimization with only revset
(::a - ::b) is equivalent to only(a, b).
2014-07-12 00:31:36 -07:00
Angel Ezquerra
e362f81ce1 tags: introduce _readtaghist function
The existing _readtags function has been modified a little and renamed
_readtaghist. A new _readtaghist function has been added, which is a wrappger
around _readtaghist. Its output is the same as the old _readtaghist.

The purpose of this change is to make it possible to automatically merge tag
files. In order to do so we will need to get the line numbers for each of the
tag-node pairs on the first merge parent.

This is not used yet, but will be used on a follow up patch that will introduce
an automatic tag merge algorithm.

I performed some tests to compare the effect of this change. I used timeit to
run the test-tags.t test a 9 times with and without this patch. The results
were:

- without this patch: 3 loops, best of 3: 8.55 sec per loop
- with this patch:    3 loops, best of 3: 8.49 sec per loop

The the test was on average was slightly faster with this patch (although the
difference was probably not statistically significant).
2014-06-28 01:42:39 +02:00
FUJIWARA Katsunori
bf65909194 subrepo: ensure "close()" execution at the end of "_initrepo()"
Before this patch, "close()" for the file object opened in
"_initrepo()" may not be executed, if unexpected exception is raised,
because it isn't executed in "finally" clause.

This patch ensures "close()" execution at the end of "_initrepo()" by
moving it into "finally" clause.

This patch puts configuration lines into "lines" array and write them
out at once, to narrow the scope of "try"/"finally" for review-ability.

This patch doesn't use "vfs.write()", because:

  - current "vfs.write()" implementation doesn't take "mode" argument
    to open file in "text" mode

  - writing hgrc file out in binary mode may break backward compatibility
2014-06-20 00:42:35 +09:00
FUJIWARA Katsunori
a467af4f30 subrepo: ensure "close()" execution at the end of "_cachestorehash()"
Before this patch, "close()" for the file object opened in
"_cachestorehash()" may not be executed, if unexpected exception is
raised, because it isn't executed in "finally" clause.

This patch ensures "close()" execution at the end of
"_cachestorehash()" by moving it into "finally" clause.
2014-06-20 00:21:19 +09:00
FUJIWARA Katsunori
7a254d1245 subrepo: ensure "close()" execution at the end of "_readstorehashcache()"
Before this patch, "close()" for the file object opened in
"_readstorehashcache()" may not be executed, if unexpected exception
is raised, because it isn't executed in "finally" clause.

This patch ensures "close()" execution at the end of
"_readstorehashcache()" by moving it into "finally" clause.
2014-06-20 00:21:19 +09:00
FUJIWARA Katsunori
9848086908 subrepo: ensure "close()" execution at the end of "_calcfilehash()"
Before this patch, "close()" for the file object opened in
"_calcfilehash()" may not be executed, if unexpected exception is
raised, because it isn't executed in "finally" clause.

This patch ensures "close()" execution at the end of "_calcfilehash()"
by moving it into "finally" clause.
2014-06-20 00:21:19 +09:00
FUJIWARA Katsunori
690c2c3f1b subrepo: ensure "lock.release()" execution at the end of "_cachestorehash()"
Before this patch, "lock.release()" for "self._repo" in
"_cachestorehash()" of "hgsubrepo" may not be executed, if unexpected
exception is raised, because it isn't executed in "finally" clause.

This patch ensures "lock.release()" execution at the end of
"_cachestorehash()" by moving it into "finally" clause.
2014-06-20 00:21:19 +09:00
FUJIWARA Katsunori
05e68ce418 subrepo: ensure "lock.release()" execution at the end of "storeclean()"
Before this patch, "lock.release()" for "self._repo" in "storeclean()"
of "hgsubrepo" may not be executed, if unexpected exception is raised,
because it isn't executed in "finally" clause.

This patch ensures "lock.release()" execution at the end of
"storeclean()" by moving it into "finally" clause.

This patch chooses moving almost all lines in "storeclean()" into
"_storeclean()" instead of indenting them for "try/finally" clauses,
to keep diff simple for review-ability.
2014-06-20 00:21:19 +09:00
Siddharth Agarwal
b89cfab942 context: generate filtered manifest efficiently for exact matchers
When the matcher is exact, there's no reason to iterate over the entire
manifest. It's much more efficient to iterate over the list of files instead.

For a repository with approximately 300,000 files, this speeds up
hg log -l10 --patch --follow for a frequently modified file from 16.5 seconds
to 10.5 seconds.
2014-07-12 17:59:03 -07:00
Siddharth Agarwal
021a1bd81c manifestdict: add a new method to intersect with a set of files
This is meant to be used when the set of files is known in advance, e.g. with a
match object with no patterns.
2014-07-12 17:57:25 -07:00
Siddharth Agarwal
1fe4080620 log: use an exact matcher for --patch --follow
The arguments to log --patch --follow are expected to be exact paths.

This will be used to make manifest filtering for these cases more efficient in
upcoming patches.
2014-07-12 18:31:18 -07:00
Matt Mackall
809fa98620 merge with stable 2014-07-16 17:35:04 -05:00
Siddharth Agarwal
67dffae77b log: make --patch --follow work inside a subdirectory
Previously, the 'patch' code for hg log --patch --follow would try to resolve
patterns relative to the repository root rather than the current working
directory. Fix that by using match.files instead of pats, as done elsewhere
nearby.
2014-07-12 02:23:17 -07:00
Matt Mackall
de2b99d87c templates: escape NUL bytes in jsonescape (issue4303)
It's currently possible for various fields to contain NUL bytes, which
are disallowed in JSON.
2014-07-14 12:44:45 -05:00
Matt Mackall
5fc8526562 merge with stable 2014-07-14 18:53:03 -05:00
Siddharth Agarwal
9d5c80b2c5 log: allow revset for --follow to be lazily evaluated
It is unclear to me why evaluation was forced.

For a repository with over 700,000 commits, 'hg log -f' drops from 1.2 seconds
to 0.2 seconds.
2014-07-12 20:44:00 -07:00
Siddharth Agarwal
b06eb2e341 parsers: remove unused getintat function
Warning detected by clang.
2014-07-14 15:42:31 -07:00
Matt Mackall
5157edb3f5 revset: maintain ordering when subtracting from a baseset (issue4289) 2014-07-14 17:55:31 -05:00
FUJIWARA Katsunori
ccb0dfc103 cmdutil: separate building commit text from 'commitforceeditor'
This separation makes it easier to extend/hook building commit text
from the specified context.

This patch uses 'committext' instead of 'edittext' for names of newly
added variable and function, because the former is more purpose
specific than the latter, even though 'edittext' in 'buildcommittext'
is left as it is to reduce amount of diff.
2014-07-15 00:59:09 +09:00
Gregory Szorc
ad5c0552ce localrepo: document localrepo.hook() 2014-07-12 10:52:58 -07:00
FUJIWARA Katsunori
872be90f3b filemerge: use 'util.ellipsis' to trim custom conflict markers correctly
Before this patch, filemerge slices byte sequence directly to trim
conflict markers, but this may cause:

  - splitting at intermediate multi-byte sequence

  - incorrect calculation of column width (length of byte sequence is
    different from columns in display in many cases)

This patch uses 'util.ellipsis' to trim custom conflict markers
correctly, even if multi-byte characters are used in them.
2014-07-06 02:56:41 +09:00
FUJIWARA Katsunori
31bba09810 filemerge: use only the first line of the generated conflict marker for safety
Before this patch, with careless configuration (missing '|firstline'
filtering for '{desc}' keyword, for example), '[ui]
mergemarkertemplate' can make conflict markers multiple lines.

For ordinary users, advantage of allowing '[ui] mergemarkertemplate'
to generate multiple lines for customizing seems to be less than
advantage of disallowing it for safety.

This patch uses only the first line of the conflict marker generated
from '[ui] mergemarkertemplate' configuration for safety.
2014-07-06 02:56:41 +09:00
FUJIWARA Katsunori
b34bd803eb encoding: add 'leftside' argument into 'trim' to switch trimming side 2014-07-06 02:56:41 +09:00
FUJIWARA Katsunori
5206a6fd25 util: replace 'ellipsis' implementation by 'encoding.trim'
Before this patch, 'util.ellipsis' tried to avoid splitting at
intermediate multi-byte sequence, but its implementation was incorrect.

Internal function '_ellipsis' trims specified unicode sequence not at
most maxlength 'columns in display', but at most maxlength number of
'unicode characters'.

    def _ellipsis(text, maxlength):
        if len(text) <= maxlength:
            return text, False
        else:
            return "%s..." % (text[:maxlength - 3]), True

In many encodings, number of unicode characters can be different from
columns in display.

This patch replaces 'ellipsis' implementation by 'encoding.trim',
which can trim string at most maxlength columns in display correctly,
even though specified string contains multi-byte characters.

'_ellipsis' is removed in this patch, because it is referred only from
'ellipsis'.
2014-07-06 02:56:41 +09:00
FUJIWARA Katsunori
71717db270 encoding: add 'trim' to trim multi-byte characters at most specified columns
Newly added 'trim' is used to trim multi-byte characters at most
specified columns correctly: directly slicing byte sequence should be
replaced with 'encoding.trim', because the former may split at
intermediate multi-byte sequence.

Slicing unicode sequence ('uslice') and concatenation with ellipsis
('concat') are defined as function, to make enhancement in subsequent
patch easier.
2014-07-06 02:56:41 +09:00
Matt Mackall
ffa85c3a41 bookmarks: avoid deleting primary bookmarks on rebase
Prior to this, doing "hg rebase -s @foo -d @" would delete @, which is
obviously wrong: a primary bookmark should never be automatically deleted.

This change blocks the deletion, but doesn't yet properly clean up the
divergence: @ should replace @foo.
2014-07-08 14:45:55 -05:00
Augie Fackler
23d3b7a1e7 cmdutil: add copy-filtering support to duplicatecopies
In order to fix issue 4192 we need to be able to skip some copies
while doing duplicatecopies.
2014-06-07 15:14:36 -04:00
Angel Ezquerra
870dfdf91c repoview: do not crash when localtags refers to non existing revisions
This fixes a crash that may happen when using mercurial 3.0.x.

The _gethiddenblockers function assumed that the output of tags.readlocaltags()
was a dict mapping tags to of valid nodes. However this was not necessarily the
case. When a repository had obsolete revisions and had local tag pointing to a
non existing revision was found, many mercurial commands would crash.

This revision fixes the problem by removing any tags from the output of
tags.readlocaltags() which point to invalid nodes.

We may want to add a warning when this happens (although it might be
annoying to get that warning for every command, possibly even more than once per
command).

A test for this problem has been added to test-obsolete.t. Without this fix the
test would output:

  $ hg tags
  abort: 00changelog.i@3816541e5485: no node!
  [255]

Instead of:

  $ hg tags
  tiptag                             2:3816541e5485
  tip                                2:3816541e5485
  visible                            0:193e9254ce7e
2014-06-29 13:52:35 +02:00
Siddharth Agarwal
1aa951751f match: make glob '**/' match the empty string
Previously, a glob pattern of the form 'foo/**/bar' would match 'foo/a/bar' but
not 'foo/bar'. That was because the '**' in 'foo/**/bar' would be translated to
'.*', making the final regex pattern 'foo/.*/bar'. That pattern doesn't match
the string 'foo/bar'.

This is a bug because the '**/' glob matches the empty string in standard Unix
shells like bash and zsh.

Fix that by making the ending '/' optional if an empty string can be matched.
2014-06-25 14:50:48 -07:00
Matt Mackall
831df5027c push: restore contents of HG_URL for hooks (issue4268) 2014-06-18 19:46:18 -05:00
Matt Mackall
0257c423ac hgweb: avoid initialization race (issue4280) 2014-06-16 13:30:46 -05:00