Commit Graph

34906 Commits

Author SHA1 Message Date
Matt Harbison
0a5e6b5a69 lfs: add a repo requirement for this extension when converting to lfs
This covers both the vanilla repo -> lfs repo and largefiles -> lfs conversions.
The largefiles extension adds the requirement directly, because it has a
dedicated command to convert.  Using the convert extension is better, because it
supports more features.

I'd like ideas about how to ensure that converting away from lfs works on all
files.  (See comments in test-lfs.t)
2017-11-22 22:38:50 -05:00
Matt Harbison
2583a8e324 convert: allow the sink object to be wrapped when the extension isn't loaded
The next patch will wrap the conversion code, in order to write out a
requirement for 'lfs' when appropriate.  Wrapping convcmd.convertsink() in an
afterloaded callback works fine when the convert extension is enabled by the
user.  The problem here is that lfconvert uses the convert extension, whether or
not it was formally enabled by the user.

My first attempt was to have lfs install an afterloaded callback that would wrap
the convert sink if convert was loaded, or wrap lfconvert if it wasn't.  Then
the lfconvert override could install an afterloaded callback to try wrapping the
convert sink again, before calling the original lfconvert.  But that breaks down
if largefiles can't load the convert extension on the fly. [1]  Further, some
tests were failing with an error indicating that the size of the afterloaded
list changed while iterating it.

Yuya mentioned that maybe some bits of convert could be moved into core, but I'm
not sure where to draw that line.  The convertsink() method depends on the list
of sinks, which in turn depends on the sink classes.

[1] https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-November/108038.html
2017-11-26 14:59:39 -05:00
Matt Harbison
f73ca1dafd convert: save an indicator of the repo type for sources and sinks
This seems like basic info to have, and will be used shortly when deciding
whether or not to wrap the class for lfs conversions.

The other option is to just add a function to each class.  But this seems better
in that the strings aren't duplicated, and the constructor for most of these
will run even if the VCS isn't installed, so it's easier to catch errors.
2017-11-22 20:49:01 -05:00
Matt Harbison
ed0e86ccdb lfs: add a repo requirement for this extension once an lfs file is committed
Largefiles does the same thing (also delayed until the first largefile commit),
to prevent access to the repo without the extension.  In the case of this
extension, not having the extension loaded while accessing an lfs file results
in cryptic errors about "missing processor for flag '0x2000'".  If enabled
locally but not remotely, the cryptic error message is about no common
changegroup version.  (It wants '03', which is currently experimental.)

The largefiles extension looks for any tracked file that starts with '.hglf/'.
Unfortunately, that doesn't work here.  I didn't see any way to get the files
that were just committed, without doing a full status.  But since there's no
secondary check on adding an lfs file once the extension is loaded and a
threshold set, the best practice is to only enable this locally on a repo that
needs it.  That should minimize the unnecessary overhead for repos without an
lfs file.
2017-11-15 23:43:15 -05:00
Yuya Nishihara
259c2d3a80 match: remove doc about undefined behavior of visitdir()
This was added by cb39606d374e, but core matchers support visitdir() of
arbitrary locations since a4236180df5e, and verifier._verifymanifest()
doesn't seem to strictly obey the restriction.

I have no idea how important this API contract is for third-party extensions.
That's why this patch is RFC.
2017-11-30 22:32:13 +09:00
Augie Fackler
da28f5be4e merge with stable 2017-11-30 15:48:42 -05:00
Augie Fackler
285d5a2a3b merge with i18n 2017-11-29 17:49:08 -05:00
Matt Harbison
40cf71ae24 convert: avoid wrong lfconvert defaults by moving configitems to core
The `hg lfconvert --to-normal` command uses the convert extension internally to
work its magic, but that produced devel-warn messages if the convert extension
wasn't loaded by the user.  The test in 658e7a6d93e0 (modified here) wasn't
showing the warnings because the convert extension was loaded via $HGRCPATH.
Most of the config options default to None/False, but 'hg.usebranchnames' and
'hg.tagsbranch' are supposed to default to True and 'default' respectively.

The first iteration of this was to ui.setconfig() inside lfconvert, to force the
convert extension to load.  But there really is no precedent for doing this, and
check-config complained that 'extensions.convert' isn't documented.  Yuya
suggested this alternative.

This partially backs out 448e09d8859d.
2017-11-28 23:20:08 -05:00
Boris Feld
cf402c02f7 tr-summary: keep a weakref to the unfiltered repository
Repoview can have a different life cycle, causing issue in some corner
cases. The particular instance that revealed this comes from localpeer. The
localpeer hold a reference to the unfiltered repository, but calling 'local()'
will create an on-demand 'visible' repoview. That repoview can be garbaged
collected any time. Here is a simplified step by step reproduction::

    1) tr = peer.local().transaction('foo')
    2) tr.close()

After (1), the repoview object is garbage collected, so weakref used in (2)
point to nothing.


Thanks to Sean Farley for helping raising and debugging this issue.
2017-11-24 21:51:41 -05:00
Anton Shestakov
9c20612eac hgweb: add .jshintrc with some basic rules
This file is picked up automatically by jshint, so no extra changes required in
test-check-jshint.t.
2017-11-22 22:18:06 +08:00
Anton Shestakov
450b6a8ce6 hgweb: look up "URLSearchParams" in "window" to work around jshint issues
Unfortunately, current version of jshint (2.9.5) doesn't know such a global
variable and complains that it's undefined. Since this line tries to look up
URLSearchParams in a global scope (i.e. window), let's simply preface it with
"window." to work around jshint.
2017-11-22 22:11:37 +08:00
Anton Shestakov
0e80806e94 hgweb: define locally used variables as actually local in mercurial.js
Variables that are used or assigned without any declaration using var (or let,
or const) are considered global. In many cases this is inadvertent and actually
causes a variable leaking to a broader scope, such as a temporary variable used
inside a loop suddenly being accessible in global scope. (This corresponds to
"undef" option of jshint).

So this patch limits the scope of variables that don't need to be global. There
are a lot of helper variables in Graph.render() used in a loop, I've declared
them all on one line to reduce patch size. "radius" is special because it
wasn't passed to graph.vertex, but was used there (it worked because this
variable leaked to global scope). "window.graph" is created by an inline script
in graph.tmpl so that it can be used in ajaxScrollInit() function, this patch
makes this fact explicit by assigning window.graph to a local variable.
2017-11-22 21:49:36 +08:00
Anton Shestakov
6d8846bc41 hgweb: rename an instance of XMLHttpRequest to xhr in mercurial.js
"xhr" is a really widespread name for this kind of things, no idea where did
"xfr" come from (the original fbf9645839e4 doesn't explain that). Let's just
change one letter so the name makes more sense.
2017-11-22 21:32:18 +08:00
Anton Shestakov
925cb3fa58 hgweb: properly iterate over arrays and objects in mercurial.js
In JavaScript, using for-in loops to access every property of an object can
have unexpected results when inheritance is involved. For example, if some
piece of code adds a property (it may be a method too) to Object.prototype,
then all for-in loops that iterate over keys of any object (also anything that
inherits Object) will get that property on one of the iterations. To filter out
such unexpected properties for-in loops have to use Object.hasOwnProperty()
method. (This corresponds to "forin" option of jshint).

In the two first cases "data" and "edges" are arrays, to it's simpler to just
switch to using a regular for-with-a-counter loop.
2017-11-22 21:15:44 +08:00
Anton Shestakov
834be0af5c hgweb: use strict equals in mercurial.js
This patch changes "==" (equals operator) to "===" (strict equals operator).
The difference between them is that the latter doesn't do any type coercions.
It's handy to compare string '1' to number 1 sometimes, but most of the time
using "==" is inadvertent and can be replaced by an explicit type conversion.
(This corresponds to "eqeqeq" option of jshint).

Some of the changes in this patch are straightforward, e.g. when comparing
results of typeof (they could only be strings). The same goes for 'none' and
similar strings that can't be sensibly coerced to some other type. Two changes
that compare values to "1" and "0" can be clarified: getAttribute() returns
either a string or null, but comparing null to a string is always false, so no
logic is lost.
2017-11-22 20:52:59 +08:00
Anton Shestakov
a994030bc9 hgweb: use strict equals, remove non-breaking space in followlines.js
The first hunk had a non-breaking space character just before "{", it's not an
error or anything, but let's fix it while we're at it. (This corresponds to
"nonbsp" option of jshint).

Hunks 2 and 3 change "==" (equals operator) to "===" (strict equals operator).
The difference between them is that the latter doesn't do any type coercions.
It's handy to compare string '1' to number 1 sometimes, but most of the time
using "==" is inadvertent and can be replaced by an explicit type conversion.
(This corresponds to "eqeqeq" option of jshint).

Most of this file already uses strict equals operator, and in the code affected
type coercion is not needed, because tagName and selectableTag are both strings
and endId and startId are both numbers.
2017-11-22 20:32:07 +08:00
Martin von Zweigbergk
78a897a44d run-tests: make "| foo (re)" not match everything
We make "foo (re)" match the entire line by adding a \Z to the regular
expression before matching. However, that doesn't help when the
regular expression is something like "| foo", because that gets
translated to "| foo\Z", where the "|" has lower precedence and it
thus matches the empty string, which is of course a prefix of every
string. Fix by wrapping expression in a group before adding the \Z to
the end.

Differential Revision: https://phab.mercurial-scm.org/D1546
2017-11-29 10:34:49 -08:00
Martin von Zweigbergk
cecc308ad5 tests: fix regex in test-subrepo-git.t to match entire string
Due to a bug in the test runner (fixed by the next commit), the regex
used for matching lines like " foobar | 2 +-" stoppped at the "|" and
the test passed even though the rest of the line did not match. The
test seems to have been supposed to match "|" and "+" literally on
those lines, so this changes the regex to escape those characters. It
also changes a "\s*" to "\s+" since I think we'll always include a
space after the "|" in the diffstat output.

Differential Revision: https://phab.mercurial-scm.org/D1545
2017-11-29 10:58:32 -08:00
Augie Fackler
60b36d6799 contrib: improve check-code ban on $LOCALIP in output without (glob)
Differential Revision: https://phab.mercurial-scm.org/D1553
2017-11-29 17:06:45 -05:00
Augie Fackler
2a1d51dca4 tests: re-add (glob) for $LOCALIP matches
This should fix most of the failing tests on the FreeBSD builder,
since it has no 127/8 series IP as a side effect of being trapped in a
jail.

Differential Revision: https://phab.mercurial-scm.org/D1552
2017-11-29 17:05:51 -05:00
Pulkit Goyal
ad73ed1dae py3: make sure the first argument of time.strftime() is str
time.strftime() does not accepts bytes as its first argument on py3.

Differential Revision: https://phab.mercurial-scm.org/D1559
2017-11-29 08:44:06 +05:30
Pulkit Goyal
5bdb7d8262 py3: alias xrange to range in tests/seq.py
Differential Revision: https://phab.mercurial-scm.org/D1560
2017-11-29 08:46:37 +05:30
Pulkit Goyal
044c1aa613 py3: use pycompat.maplist() instead of map()
Differential Revision: https://phab.mercurial-scm.org/D1558
2017-11-29 08:40:58 +05:30
Anton Shestakov
833558d7cd tests: move JSON escape test to test-hgweb-json.t
The original tests (kanji and null) in test-hgweb-commands.t come from
6213c4c3d3f7 and f18359d4ac5a, but they check json escape filter by using
JavaScript variable on /graph page, which is awkward, and I'm planning to
remove commit description from this variable soon. Let's move the parts that
check json template filter to a more appropriate file and use normal json-*
templates.
2017-11-30 16:30:43 +08:00
Pulkit Goyal
291a4c706a py3: fix handling of keyword arguments in revert
Differential Revision: https://phab.mercurial-scm.org/D1554
2017-11-29 07:57:17 +05:30
Boris Feld
fe39de3207 fsmonitor: issue debug messages when we fall back to core status
Having more information about when and why fsmonitor bails out help when
looking into status performance.
2017-11-28 11:00:54 -05:00
Pulkit Goyal
134a289843 py3: add b'' to regular expressions which are raw strings
Differential Revision: https://phab.mercurial-scm.org/D1538
2017-11-29 04:47:27 +05:30
Pulkit Goyal
82e1e097dc py3: use '%d' for integers rather than '%s'
obsolete._readmarkers() returns an integer version number.

Differential Revision: https://phab.mercurial-scm.org/D1537
2017-11-29 04:41:19 +05:30
Pulkit Goyal
6a9585e5d1 py3: fix args handling for obsfate template
Differential Revision: https://phab.mercurial-scm.org/D1536
2017-11-29 04:41:48 +05:30
Pulkit Goyal
47560b9470 py3: remove test-terse-status.t from python3 whitelist as it was renamed
The renamed file exists in the whitelist.

Differential Revision: https://phab.mercurial-scm.org/D1540
2017-11-29 06:48:52 +05:30
Wagner Bruna
9766674d68 i18n-pt_BR: synchronized with f1d5a55d6a57 2017-11-21 13:50:25 -02:00
Matt Harbison
555700adde test-lfs: allow the test server to be killed on Windows
Apparently '$!' doesn't return a Win32 PID, so the process was never killed, and
the next run was screwed up.  Oddly, without the explicit killdaemons.py at the
end, the test seems to hang.  This spawning is just sad, so I limited it to
Windows.
2017-11-21 00:24:09 -05:00
Matt Harbison
bef85d8500 test-lfs: perform the chmod +x command in a manner compatible with Windows 2017-11-14 22:53:52 -05:00
Matt Harbison
f4937719cf hghave: add a check for lfs-test-server
This is consistent with how the other tests require a feature.
2017-11-14 22:35:42 -05:00
Anton Shestakov
5c0beecc82 hgweb: show changeset age in more places (gitweb and monoblue)
mercurial.js has a process_dates() function that calculates relative age for a
given date, it works for all elements with "age" css class. If those elements
also have "date" css class, the original text is preserved and age is added at
the end.

This patch adds these two css classes in some pages in gitweb and monoblue that
weren't already using this feature.
2017-11-21 20:28:57 +08:00
Boris Feld
9fd6108d9c obsolete: drop usage of changectx in '_computecontentdivergentset'
Changectx are expensive and not needed there. The use of `repo.set` denote old
code that predate the introduction of `repo.revs` that we now use.

On my mercurial repository 495 draft:

    before: 0.054239 second
    after:  0.046935 second

On a mercurial repository with 115973 draft:

    before: 0.564548 second
    after:  0.130534 second
2017-11-19 05:34:50 +01:00
Boris Feld
aa5228bff7 obsolete: drop usage of changectx in '_computephasedivergentset'
Changectx are expensive and not needed there. The use of `repo.set` denote old
code that predate the introduction of `repo.revs` that we now use.

On my mercurial repository 495 draft:

    before: 0.010275 second
    after:  0.008832 second

On a mercurial repository with 115973 draft:

    before: 0.899255 second
    after:  0.397131 second
2017-11-19 05:23:12 +01:00
Anton Shestakov
244418453f hgweb: remove unused Graph() properties
Both of these were introduced in 083571f47ff6, but were already unused.
2017-11-25 16:01:27 +08:00
Anton Shestakov
3696751497 gitweb: remove unused css classes
Looks like they were unused since the very introduction of gitweb theme in
8a464c5805aa.
2017-11-25 15:42:24 +08:00
Anton Shestakov
f0252b2ab8 monoblue: also highlight target line on annotate and comparison pages
Clicking on a line link on pages that show any kind of file contents (including
diffs) should highlight that line, and in monoblue it works when there's a
<pre> element (e.g. diff), but pages that use <table> element (annotate and
compare) need this css class. It matches and highlights linked (":target")
table rows. This line is pretty much copied from gitweb theme.
2017-11-25 15:23:07 +08:00
Anton Shestakov
d86bd961a0 paper: remove css hack that made .branchname look like .branchhead
There's a visual difference in hgweb between one changeset that is the tip of
its branch and another that simply belongs to that branch. But paper theme
ignored this difference on changeset page and used to always use "branchname"
css class, be that changeset the tip of its branch or not. That has been
recently fixed, so this piece of css is not needed anymore.
2017-11-25 15:01:47 +08:00
Anton Shestakov
296ab8c247 hgweb: rename the main attribute of instabilities
Let's make "instabilities" list contain items with "instability" key as opposed
to "name" key. This way it's more explicit and more consistent with the log
command-line template.
2017-11-26 13:29:18 +08:00
David Soria Parra
7766b6cfbc hbisect: use a defaultdict to avoid large allocations for a large changelogs
We can avoid a SPACE(len(changelog)) allocation by using a defaultdict.

Test Plan:
    python run-tests.py test-bisect*

Differential Revision: https://phab.mercurial-scm.org/D1499
2017-11-23 14:13:14 -08:00
David Soria Parra
690d883f70 hbisect: use a revset for ancestor calculation
Since we have revsets we can be more concise in doing the ancestor calulcation.
Significant commits are all descendent of the topmost good commits.

Test Plan:
    python run-tests.py test-bisect*

Differential Revision: https://phab.mercurial-scm.org/D1498
2017-11-23 14:12:55 -08:00
David Soria Parra
10f01a10fc hbisect: pass repo into hbisect.bisect
Pass repo into the bisect function to get more flexibility in what we can call.
This will allow us to use revsets to rewrite parts of the ancestor and children
calculation in later patches.

Test Plan:
    python run-tests.py test-bisect*

Differential Revision: https://phab.mercurial-scm.org/D1497
2017-11-23 14:11:27 -08:00
Kyle Lippincott
6d75dc536c develwarn: do not emit warning if "config" is unspecified
Previously, if the develwarn call site did not specify the category of warning,
and devel.all-warnings was False, it would emit the warning.  If it was
intended that this emit a warning if config is unspecified, I would have
expected a comment, so I assumed this was unintentional and am changing the
behavior.

Differential Revision: https://phab.mercurial-scm.org/D1494
2017-11-22 19:24:22 -08:00
Yuya Nishihara
52b06fe73d dispatch: verify result of early command parsing
Before, early options were stripped from args, and because of this, some
kind of parsing errors weren't reported. For example,

  $ hg ci -m -Ra file

would execute "hg ci -m file" in repository "a".

This patch fixes the issue by parsing early options again by real getopt-based
parser, and verifying the results. If the early parsing appears wrong, hg just
aborts. The current error message seems not nice, and should be improved, maybe
in V2 or follow-up.

Note that this isn't a security feature because we can still do anything by
using shell aliases.
2017-11-11 12:40:13 +09:00
Yuya Nishihara
fccba4aa77 dispatch: convert non-list option parsed by _earlygetopt() to string
So we can easily compare it with the corresponding getopt() result.

There's a minor behavior change. Before, "hg --cwd ''" failed with ENOENT.
But with this patch, an empty cwd is silently ignored. "hg -R ''" has always
worked as such, so -R has no BC.
2017-11-11 17:55:15 +09:00
Yuya Nishihara
f9dd555dd4 dispatch: add option to not strip command args parsed by _earlygetopt()
This allows us to parse the original args later by full-blown getopt() in
order to verify the result of the faulty early parsing. Still we need the
'strip=True' behavior for shell aliases.

Note that this series is RFC because it seems to change too much to be
included in stable release.
2017-11-11 16:46:41 +09:00
Yuya Nishihara
333fc1d401 dispatch: fix early parsing of short option with value like -R=foo
Before, -R=foo was parsed as '-R' 'foo', which disagrees with the standard
getopt behavior.
2017-11-14 00:25:59 +09:00