Commit Graph

32913 Commits

Author SHA1 Message Date
Adam Simpkins
bca99d2980 extensions: call afterloaded() with loaded=False for disabled extensions
If an extension was loaded but disabled due to a minimumhgversion check it
will be present in the _extensions map, but set to None.  The rest of the
extensions code treats the extension as if it were not present in this case,
but the afterloaded() function called the callback with loaded=True.
2017-06-23 10:59:05 -07:00
FUJIWARA Katsunori
ec156d9a8a fetch: remove shorthand of --edit colliding against -e/-ssh in remoteopts (BC)
Before this patch, -e/--edit and -e/--ssh of fetch command collide
against each other. This causes that -e is treated as shorthand of
--edit but doesn't work as same as --edit. Therefore, -e works as
neither --edit nor --ssh, in practice.

This issue was introduced at f54ee4b17f46 (or 1.0), which renamed
-f/--force-editor to -e/--edit. At that point, -e was already used as
shorthand of --ssh.

After this patch, -e is treated as shorthand of --ssh.

This patch is marked as "(BC)", because -e as shorthand of --edit in
existing scripts causes failure (or unexpected result) after this
patch. This impact should be less enough, because --edit mainly
focuses on interactive use.

BTW, test-duplicateoptions.py (since 1f980ef518d2 or 1.9) can't detect
this kind of issues as expected, because direct invocation of
extensions.loadall() doesn't involve registration of commands defined
in extensions (this issue is fixed in subsequent patch).
2017-06-24 02:39:13 +09:00
Rishabh Madan
f74a00edef releasenotes: improve parsing around bullet points
Earlier, on parsing the bullet points from existing release notes the bullet
points after the first one weren't written correctly to the notes file. This
patch makes changes to parsereleasenotesfromfile() function that introduces a new
bullet_points data structure that tracks the bullets and associated subparagraph.
It also makes necessary changes to the tests related to merging of bullets.
2017-06-23 17:15:53 +02:00
Sean Farley
2906ca38ca bookmarks: factor method _printer out of for loop in printbookmarks
This allows even further customization via extensions for printing
bookmarks. For example, in hg-git this would allow printing remote refs
by just modifying the 'bmarks' parameter instead of reimplementing the
old commands.bookmarks method.

Furthermore, there is another benefit: now multiple extensions can
chain their custom data to bookmark printing. Previously, an extension
could have conflicting bookmark output due to which loaded first and
overrode commands.bookmarks. Now they can all play nicely together.
2017-06-20 17:18:20 -07:00
Sean Farley
c2c33ecbd5 bookmarks: factor out bookmark printing from commands 2017-06-20 16:36:25 -07:00
Sean Farley
d7dbaa4938 commands: move activebookmarklabel to bookmarks module
This is going to be used in an upcoming patch that moves more methods to
bookmarks.py.
2017-06-20 15:56:29 -07:00
Sean Farley
ae713d84ab commands: replace locking code with a context manager
Note that this means that we're unnecessarily creating a transaction
in the pure "--inactive" (i.e. when deactivating the current
bookmark), but that should be harmless.
2017-06-20 15:36:43 -07:00
Sean Farley
b3855ee8cc bookmarks: factor out adding a list of bookmarks logic from commands
We keep the lock in the caller so that future devs are aware of the
locking implications.
2017-06-20 15:18:40 -07:00
Matt Harbison
3a1dae7593 largefiles: avoid a crash when archiving a subrepo with largefiles disabled
This path is also used for extdiff, which is how I crossed paths with it.
Without this, an AttributeError occurs looking for 'lfstatus' on
localrepository.  See also ca0085e432d6.

The other archive method is for the archival.py override, so it doesn't need to
be special cased like this.  (It looks like it is only called for the top level
repo.)  Likewise, the transplant override is also for commands.py.  The other
overrides set lfstatus before examining it.
2017-06-13 22:24:41 -04:00
Sean Farley
55d19ae197 bookmarks: factor out rename logic from commands
We keep the lock in the caller so that future devs are aware of the
locking implications.
2017-06-13 11:10:22 -07:00
Sean Farley
da73ed7374 bookmarks: factor out delete logic from commands
We keep the lock in the caller so that future devs are aware of the
locking implications.
2017-06-12 23:02:48 -07:00
Augie Fackler
a22823ec45 merge with stable 2017-06-23 15:30:27 -04:00
Yuya Nishihara
c47ec16b6a revset: add startdepth limit to ancestors() as internal option
This is necessary to implement the set{gen} (set subscript) operator. For
example, set{-n} will be translated to ancestors(set, depth=n, startdepth=n).

https://www.mercurial-scm.org/wiki/RevsetOperatorPlan#ideas_from_mpm

The UI is undecided and I doubt if the startdepth option would be actually
useful, so the option is hidden for now. 'depth' could be extended to take
min:max range, in which case, integer depth should select a single generation.

  ancestors(set, depth=:y)  # scan up to y-th generation
  ancestors(set, depth=x:)  # skip until (x-1)-th generation
  ancestors(set, depth=x)   # select only x-th generation

Any ideas are welcomed.

  # reverse(ancestors(tip)) using hg repo
  3) 0.075951
  4) 0.076175
2017-06-18 00:40:58 +09:00
Yuya Nishihara
3a18a16767 revset: add depth limit to ancestors()
This is proposed by the issue5374, and will be a building block of set{gen}
(set subscript) operator.

https://www.mercurial-scm.org/wiki/RevsetOperatorPlan#ideas_from_mpm

  # reverse(ancestors(tip)) using hg repo
  2) 0.075408
  3) 0.075951
2017-06-18 00:22:41 +09:00
Yuya Nishihara
af9646319c dagop: compute depth in revancestors() generator
Surprisingly, this makes revset benchmark slightly faster. I don't know why,
but it appears that wrapping -inputrev by tuple is the key. So I decided to
just enable depth computation by default.

  # reverse(ancestors(tip)) using hg repo
  1) 0.081051
  2) 0.075408
2017-06-18 00:11:48 +09:00
Yuya Nishihara
538d2e426b dagop: just compare with the last value to deduplicate input of revancestors()
Since we're using a max heap, the current rev should be a duplicate only
if it equals to the previous one. We don't have to maintain the whole seen
set.

  # reverse(ancestors(tip)) using hg repo
  0) 0.086420
  1) 0.081051
2017-06-18 08:59:09 +09:00
Yuya Nishihara
a08fb00a93 dagop: bulk rename variables in revancestors() generator
- h -> pendingheap: "h" seems too short for variable of long lifetime
 - current -> currev: future patches will add current "depth" variable
 - parent -> prev or pctx: short lifetime, follows common naming rules
2017-06-18 17:22:57 +09:00
Yuya Nishihara
6ade9d6bff dagop: comment why revancestors() doesn't heapify input revs at once
I wondered why we're doing this complicated stuff without noticing the input
revs may be iterated lazily in descending order. e9a070fa585b showed why.
2017-06-18 17:16:02 +09:00
Yuya Nishihara
038a677e17 dagop: unnest inner generator of revancestors()
This just moves iterate() to module-level function.
2017-06-17 22:33:23 +09:00
Denis Laxalde
831d4dcf5b hgweb: plug followlines action in annotate view
Add the followlines.js script and corresponding parameters as data attribute
on <tbody class="sourcelines"> element.
Extend CSS rules so that they also match the DOM structure of annotate view.

As previously, only address paper and gitweb styles (other styles do not have
followlines at all).
2017-06-21 17:17:17 +02:00
Denis Laxalde
cd2cc3059a hgweb: parameterize the tag name of elements holding followlines selection
While plugging followlines.js into "annotate" view, we'll need to walk a
different DOM structure from that of "filerevision" view. In particular, the
selectable source line element is a <tr> in annotate view (in contrast with a
<span> in filerevision view). So make this tag name a parameter of
followlines.js script by passing its value as a "selectabletag" data attribute
of <pre class="sourcelines"> element.

As <pre class="sourcelines"> tags are getting quite long in templates, rewrite
them on several lines.
2017-06-21 17:07:51 +02:00
Denis Laxalde
d0134f71a8 gitweb: wrap table rows of annotate view into a <tbody> element
We will use this element to hook data attribute for the followlines.js script
to be plugged in annotate view. Also this gets symmetrical with paper style
which already has a <tbody> element.
2017-06-21 17:02:21 +02:00
Denis Laxalde
79e8469c39 tests: update regex check for fetch error in test-clonebundles.t
On some systems, e.g. Docker container, the actual error may be:

  error fetching bundle: [Errno 99] Cannot assign requested address

Update the regex to handle this case.
2017-06-22 11:16:29 +02:00
Gregory Szorc
09c5531c2e hgweb: use separate CSS class for navigation links in footer
c0593b622180 changed the styling of the "page_nav" CSS class to use
flexbox to separate elements within the <div>. I didn't realize that
this class was used outside of the links in the header. So this
resulted in incorrectly formatting links in the footer of various
pages. Fix that by introducing a new CSS class that preserves the
old CSS behavior.
2017-06-20 20:53:29 -07:00
Pierre-Yves David
8f6dde9279 configitems: register 'ui.clonebundleprefers' as example for 'configlist'
This exercise the default value handling in 'configlist'.
2017-06-17 13:25:42 +02:00
Pierre-Yves David
414fa65e17 configitems: register 'patch.fuzz' as first example for 'configint'
This exercise the default value handling in 'configint'.
2017-06-17 13:17:10 +02:00
Pierre-Yves David
4579a8de56 configitems: issue a devel warning when overriding default config
If the option is registered, there is already a default value available and
passing a new one is at best redundant. So we issue a deprecation warning in
this case.

(note: there will be case were the default value will not be as simple as what
is currently possible. We'll upgrade the configitems code to handle them in
time.)
2017-06-17 13:08:03 +02:00
Pierre-Yves David
101a7d166c configitems: register 'ui.quiet' as first example
We now have a user and this works fine.
2017-06-17 12:33:59 +02:00
Pierre-Yves David
7918debc04 configitems: get default values from the central registry when available
We do not have any registered config yet, but we are now ready to use them.

For now we ignore this feature for config access with "alternates". On the long
run, we expect alternates to be handled as "aliases" by the config item
themself.
2017-06-17 12:15:28 +02:00
Pierre-Yves David
ba2fa929d4 configitems: introduce a central registry for config option
We now have the appropriate infrastructure to register config items. Usage will
added in the next changeset.
2017-06-17 18:43:27 +02:00
Pierre-Yves David
5371837b9e configitems: add a basic class to hold config item information
The goal of this class is allow explicit declaration for the available config
option. This class will hold the data for one specific config item.

To keep it simple we start centralizing the handling of the default config value.

In the future we can expect more data to be carried on this class. For example:
 - documentation,
 - status (experimental, advanced, normal, deprecated),
 - aliases,
 - expected type,
 - etc...
2017-06-17 18:41:55 +02:00
Jun Wu
f17b667b60 run-tests: fix -i when "#testcases" is used in .t test
The "#testcases" feature introduced by 250afd791085 has issues with "-i"
because "-i" uses "test.name.endswith('.t')" to test if a test is .t or not.

test.name could now be something like "test-foo.t (caseA)" so the above
endswith test is no longer valid.

This patch changes the test to use "self.path" which won't have the issue.
2017-06-21 01:12:31 -07:00
Jun Wu
ca342cbec6 run-tests: update .t reference output after reading the test
The .t file is both test input and reference output. They should always
match. However we have different code paths to read reference output
(Test.__init__ -> Test.readrefout) and test input (TTest._run) so they might
be inconsistent if somethings change the file between those two functions.

This patch assigns "lines" read by "_run" back to "_refout" if "_refout" is
not None (with --debug, see Test.readrefout) so reference output and test
input will always match.
2017-06-21 01:12:31 -07:00
Jun Wu
df1862bacf run-tests: do not prompt changes (-i) if a race condition is detected
The race condition is like:

  1. run-tests.py reads test-a.t as reference output, content A
  2. run-tests.py runs the test (which could be content B, another race
     condition fixed by the next patch, but assume it's content A here)
  3. something changes test-a.t to content C
  4. run-tests.py compares test output (content D) with content A
  5. with "-i", run-tests.py prompts diff(A, D), while the file has content
     C instead of A at this time

This patch detects the above case and tell the user to rerun the test if
they want to apply test changes.
2017-06-21 01:05:20 -07:00
Jun Wu
5e22630fbf patch: rewrite reversehunks (issue5337)
The old reversehunks code accesses "crecord.uihunk._hunk", which is the raw
recordhunk without crecord selection information, therefore "revert -i"
cannot revert individual lines, aka. issue5337.

The patch rewrites related logic to return the right reverse hunk for
revert. Namely,

 1. "fromline" and "toline" are correctly swapped [1]
 2. crecord.uihunk generates a correct reverse hunk [2]

Besides, reversehunks(hunks) will no longer modify its input "hunks", which
is more expected.

[1]: To explain why "fromline" and "toline" need to be swapped, take the
     following example:

  $ cat > a <<EOF
  > 1
  > 2
  > 3
  > 4
  > EOF

  $ cat > b <<EOF
  > 2
  > 3
  > 5
  > EOF

  $ diff a b
  1d0   <---- "1" is "fromline" and "0" is "toline"
  < 1         and they are swapped if diff from the reversed direction
  4c3             |
  < 4             |
  ---             |
  > 5             |
                  |
  $ diff b a      |
  0a1   <---------+
  > 1
  3c4   <---- also "4c3" gets swapped to "3c4"
  < 5
  ---
  > 4

[2]: This is a bit tricky.

For example, given a file which is empty in working parent but has 3 lines
in working copy, and the user selection:

    select hunk to discard
    [x] +1
    [ ] +2
    [x] +3

The user intent is to drop "1" and "3" in working copy but keep "2", so the
reverse patch would be something like:

        -1
         2 (2 is a "context line")
        -3

We cannot just take all selected lines and swap "-" and "+", which will be:

        -1
        -3

That patch won't apply because of "2". So the correct way is to insert "2"
as a "context line" by inserting it first then deleting it:

        -2
        +2

Therefore, the correct revert patch is:

        -1
        -2
        +2
        -3

It could be reordered to look more like a common diff hunk:

        -1
        -2
        -3
        +2

Note: It's possible to return multiple hunks so there won't be lines like
"-2", "+2". But the current implementation is much simpler.

For deletions, like the working parent has "1\n2\n3\n" and it was changed to
empty in working copy:

    select hunk to discard
    [x] -1
    [ ] -2
    [x] -3

The user intent is to drop the deletion of 1 and 3 (in other words, keep
those lines), but still delete "2".

The reverse patch is meant to be applied to working copy which is empty.
So the patch would be:

        +1
        +3

That is to say, there is no need to special handle the unselected "2" like
the above insertion case.
2017-06-20 23:22:38 -07:00
Pierre-Yves David
447cbfab6f profiling: cope with configwith default value handling changes
Changeset 3d003a7a1a87 change 'configwith' behavior so that the default value is
run through the conversion function. In parallel a new user of 'configwith' got
introduced unaware of this coming behavior change. This broke profiling.

We resolve the situation by having the new conversion function cope with a
default value already using the right type.
2017-06-21 10:46:18 +02:00
Martin von Zweigbergk
153a1c94b7 py3: catch StopIteration from next() in generatorset
IIUC, letting the StopIteration through would not cause any bugs, but
not doing it makes the test-py3-commands.t pass.

I have also diligently gone through all uses of next() in our code
base. They either:

 * are not called from a generator
 * pass a default value to next()
 * catch StopException
 * work on infinite iterators
 * request a fixed number of items that matches the generated number
 * are about batching in wireproto which I didn't quite follow

I'd appreciate if Augie or someone else could take a look at the
wireproto batching and convince themselves that the next(batchable)
calls there will not raise a StopIteration.
2017-06-20 14:00:41 -07:00
Matt Harbison
173062cab9 tests: adjust quoting to keep Windows happy with recent $PYTHON change
I tried adding quotes to the $PYTHON variable, and also tried converting the
path from the current 'c:/Python/python.exe' form to '/c/python/python.exe', but
neither worked.  I'm not sure why one of these needs '\"' around the variable
and the other doesn't.
2017-06-20 23:23:45 -04:00
Martin von Zweigbergk
18bcf3de5c bundle2: don't use debug message "no-transaction" with transaction 2017-06-20 16:33:13 -07:00
Pulkit Goyal
b5c1ee7c59 py3: use pycompat.bytestr() in place of str() 2017-06-21 02:20:34 +05:30
Pulkit Goyal
42ca4394c3 py3: use r'' to access values from kwargs where keys are str
These are the cases where either args is again passed as keyword argument or 1
or 2 elements are accessed. So it's better to add an r'' to prevent it
converting to bytes rather than doing the conversion of args.
2017-06-21 02:13:34 +05:30
Pulkit Goyal
bdff49ff8e py3: convert keys of kwargs in template keywords functions to bytes
This patch converts the args argument keys' to bytes wherever necessary as there
are some places where either args is not used or using r'' is better or args is
again passed as keyword arguments.
2017-06-21 02:10:25 +05:30
Pulkit Goyal
ed094222db py3: make sure the commands name are bytes in test-devel-warnings.t 2017-06-20 23:50:50 +05:30
Pulkit Goyal
d05173a0a0 py3: replace str with bytes in isinstance()
We were using str because on Python 2, str were bytes but now we have to use
bytes. Otherwise the if conditions fails and we have weird results from commands
on Python 3.
2017-06-20 23:46:18 +05:30
Pulkit Goyal
dc7fe61263 py3: catch binascii.Error raised from binascii.unhexlify
Before Python 3, binsacii.unhexlify used to raise TypeError, now it raises
binascii.Error.
2017-06-20 22:11:46 +05:30
Jun Wu
52b1076198 shelve: allow unlimited shelved changes per name
Previously, there is a 100 changes limit per name (bookmark or named
branch). And the user will get "too many shelved changes named %s" when they
are trying to shelve the 101th change. I hit that error message today.

This limit was introduced by the shelve extension since the beginning.
The function generating the names was called "gennames", under
"getshelvename".

There is another "gennames" under "backupfilename":

    def backupfilename(self):
        def gennames(base):
            yield base
            base, ext = base.rsplit('.', 1)
            for i in itertools.count(1):
                yield '%s-%d.%s' % (base, i, ext)

"itertools.count" is an endless counter.

Since the other "gennames" generates unlimited number of names, and the
changeset introducing the limit (49d4919d21) does not say why the limit
is useful. It seems safe to just remove the limit.

The format "%02d" was kept intentionally so existing shelved changes won't
break.
2017-06-20 23:39:59 -07:00
Pierre-Yves David
5640bb2ad1 config: use the new '_unset' value for 'configsuboptions'
This should let configsuboptions delegate all special processing of the default
config value to the main 'config' method.
2017-06-17 12:51:37 +02:00
Pierre-Yves David
3828008441 config: use the 'config' method in 'configsuboptions'
There was unnecessary code duplication. It was getting in the way of the
unification of the default value logic.
2017-06-17 18:28:20 +02:00
Pierre-Yves David
30b883a533 config: use the new '_unset' value for 'configpath'
This should let 'configpath' delegate all special processing of the default
config value to the main 'config' method.
2017-06-17 12:52:02 +02:00
Pierre-Yves David
73fc40fe02 config: use the new '_unset' value for 'configdate'
This should let 'configdate' delegate all special processing of the default
config value to the main 'config' method.

The default value for date (None) is still enforced in this method if no other
default were passed.
2017-06-17 12:54:45 +02:00