Commit Graph

20380 Commits

Author SHA1 Message Date
Denis Laxalde
13f0a4a653 show: use labelcset() template alias for work (and stack) views
By reusing labelcset() template alias from map-cmdline.default we can now
display obsolescence information in `hg show work/stack`.
2017-10-17 20:25:43 +02:00
Kevin Bullock
d9bf33fad2 phases: pass phase names to hooks instead of internal values 2017-10-18 12:19:53 -05:00
Boris Feld
aab8c43439 configitems: document the choice of using 'match' instead of 'search' 2017-10-18 12:36:23 +02:00
Boris Feld
ad198e9760 configitems: do not directly match generic items
Before this changesets, a literal '.*:foo$' config would match a registered
'.*:foo$' generic. This is wrong since generic should be matched through
regular exception only. This changeset fixes this problem.

Thanks for to Yuya Nishihara for spotting the issue.
2017-10-18 12:26:08 +02:00
Boris Feld
3df0c5d74a obsfate: fix obsfate_printer with empty date list
When the list of dates is empty, `min` and `max` would raises a ValueError.
Protect against this case by checking that the date list is not empty.

I didn't add a test because I couldn't find a reproducing test case.
2017-10-18 15:38:51 +02:00
Boris Feld
4b2916f625 config: gather allowdivergence under the evolution namespace
Grouping all evolution related-config under the experimental.evolution
namespace would helps the future migration outside [experimental].

Differential Revision: https://phab.mercurial-scm.org/D1155
2017-10-17 16:54:31 +02:00
Boris Feld
03a11d7666 config: remove stabilization.* aliases
Stabilization config items were never part of a release, remove them now that
we cleaned up the evolution related configuration.

Differential Revision: https://phab.mercurial-scm.org/D1154
2017-10-17 15:57:56 +02:00
Boris Feld
5f77fdf0f1 config: update evolution-related config
Update the evolution helpers function to support both old-style configuration and
new-style configuration:

    experimental.evolution=all is renamed into experimental.evolution=true

    experimental.evolution=createmarkers is renamed into
    experimental.evolution.createmarkers=true

    experimental.evolution=allowunstable is renamed into
    experimental.evolution.allowunstable=true

    experimental.evolution=exchange is renamed into
    experimental.evolution.exchange=true

We choose to not rename individual config options; keeping the same names
would easy the transition for users but it's something that could be easily
done in the future.

Differential Revision: https://phab.mercurial-scm.org/D1147
2017-10-16 17:14:47 +02:00
Boris Feld
35adc999b8 config: invert evolution-related configuration aliases
We want to split the evolution-related configuration and back-out the renaming
from evolution.* to stabilization.*.

First invert the configuration and aliases, so next changesets will be
cleaner.

Differential Revision: https://phab.mercurial-scm.org/D1146
2017-10-16 17:14:32 +02:00
Augie Fackler
7ca1f09f81 parsers: allow clang-format here
# skip-blame because parsers.c is mechanically rewritten by
clang-format with no semantic change.

Differential Revision: https://phab.mercurial-scm.org/D1170
2017-10-16 14:53:57 -04:00
Augie Fackler
90df42e97c cext: add /* header */ comment to all PyVarObject_HEAD_INIT() calls
This gives clang-format the right notion about formatting these struct
initializers, therefore allowing us to automatically format several
additional files.

# skip-blame because this is just a content-free comment addition

Differential Revision: https://phab.mercurial-scm.org/D1169
2017-10-16 14:49:35 -04:00
Yuya Nishihara
5db2725c37 revset: make follow() accept empty startrev
This is the same behavior as ancestors(emptyset).
2016-09-22 19:41:42 +09:00
Yuya Nishihara
85d4b98f53 revset: alias follow(startrev=rev) to ancestors(rev)
This seems natural given 'log -frREV' (with no file pattern) is equivalent
to 'log -frREV *'.
2016-09-22 19:40:07 +09:00
Yuya Nishihara
08c3b37347 revset: make follow() accept keyword arguments
Also renamed the argument from 'pattern' to 'file' conforming to
followlines().
2016-09-22 19:35:36 +09:00
Yuya Nishihara
3142b0e7d7 revset: make follow() accept multiple startrevs
The diff might look slightly complicated, but the initial "c = repo['.']" was
effective if rev = None.
2016-09-22 19:11:26 +09:00
Yuya Nishihara
d7842061cc dagop: use heap to compute max rev in filectxancestors() 2016-09-22 18:41:51 +09:00
Yuya Nishihara
e49a4312a9 dagop: add smartset interface to filectxancestors()
The original filectx API is kept public since we'll need it to walk ancestor
(rev, match) pairs efficiently. The current implementation scans ancestors
twice for 'hg log -fp FILE'.
2017-10-22 18:57:42 +09:00
Phil Cohen
e206413cfc overlayworkingctx: add _checkexist(path)
This is in preparation to switch this class to inheriting (and being based off
a) `commitctx` instead of a `workingctx`. `filectx` has no `exists` function,
so this is how we'll fall back in that case.

Differential Revision: https://phab.mercurial-scm.org/D1237
2017-12-07 13:20:47 -08:00
Phil Cohen
4cb0fafe39 overlayworkingctx: fix a bad reference to self._path
Differential Revision: https://phab.mercurial-scm.org/D1236
2017-12-07 13:20:47 -08:00
Phil Cohen
4dc892f75b overlayworkingctx: track copy information in the context
We can no longer do so in the dirstate, so add the functions to do so here.

Differential Revision: https://phab.mercurial-scm.org/D1235
2017-12-07 13:20:47 -08:00
Phil Cohen
8024806695 overlayworkingctx: move _wrappedctx out of the constructor
With rebase, we will be setting the _wrappedctx at a different point from the
wctx construction (somewhat later, and possibly several times). Move it to a
public function.

Differential Revision: https://phab.mercurial-scm.org/D1231
2017-12-07 13:20:47 -08:00
Phil Cohen
d99691c52d merge: don't check for unknown files in IMM
Differential Revision: https://phab.mercurial-scm.org/D1214
2017-12-07 13:20:47 -08:00
Jun Wu
e7d2ff6ac8 rebase: enable multidest by default
This was intended to be done by D470. But there was a minor documentation
issue. The feature is quite usable now so it gets formally documented and
enabled.

There is no behavior change for people not using the `SRC` or `ALLSRC` in
rebase destination revset.

.. feature:: Rebase with different destination per source revision

  Previously, rebase only supports one unique destination. Now ``SRC`` and
  ``ALLSRC`` can be used in rebase destination revset to precisely define
  destination per each individual source revision.

  For example, the following command could move some orphaned changesets to
  reasonable new places so they become no longer orphaned::

    hg rebase
      -r 'orphan()-obsolete()'
      -d 'max((successors(max(roots(ALLSRC) & ::SRC)^)-obsolete())::)'

Differential Revision: https://phab.mercurial-scm.org/D1063
2017-10-13 14:08:14 -07:00
Phil Cohen
b85e71bd61 overlayworkingctx: make clean() public
It will be called directly by rebase after concluding a node.

Differential Revision: https://phab.mercurial-scm.org/D1230
2017-12-01 00:07:23 -08:00
Phil Cohen
635c6eaf7f overlayworkingctx: remove flushall()
Differential Revision: https://phab.mercurial-scm.org/D1216
2017-12-01 00:07:23 -08:00
Phil Cohen
da19a4a9f4 merge: skip subrepo state, update hooks, and updating the dirstate in IMM
Differential Revision: https://phab.mercurial-scm.org/D1215
2017-12-01 00:07:23 -08:00
Phil Cohen
d0b4ef96b4 merge: remove calls to flushall()
Since D1105, these are unnecessary since IMM will now never use workers.

Differential Revision: https://phab.mercurial-scm.org/D1213
2017-12-01 00:07:23 -08:00
Phil Cohen
cb5bf40a81 filemerge: raise InMemoryMergeConflictsError if we hit merge conflicts in IMM
Merge conflicts might be supported in the future, but for now are kept out of
scope.

Any places where we used to call `flushall()` should be replaced with some kind
of exception. At this point, IMM M1 is no longer supported.

Differential Revision: https://phab.mercurial-scm.org/D1212
2017-12-01 00:07:23 -08:00
Phil Cohen
5992e0fe48 context: switch ctx() use to changectx()
I added `ctx()` to `overlayworkingfilectx`, (and before that, `absentfilectx`),
because `absentfilectx` had reference to this function in its `cmp()` function.

But the standard is actually `changectx()`, and no other class implements
`ctx()`. So let's use the standard name.

(As a result, I'm not sure that part of the `absentfilectx` comparator ever
worked! It was written before I added either function.)

This will be necessary in the next patch.

Differential Revision: https://phab.mercurial-scm.org/D1211
2017-12-01 00:07:23 -08:00
Matthieu Laneuville
14498f2bf5 patch: add within-line color diff capacity
The `diff' command usually writes deletion in red and insertions in green. This
patch adds within-line colors, to highlight which part of the lines differ.
Lines to compare are decided based on their similarity ratio, as computed by
difflib SequenceMatcher, with an arbitrary threshold (0.7) to decide at which
point two lines are considered entirely different (therefore no inline-diff
required).

The current implementation is kept behind an experimental flag in order to test
the effect on performance. In order to activate it, set inline-color-diff to
true in [experimental].
2017-10-26 00:13:38 +09:00
Yuya Nishihara
4c0e4dc497 dagop: extend filectxancestors() to walk multiple files 2016-09-22 18:23:58 +09:00
Yuya Nishihara
b05b96f608 dagop: put start fctx into visit dict of filectxancestors()
Prepares for multiple start revisions/files.
2016-09-22 18:18:56 +09:00
Yuya Nishihara
09a49f4137 dagop: change visit dict of filectxancestors() indexed solely by rev
In future patches, a max heap will be used to compute the next revision
to visit.
2016-09-22 18:11:37 +09:00
Yuya Nishihara
a17c36ca23 dagop: use fctx.rev() consistently in filectxancestors()
We can't use fctx.linkrev() to sort fctxs coming from multiple files.
This was changed at a5b8b1052ef6 due to performance issue, but we know
we evaluate parent.rev() in revset anyway.
2016-09-22 18:01:55 +09:00
Yuya Nishihara
70940bffa0 dagop: yield intro filectx by filectxancestors()
This is the convention of dagop.*ancestors() functions.
2016-09-22 17:48:46 +09:00
Yuya Nishihara
6245084744 filectx: extract helper method to obtain filectx pointing to its introrev 2017-10-22 17:23:34 +09:00
Yuya Nishihara
f55866843d dagop: copy basefilectx.ancestors() to free function
The primary goal of this series is to make follow() support multiple start
revisions.

dagop.filectxancestors() will be extended to take multiple filectxs.
basefilectx.ancestors() is not forwarded to this function because doing that
would resurrect the performance issue fixed by a5b8b1052ef6.
2016-09-22 17:16:53 +09:00
Boris Feld
8e35ca84ad pull: retrieve bookmarks through the binary part when possible
This makes pull consistent with the part used by push and provide us with a
more compact representation of bookmarks.

In addition, this opens the way for smarter bookmark exchanges (e.g. filtering
by names or only sending the bookmark relevant to the pulled set, etc).
2017-10-17 15:27:22 +02:00
Boris Feld
96e2aa3564 getbundle: add support for 'bookmarks' boolean argument
This new argument requests a 'bookmarks' part from the server. It is meant to
be used instead of the "listkeys" request.
2017-10-17 15:27:17 +02:00
Boris Feld
d449bcaec6 bundle2: support a 'records' mode for the 'bookmarks' part
In this mode, the bookmarks changes are record in the 'bundleoperation' records
instead of inflicted to the repository. This is necessary to use the part when
pulling.
2017-10-17 15:26:16 +02:00
Boris Feld
85a28bae65 bundle2: add a 'modes' dictionary to the bundle operation
This new attribute allows the codes requesting an unbundling to pass important
information to individual part handlers. The current target use case is to
allow for receiving 'bookmarks' part without directly updating local
repository, but just recording the received data instead. This is necessary
for pull where the remote bookmarks are processed locally. I expect the
concept to be beneficial to other parts in the future.

To clarify the bookmark behavior on pull, the remote bookmark value are not just
taken -as-is- into the local repository. There is an extra step to detect
bookmark divergence. The remote bookmarks data are stored until this processing
happens.
2017-10-17 15:39:34 +02:00
Boris Feld
12ed35f197 bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
We use the new binary parts we introduced earlier to exchange bookmark. The
payload is a bit more compact since we use binary and the length of bookmarks
is no longer constrained to 255.

.. fix:: Issue 5165

   Bookmark, whose name is longer than 255, can again be exchanged again
   between 4.4+ client and servers.
2017-10-17 12:38:13 +02:00
Boris Feld
f4af02531c push: move bundle2-pushkey based bookmarks exchange in its own function
We are about to introduce an alternative way to push bookmark over bundle2.
2017-10-15 19:22:56 +02:00
Boris Feld
fa6d2b1849 bookmark: add pushkey hook compatiblity to the bundle2 part
Currently, pushing a bookmark update triggers a pushkey hooks. It is likely
that users in the wild use such hooks to control bookmark movement. Using a non
push-key mechanism to exchange bookmark means these hooks are no longer called,
possibly breaking existing users setup. So we add explicit call to the pushkey
hooks in the handling of the bundle2 part. This behavior can be disabled with a
new config knob: 'server.bookmarks-pushkey-compat'.
2017-10-17 12:07:24 +02:00
Boris Feld
b1c5929fec bookmark: introduce a 'bookmarks' part
This part can carry and apply bookmarks information. We start with adding the
core behavior of the part. In its current form, the part is only suitable for
push since it plain update the bookmark without consideration for the local
state. Support of the behavior needed for pulling will be added in later
changesets.
2017-10-15 18:02:11 +02:00
Boris Feld
e7031fe580 push: include a 'check:bookmarks' part when possible
Before updating the actual bookmark update, we can start with updating the way
we check for push race. Checking bookmarks state earlier is useful even if we
still use pushkey. Aborting before the changegroup is added can save a lot of
time.
2017-11-13 04:22:45 +01:00
Boris Feld
02c4c0f0cf bookmark: add a 'check:bookmarks' bundle2 part
This part checks that bookmarks are still at the node they are expected to be.
This allows a pushing client to detect push race where the repository was
updated between the time it discovered the server state and the time it managed
to finish its push.

Such checking already exists when pushing bookmark through pushkey. This new
part can be inserted at the beginning of the bundle, triggering abort earlier.
In addition, we would like to move away from pushey to push bookmark. A step
useful to solve issue5165.
2017-10-15 15:01:03 +02:00
Boris Feld
5028c90eec bookmark: add methods to binary encode and decode bookmark values
Coming new bundle2 parts related to bookmark will use a binary encoding. It
encodes a series of '(bookmark, node)' pairs. Bookmark name has a high enough
size limit to not be affected by issue5165. (64K length, we are well covered)
2017-10-15 14:59:55 +02:00
Anton Shestakov
631928e009 hgweb: move common vertex code to Graph.prototype
Just to give some context to the return values: vertex() needs to return two
HTML elements as strings, <li> to be used as a background and a <li> to be
shown in foreground. The latter was made obsolete recently when changesets
started to be rendered server-side, but background elements are still useful
for now.
2017-12-06 12:10:16 +08:00
Anton Shestakov
a4d9f6f538 hgweb: create Graph methods using a prototype
This way it's possible to call the original methods even if they were
overridden.
2017-12-06 12:01:07 +08:00
Anton Shestakov
01742a7db5 hgweb: remove unused Graph.cur property
It was introduced in 083571f47ff6, but was already unused. I missed it in
ba4409377a9f.
2017-12-06 11:59:19 +08:00
Yuya Nishihara
fc1b1c7965 repoview: include filter name in repr for debugging 2017-12-05 21:56:48 +09:00
Yuya Nishihara
11b6b464d8 repoview: extract a factory function of proxy class
This makes sure that dynamically-created class objects are isolated from
local binding of repo instances. The type cache is moved to module level
as it isn't tied to each instance.
2017-12-05 21:50:33 +09:00
Yuya Nishihara
570f399d52 repoview: do not include filter name in name of proxy class
The type object is shared across all filters. I'll add __repr__() instead.
2017-12-05 21:37:30 +09:00
Yuya Nishihara
655da40532 thirdparty: move selectors2 module to where it should be 2017-11-30 22:43:03 +09:00
Pulkit Goyal
a0250b29d4 rewriteutil: use precheck() in uncommit and amend commands
Differential Revision: https://phab.mercurial-scm.org/D1526
2017-11-28 05:50:45 +05:30
Pulkit Goyal
4f214eeba8 rewriteutil: add a precheck function to check if revs can be rewritten
The precheck function is intended to be used before we start rewritting
changesets.

Differential Revision: https://phab.mercurial-scm.org/D1503
2017-11-24 03:44:50 +05:30
Pulkit Goyal
579e1d7f54 rewriteutil: add utility function to check if we can create new unstable cset
This patch adds a new file which will contain utility functions related to
rewritting changesets. It also adds a utility function to check if the
rewritting operation creates new unstable changesets and are we allowed to
create them.

This rewriteutil.py introduced in this patch and the utility functions added in
the upcoming patches exists in the evolve extension are being ported from there.

Differential Revision: https://phab.mercurial-scm.org/D1502
2017-11-24 03:40:33 +05:30
Pulkit Goyal
bc6c76e6f1 remotenames: consider existing data while storing newer data
Previously reviewed as D1357.

Differential Revision: https://phab.mercurial-scm.org/D1551
2017-11-09 12:10:03 +05:30
Pulkit Goyal
db8a9589fd remotenames: add functions to read remotenames data from .hg/remotenames/
This patch functions which can be used to read remotenames data from
.hg/remotenames/. The logic for the function which reads the remotenames file is
taken from the remotenames extension.

Previously reviewed as D940.

Differential Revision: https://phab.mercurial-scm.org/D1550
2017-10-05 01:31:53 +05:30
Pulkit Goyal
d680032136 remotenames: add functionality to store remotenames under .hg/hgremotenames/
This patch moves the functionality from remotenames extension to store
remotenames to core.

Storage format used by remotenames extension:

A single file `.hg/remotenames` with an entry in each line where each line is of
format:
`node nametype remotepath/name`
where nametype is either 'bookmarks' or 'branches'.

This was not the best way to store data, so while moving to core the storage
format was changed but yet not the final format. The storage format used by core
after this patch will be:

* A file for each type of name i.e. bookmarks and branches in .hg/remotenames/
  directory
* A version number on the top of the file. The version for current format is 0.
* An entry in each line where each line is of the format
`node\0remotepath\0name`

The logic to sync with existing remotenames file and saving journals and other
related things will be moved to core in next patches incrementally.

Thanks to Ryan, Augie and Durham for suggestions on storage format.

Previously reviewed as D939.

Differential Revision: https://phab.mercurial-scm.org/D1548
2017-10-05 00:44:38 +05:30
Pulkit Goyal
c2ca736b6e remotenames: move function to pull remotenames from the remoterepo to core
This patch is the first patch of the series moving functionality from
hgremotenames extension to core.

There are lot of functionality in the extension which in the end enables us to
store branch heads and bookmarks location on a server from which we are pulling
or cloning from. This will help us in creating a better bookmark workflow where
we can show user that a certain server has this bookmarks at this node. It will
also introduce namespaces related to remote bookmarks and remote branches.

This patch moves the functionality to pull branches and bookmarks from a
server from which we are pulling to core behind config option
`experimental.remotenames`.

This patch adds a test which helps us to analyse whether things are working or
not. We are currently writing things to ui, we will write information to files
in upcoming patches.

Previously reviewed as D937.

Differential Revision: https://phab.mercurial-scm.org/D1547
2017-10-05 00:02:02 +05:30
Yuya Nishihara
9bf6236a83 fancyopts: fix handling of "--" value in earlygetopt() 2017-11-25 17:30:50 +09:00
Yuya Nishihara
502549c773 fancyopts: use getopt.gnu_getopt()
The issue described in the docstring has been fixed since Python 20ab2260dc93,
which is in 2.7.

https://hg.python.org/cpython/rev/20ab2260dc93
https://bugs.python.org/issue4458

This fixes the handling of '--' value.
2017-11-24 01:09:00 +09:00
Yuya Nishihara
86043c7487 dispatch: replace _earlygetopt(strip=True) with new parser
The execution order in cmdalias.__init__() is adjusted to set stripped args
to self.givenargs, which is no longer updated in place.
2017-11-23 23:18:56 +09:00
Yuya Nishihara
c2c866a852 dispatch: replace _earlyreq*() with new fancyopts-based parser 2017-11-23 22:23:59 +09:00
Yuya Nishihara
2e53122de6 dispatch: alias --repo to --repository while parsing early options
This prepares for replacing old _early*opt() functions. My initial attempt
was to extend options table to support 'repository|repo' syntax. It worked,
but seemed too invasive. So I decided to add an optional argument to
fancyopts() instead.

This also changes the nevernegate dict to be keyed by a canonical_name,
not by an option-name for clarity.
2017-11-25 17:03:52 +09:00
Anton Shestakov
7187e609f7 spartan: render changesets server-side on /graph page 2017-12-04 19:08:41 +08:00
Anton Shestakov
7a357f1cf9 monoblue: render changesets server-side on /graph page 2017-12-04 18:26:54 +08:00
Anton Shestakov
55006fdcc2 gitweb: render changesets server-side on /graph page 2017-12-04 17:43:45 +08:00
Anton Shestakov
3c2de0ad20 paper: render changesets server-side on /graph page 2017-12-04 16:21:15 +08:00
Anton Shestakov
364b5723c5 hgweb: only include graph-related data in jsdata variable on /graph pages (BC)
Historically, client-side graph code was not only rendering the graph itself,
but it was also adding all of the changeset information to the page as well.
It meant that JavaScript code needed to construct valid HTML as a string
(although proper escaping was done server-side). It wasn't too clunky, even
though it meant that a lot of server-side things were duplicated client-side
for no good reason, but the worst thing about it was the data format it used.
It was somewhat future-proof, but not human-friendly, because it was just a
tuple: it was possible to append things to it (as was done in e.g.
4d7cfa1867b5), but you'd then have to remember the indices and reading the
resulting JS code wasn't easy, because cur[8] is not descriptive at all.

So what would need to happen for graph to have more features, such as more
changeset information or a different vertex style (branch-closing, obsolete)?
First you'd need to take some property, process it (e.g. escape and pass
through templatefilters function, and mind the encoding too), append it to
jsdata and remember its index, then go add nearly identical JavaScript code to
4 different hgweb themes that use jsdata to render HTML, and finally try and
forget how brittle it all felt. Oh yeah, and the indices go to double digits if
we add 2 more items, say phase and obsolescence, and there are more to come.
Rendering vertex in a different style would need another property (say,
character "o", "_", or "x"), except if you want to be backwards-compatible, it
would need to go after tags and bookmarks, and that just doesn't feel right.

So here I'm trying to fix both the duplication of code and the data format:

- changesets will be rendered by hgweb templates the same way as changelog and
  other such pages, so jsdata won't need any information that's not needed for
  rendering the graph itself

- jsdata will be a dict, or an Object in JS, which is a lot nicer to humans and
  is a lot more future-proof in the long run, because it doesn't use numeric
  indices

What about hgweb themes? Obviously, this will break all hgweb themes that
render graph in JavaScript, including 3rd-party custom ones. But this will also
reduce the size of client-side code and make it more uniform, so that it can be
shared across hgweb themes, further reducing its size. The next few patches
demonstrate that it's not hard to adapt a theme to these changes. And in a
later series, I'm planning to move duplicate JS code from */graph.tmpl to
mercurial.js and leave only 4 lines of code embedded in those <script>
elements, and even that would be just to allow redefining graph.vertex
function. So adapting a custom 3rd-party theme to these changes would mean:

- creating or copying graphnode.tmpl and adding it to the map file (if a theme
  doesn't already use __base__)

- modifying one line in graph.tmpl and simply removing the bigger part of
  JavaScript code from there

Making these changes in this patch and not updating every hgweb theme that uses
jsdata at the same time is a bit of a cheat to make this series more
manageable: /graph pages that use jsdata are broken by this patch, but since
there are no tests that would detect this, bisect works fine; and themes are
updated separately, in the next 4 patches of this series to ease reviewing.
2017-12-01 16:00:40 +08:00
Anton Shestakov
43f716d8d5 hgweb: adopt child nodes in ajaxScrollInit on /graph pages too
ajaxScrollInit is a function that loads more elements (e.g. changelog entries)
when browser window is scrolled down to the bottom of the page. It basically
fetches the next page from the server as HTML, finds container element in that
document and "adopts" (essentially, moves) all its child nodes to the container
in the current document.

Currently, hgweb doesn't render any changesets on /graph page (everything is
done in JavaScript), so there are no children to adopt. But there will be soon,
so let's create a reusable function that does it.

Hardcoding #graphnodes selector is suboptimal, but graph code already does this
in two other places.
2017-12-01 14:17:20 +08:00
Yuya Nishihara
2c811cd701 log: translate column labels at once (issue5750)
This makes sure that all columns are aligned. getlogcolumns() is hosted by
templatekw so the namespaces module can see it.

i18n/de.po is updated so test-log.t passes with no error. "obsolete:" and
"instability:" are kept untranslated.
2017-12-02 16:29:49 +09:00
Yuya Nishihara
9d926f0131 log: remove temporary variable 'date' used only once 2017-12-02 16:08:24 +09:00
Boris Feld
6fefecff91 lock: allow to configure when the lock messages are displayed
We add a new 'ui.timeout.warn' config to set a grace period before we display
lock related warning:

    waiting for lock on PATH held by PROCESS

The config is based on 'ui.timeout' and expresses a number of seconds before
the warning is displayed. Negative values disable the warning altogether.

The messages go to the debug output to help people trouble-shooting deadlocks.
2017-11-29 20:39:59 -05:00
Boris Feld
87115045d0 lock: add a trylock method handling the timeout and messaging logic
We are about to make the messages around lock more flexible. We move all the
currently logic into a function in the lock module. We'll update the message
scheme in the next changeset.
2017-11-29 20:36:29 -05:00
Boris Feld
ce5945f52a lock: use configint for 'ui.timeout' config
The ui object can do the conversion itself.
2017-11-29 21:00:02 -05:00
Boris Feld
d4021aee4f scmutil: improve format pattern used in nodesummaries
As spotted by Yuya Nishihara, that value is an integer.
2017-12-04 09:39:37 +01:00
Pulkit Goyal
174b204536 py3: use encoding.strtolocal() to convert string to bytes
Differential Revision: https://phab.mercurial-scm.org/D1557
2017-11-29 08:40:25 +05:30
Pulkit Goyal
4aa252d4b0 py3: use pycompat.bytestr() or '%d' in place of str()
Differential Revision: https://phab.mercurial-scm.org/D1556
2017-11-29 08:39:48 +05:30
James May
12adeba8fa archive: pass thru mtime for directory archives, like other archive types do
Without this files in the output archive directory have their mtimes set to
whatever time they were written their.  This is in this inconsistent with
the other archivers, eg. zip, which use exactly the same time for all files.

Works on my machine (Windows), but I don't have a *nix box available to run
anything more thorough, unfortunately.
2017-12-01 17:39:21 +11:00
Anton Shestakov
41e5f7f794 hgweb: remove negative top from .info line in graph
"top: -Xpx" shifts a block up by X pixels, which can be used to visually
compress two lines of text to have less space between them, in this case it's
used for the changesets on /graph page. But not only it's not needed there
(both lines fit fine into their allowed vertical space), but it would also look
better (not as crammed, more vertically centered) without these negative
values.

"position: relative" is needed solely for the "top" property to have effect on
the element, no children of the .info element rely on it, so let's remove it as
well.
2017-12-01 20:33:02 +08:00
Pulkit Goyal
6d1ddd1aef py3: use bytes in place of basestring
All strings in mercurial must be bytes so we can easily replace basestring with
bytes.

Differential Revision: https://phab.mercurial-scm.org/D1555
2017-12-01 16:53:55 +05:30
Martin von Zweigbergk
9ca0e39e98 amend: make a copy of "extra" to avoid mutating an input
I don't know of any problems this has caused, it just seems less
surprising.

Differential Revision: https://phab.mercurial-scm.org/D1575
2017-12-01 14:13:55 -08:00
Gregory Szorc
32815ee95d py3: define __next__ in patch.py
This needed to appease Python 3's iterator protocol.

This is crasher #5 in Python 3.

Differential Revision: https://phab.mercurial-scm.org/D1480
2017-11-20 23:13:09 -08:00
Kevin Bullock
c86342f882 merge with stable 2017-12-01 15:21:05 -06:00
Boris Feld
13f89f2060 server: introduce a 'experimental.single-head-per-branch' option
When the option is set, the repository will reject any transaction adding
multiple heads to the same named branch.

For now we reject all scenario with multiple heads. One could imagine handling
closed branches differently. We prefer to keep things simple for now. The
feature might get extended later. Branch closing is not the best experience
Mercurial has to offer anyway.
2017-11-16 03:52:42 +01:00
Boris Feld
b51190da4b scmutil: extra utility to display a reasonable amount of nodes
Push have some logic to display a reasonable amount nodes. We extract it to an
utility function to make it reusable.
2017-11-16 03:52:38 +01:00
Augie Fackler
b162ade5b4 color: respect HGPLAINEXCEPT=color to allow colors while scripting (issue5749)
I'd also like --color=always on the command-line to override HGPLAIN=1
et al, but that's more work, and this seems like a better fix. We've
got a fair number of programs that actually want to automate hg and
get colored output to users, so they should set HGPLAINEXCEPT=alias
(what we usually recommend), but this has been breaking them because
they then lose color.

.. feature::

  The ``HGPLAINEXCEPT`` environment variable can now include ``color``
  to allow automatic output colorization in otherwise automated
  environments.

Differential Revision: https://phab.mercurial-scm.org/D1532
2017-11-28 13:27:43 -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
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
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
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
044c1aa613 py3: use pycompat.maplist() instead of map()
Differential Revision: https://phab.mercurial-scm.org/D1558
2017-11-29 08:40:58 +05:30
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
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
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
pavanpc@fb.com
a3ed13f083 remove: print message for each file in verbose mode only while using -A (BC)
hg rm -A option prints the message of every file in the repo. This is not very
user friendly for a big repository with thousands of files. So enabling this
feature only when run in --verbose mode (hg rm -Av)

Differential Revision: https://phab.mercurial-scm.org/D1336
2017-11-17 22:52:40 +00:00
Augie Fackler
5e0001fc6f localrepo: update comments around path auditors 2017-11-03 17:19:56 -04:00
Augie Fackler
a7ce92a9cc localrepo: specify optional callback parameter to pathauditor as a keyword 2017-11-03 17:07:29 -04:00
Gregory Szorc
a7f7143fb9 bundle2: avoid unbound read when seeking
Currently, seekableunbundlepart.seek() will perform a read() during
seek operations. This will allocate a buffer to hold the raw data
over the seek distance. This can lead to very large allocations
and cause performance to suffer.

We change the code to perform read(32768) in a loop to avoid
potentially large allocations.

`hg perfbundleread` on an uncompressed Firefox bundle reveals
a performance impact:

! bundle2 iterparts()
! wall 2.992605 comb 2.990000 user 2.260000 sys 0.730000 (best of 4)
! bundle2 iterparts() seekable
! wall 3.863810 comb 3.860000 user 3.000000 sys 0.860000 (best of 3)
! bundle2 part seek()
! wall 6.213387 comb 6.200000 user 3.350000 sys 2.850000 (best of 3)
! wall 3.820347 comb 3.810000 user 2.980000 sys 0.830000 (best of 3)

Since seekable bundle parts are (only) used by bundlerepo, this /may/
speed up initial loading of bundle-based repos. But any improvement
will likely only be noticed on very large bundles.

Differential Revision: https://phab.mercurial-scm.org/D1394
2017-11-13 22:20:12 -08:00
Gregory Szorc
d1e95ae39b bundle2: inline struct operations
Before, we were calling struct.unpack() (via an alias) on every
loop iteration. I'm not sure what Python does under the hood, but
it would have to look at the struct format and determine what to
do.

This commit establishes a struct.Struct instance and reuses it for
struct reading.

We can see the impact from running `hg perfbundleread` on a Firefox
bundle:

! read(8k)
! wall 0.679730 comb 0.680000 user 0.140000 sys 0.540000 (best of 15)
! read(16k)
! wall 0.577228 comb 0.570000 user 0.080000 sys 0.490000 (best of 17)
! read(32k)
! wall 0.516060 comb 0.520000 user 0.040000 sys 0.480000 (best of 20)
! read(128k)
! wall 0.496378 comb 0.490000 user 0.010000 sys 0.480000 (best of 20)
! bundle2 iterparts()
! wall 3.056811 comb 3.050000 user 2.340000 sys 0.710000 (best of 4)
! wall 2.992605 comb 2.990000 user 2.260000 sys 0.730000 (best of 4)
! bundle2 iterparts() seekable
! wall 4.007676 comb 4.000000 user 3.170000 sys 0.830000 (best of 3)
! wall 3.863810 comb 3.860000 user 3.000000 sys 0.860000 (best of 3)
! bundle2 part seek()
! wall 6.267110 comb 6.250000 user 3.480000 sys 2.770000 (best of 3)
! wall 6.213387 comb 6.200000 user 3.350000 sys 2.850000 (best of 3)
! bundle2 part read(8k)
! wall 3.404164 comb 3.400000 user 2.650000 sys 0.750000 (best of 3)
! wall 3.241099 comb 3.250000 user 2.560000 sys 0.690000 (best of 3)
! bundle2 part read(16k)
! wall 3.197972 comb 3.200000 user 2.490000 sys 0.710000 (best of 4)
! wall 3.003930 comb 3.000000 user 2.270000 sys 0.730000 (best of 4)
! bundle2 part read(32k)
! wall 3.060557 comb 3.060000 user 2.340000 sys 0.720000 (best of 4)
! wall 2.904695 comb 2.900000 user 2.160000 sys 0.740000 (best of 4)
! bundle2 part read(128k)
! wall 2.952209 comb 2.950000 user 2.230000 sys 0.720000 (best of 4)
! wall 2.776140 comb 2.780000 user 2.070000 sys 0.710000 (best of 4)

Profiling now says most remaining time is spent in util.chunkbuffer.
I already heavily optimized that data structure several releases ago.
So we'll likely get little more performance out of bundle2 reading
while still retaining util.chunkbuffer().

Differential Revision: https://phab.mercurial-scm.org/D1393
2017-11-13 21:54:46 -08:00
Gregory Szorc
e2444ba526 bundle2: inline changegroup.readexactly()
Profiling reveals this loop is pretty tight. Literally any
function call elimination can make a big difference.

This commit inlines the relatively trivial changegroup.readexactly()
method inside the loop.

The results with `hg perfbundleread` on a bundle of the Firefox repo
speak for themselves:

! read(8k)
! wall 0.679730 comb 0.680000 user 0.140000 sys 0.540000 (best of 15)
! read(16k)
! wall 0.577228 comb 0.570000 user 0.080000 sys 0.490000 (best of 17)
! read(32k)
! wall 0.516060 comb 0.520000 user 0.040000 sys 0.480000 (best of 20)
! read(128k)
! wall 0.496378 comb 0.490000 user 0.010000 sys 0.480000 (best of 20)
! bundle2 iterparts()
! wall 3.460903 comb 3.460000 user 2.760000 sys 0.700000 (best of 3)
! wall 3.056811 comb 3.050000 user 2.340000 sys 0.710000 (best of 4)
! bundle2 iterparts() seekable
! wall 4.312722 comb 4.310000 user 3.480000 sys 0.830000 (best of 3)
! wall 4.007676 comb 4.000000 user 3.170000 sys 0.830000 (best of 3)
! bundle2 part seek()
! wall 6.754764 comb 6.740000 user 3.970000 sys 2.770000 (best of 3)
! wall 6.267110 comb 6.250000 user 3.480000 sys 2.770000 (best of 3)
! bundle2 part read(8k)
! wall 3.668004 comb 3.660000 user 2.960000 sys 0.700000 (best of 3)
! wall 3.404164 comb 3.400000 user 2.650000 sys 0.750000 (best of 3)
! bundle2 part read(16k)
! wall 3.489196 comb 3.480000 user 2.750000 sys 0.730000 (best of 3)
! wall 3.197972 comb 3.200000 user 2.490000 sys 0.710000 (best of 4)
! bundle2 part read(32k)
! wall 3.388569 comb 3.380000 user 2.640000 sys 0.740000 (best of 3)
! wall 3.060557 comb 3.060000 user 2.340000 sys 0.720000 (best of 4)
! bundle2 part read(128k)
! wall 3.276415 comb 3.270000 user 2.560000 sys 0.710000 (best of 4)
! wall 2.952209 comb 2.950000 user 2.230000 sys 0.720000 (best of 4)

Differential Revision: https://phab.mercurial-scm.org/D1392
2017-11-13 21:48:35 -08:00
Gregory Szorc
a494c5cbce bundle2: inline debug logging
Profiling revealed that repeated calls to indebug() were
consuming a fair amount of CPU during bundle2 reading, with
most of the time spent in ui.configbool().

Inlining indebug() and avoiding extra attribute lookups speeds
things up substantially. Using `hg perfbundleread` with a Firefox
bundle:

! read(8k)
! wall 0.679730 comb 0.680000 user 0.140000 sys 0.540000 (best of 15)
! read(16k)
! wall 0.577228 comb 0.570000 user 0.080000 sys 0.490000 (best of 17)
! read(32k)
! wall 0.516060 comb 0.520000 user 0.040000 sys 0.480000 (best of 20)
! read(128k)
! wall 0.496378 comb 0.490000 user 0.010000 sys 0.480000 (best of 20)
! bundle2 iterparts()
! wall 6.983756 comb 6.980000 user 6.220000 sys 0.760000 (best of 3)
! wall 3.460903 comb 3.460000 user 2.760000 sys 0.700000 (best of 3)
! bundle2 iterparts() seekable
! wall 8.132131 comb 8.110000 user 7.160000 sys 0.950000 (best of 3)
! wall 4.312722 comb 4.310000 user 3.480000 sys 0.830000 (best of 3)
! bundle2 part seek()
! wall 10.860942 comb 10.840000 user 7.790000 sys 3.050000 (best of 3)
! wall 6.754764 comb 6.740000 user 3.970000 sys 2.770000 (best of 3)
! bundle2 part read(8k)
! wall 7.258035 comb 7.260000 user 6.470000 sys 0.790000 (best of 3)
! wall 3.668004 comb 3.660000 user 2.960000 sys 0.700000 (best of 3)
! bundle2 part read(16k)
! wall 7.099891 comb 7.080000 user 6.310000 sys 0.770000 (best of 3)
! wall 3.489196 comb 3.480000 user 2.750000 sys 0.730000 (best of 3)
! bundle2 part read(32k)
! wall 6.964685 comb 6.950000 user 6.130000 sys 0.820000 (best of 3)
! wall 3.388569 comb 3.380000 user 2.640000 sys 0.740000 (best of 3)
! bundle2 part read(128k)
! wall 6.852867 comb 6.850000 user 6.060000 sys 0.790000 (best of 3)
! wall 3.276415 comb 3.270000 user 2.560000 sys 0.710000 (best of 4)

Differential Revision: https://phab.mercurial-scm.org/D1391
2017-11-13 22:05:54 -08:00
Gregory Szorc
2f77487f6f bundle2: don't use seekable bundle2 parts by default (issue5691)
The last commit removed the last use of the bundle2 part seek() API
in the generic bundle2 part iteration code. This means we can now
switch to using unseekable bundle2 parts by default and have the
special consumers that actually need the behavior request it.

This commit changes unbundle20.iterparts() to expose non-seekable
unbundlepart instances by default. If seekable parts are needed,
callers can pass "seekable=True." The bundlerepo class needs
seekable parts, so it does this.

The interrupt handler is also changed to use a regular unbundlepart.
So, by default, all consumers except bundlerepo will see unseekable
parts.

Because the behavior of the iterparts() benchmark changed, we add
a variation to test seekable parts vs unseekable parts. And because
parts no longer have seek() unless "seekable=True," we update the
"part seek" benchmark.

Speaking of benchmarks, this change has the following impact to
`hg perfbundleread` on an uncompressed bundle of the Firefox repo
(6,070,036,163 bytes):

! read(8k)
! wall 0.722709 comb 0.720000 user 0.150000 sys 0.570000 (best of 14)
! read(16k)
! wall 0.602208 comb 0.590000 user 0.080000 sys 0.510000 (best of 17)
! read(32k)
! wall 0.554018 comb 0.560000 user 0.050000 sys 0.510000 (best of 18)
! read(128k)
! wall 0.520086 comb 0.530000 user 0.020000 sys 0.510000 (best of 20)
! bundle2 forwardchunks()
! wall 2.996329 comb 3.000000 user 2.300000 sys 0.700000 (best of 4)
! bundle2 iterparts()
! wall 8.070791 comb 8.060000 user 7.180000 sys 0.880000 (best of 3)
! wall 6.983756 comb 6.980000 user 6.220000 sys 0.760000 (best of 3)
! bundle2 iterparts() seekable
! wall 8.132131 comb 8.110000 user 7.160000 sys 0.950000 (best of 3)
! bundle2 part seek()
! wall 10.370142 comb 10.350000 user 7.430000 sys 2.920000 (best of 3)
! wall 10.860942 comb 10.840000 user 7.790000 sys 3.050000 (best of 3)
! bundle2 part read(8k)
! wall 8.599892 comb 8.580000 user 7.720000 sys 0.860000 (best of 3)
! wall 7.258035 comb 7.260000 user 6.470000 sys 0.790000 (best of 3)
! bundle2 part read(16k)
! wall 8.265361 comb 8.250000 user 7.360000 sys 0.890000 (best of 3)
! wall 7.099891 comb 7.080000 user 6.310000 sys 0.770000 (best of 3)
! bundle2 part read(32k)
! wall 8.290308 comb 8.280000 user 7.330000 sys 0.950000 (best of 3)
! wall 6.964685 comb 6.950000 user 6.130000 sys 0.820000 (best of 3)
! bundle2 part read(128k)
! wall 8.204900 comb 8.150000 user 7.210000 sys 0.940000 (best of 3)
! wall 6.852867 comb 6.850000 user 6.060000 sys 0.790000 (best of 3)

The significant speedup is due to not incurring the overhead to track
payload offset data. Of course, this overhead is proportional to
bundle2 part size. So a multiple gigabyte changegroup part is on the
extreme side of the spectrum for real-world impact.

In addition to the CPU efficiency wins, not tracking offset data
also means not using memory to hold that data. Using a bundle based on
the example BSD repository in issue 5691, this change has a drastic
impact to memory usage during `hg unbundle` (`hg clone` would behave
similarly). Before, memory usage incrementally increased for the
duration of bundle processing. In other words, as we advanced through
the changegroup and bundle2 part, we kept allocating more memory to
hold offset data. After this change, we still increase memory during
changegroup application. But the rate of increase is significantly
slower. (A bulk of the remaining gradual increase appears to be the
storing of revlog sizes in the transaction object to facilitate
rollback.)

The RSS at the end of filelog application is as follows:

Before: ~752 MB
After:  ~567 MB

So, we were storing ~185 MB of offset data that we never even used.
Talk about wasteful!

.. api::

   bundle2 parts are no longer seekable by default.

.. perf::

   bundle2 read I/O throughput significantly increased.

.. perf::

   Significant memory use reductions when reading from bundle2 bundles.

   On the BSD repository, peak RSS during changegroup application
   decreased by ~185 MB from ~752 MB to ~567 MB.

Differential Revision: https://phab.mercurial-scm.org/D1390
2017-11-13 21:10:37 -08:00
Gregory Szorc
d035774cab bundle2: only seek to beginning of part in bundlerepo
For reasons still not yet fully understood by me, bundlerepo
requires its changegroup bundle2 part to be seeked to beginning
after part iteration. As far as I can tell, it is the only
bundle2 part consumer that relies on this behavior.

This seeking was performed in the generic iterparts() API. Again,
I don't fully understand why it was here and not in bundlerepo.
Probably historical reasons.

What I do know is that all other bundle2 part consumers don't
need this special behavior (assuming the tests are comprehensive).
So, we move the code from bundle2's iterparts() to bundlerepo's
consumption of iterparts().

Differential Revision: https://phab.mercurial-scm.org/D1389
2017-11-13 20:12:00 -08:00
Gregory Szorc
14c677b632 bundle2: implement consume() API on unbundlepart
We want bundle parts to not be seekable by default. That means
eliminating the generic seek() method.

A common pattern in bundle2.py is to seek to the end of the part
data. This is mainly used by the part iteration code to ensure
the underlying stream is advanced to the next bundle part.

In this commit, we establish a dedicated API for consuming a
bundle2 part data. We switch users of seek() to it.

The old implementation of seek(0, os.SEEK_END) would effectively
call self.read(). The new implementation calls self.read(32768)
in a loop. The old implementation would therefore assemble a
buffer to hold all remaining data being seeked over. For seeking
over large bundle parts, this would involve a large allocation and
a lot of overhead to collect intermediate data! This overhead can
be seen in the results for `hg perfbundleread`:

! bundle2 iterparts()
! wall 10.891305 comb 10.820000 user 7.990000 sys 2.830000 (best of 3)
! wall 8.070791 comb 8.060000 user 7.180000 sys 0.880000 (best of 3)
! bundle2 part seek()
! wall 12.991478 comb 10.390000 user 7.720000 sys 2.670000 (best of 3)
! wall 10.370142 comb 10.350000 user 7.430000 sys 2.920000 (best of 3)

Of course, skipping over large payload data isn't likely very common.
So I doubt the performance wins will be observed in the wild.

Differential Revision: https://phab.mercurial-scm.org/D1388
2017-11-13 20:03:02 -08:00
Gregory Szorc
589a08705a bundle2: implement generic part payload decoder
The previous commit extracted _payloadchunks() to a new derived class.
There was still a reference to this method in unbundlepart, making
unbundlepart unusable on its own.

This commit implements a generic version of a bundle2 part payload
decoder, without offset tracking. seekableunbundlepart._payloadchunks()
has been refactored to consume it, adding offset tracking like before.
We also implement unbundlepart._payloadchunks(), which is a thin
wrapper for it. Since we never instantiate unbundlepart directly,
this new method is not used. This will be changed in subsequent
commits.

The new implementation also inlines some simple code from unpackermixin
and adds some local variable to prevent extra function calls and
attribute lookups. `hg perfbundleread` on an uncompressed Firefox
bundle seems to show a minor win:

! bundle2 iterparts()
! wall 12.593258 comb 12.250000 user 8.870000 sys 3.380000 (best of 3)
! wall 10.891305 comb 10.820000 user 7.990000 sys 2.830000 (best of 3)
! bundle2 part seek()
! wall 13.173163 comb 11.100000 user 8.390000 sys 2.710000 (best of 3)
! wall 12.991478 comb 10.390000 user 7.720000 sys 2.670000 (best of 3)
! bundle2 part read(8k)
! wall 9.483612 comb 9.480000 user 8.420000 sys 1.060000 (best of 3)
! wall 8.599892 comb 8.580000 user 7.720000 sys 0.860000 (best of 3)
! bundle2 part read(16k)
! wall 9.159815 comb 9.150000 user 8.220000 sys 0.930000 (best of 3)
! wall 8.265361 comb 8.250000 user 7.360000 sys 0.890000 (best of 3)
! bundle2 part read(32k)
! wall 9.141308 comb 9.130000 user 8.220000 sys 0.910000 (best of 3)
! wall 8.290308 comb 8.280000 user 7.330000 sys 0.950000 (best of 3)
! bundle2 part read(128k)
! wall 8.880587 comb 8.850000 user 7.960000 sys 0.890000 (best of 3)
! wall 8.204900 comb 8.150000 user 7.210000 sys 0.940000 (best of 3)

Function call overhead in Python strikes again!

Of course, bundle2 decoding CPU overhead is likely small compared to
decompression and changegroup application. But every little bit helps.

Differential Revision: https://phab.mercurial-scm.org/D1387
2017-11-12 19:46:15 -08:00
Gregory Szorc
d2101718bc bundle2: extract logic for seeking bundle2 part into own class
Currently, unbundlepart classes support bi-directional seeking.
Most consumers of unbundlepart only ever seek forward - typically
as part of moving to the end of the bundle part so they can move
on to the next one. But regardless of the actual usage of the
part, instances maintain an index mapping offsets within the
underlying raw payload to offsets within the decoded payload.

Maintaining the mapping of offset data can be expensive in terms of
memory use. Furthermore, many bundle2 consumers don't have access
to an underlying seekable stream. This includes all compressed
bundles. So maintaining offset data when the underlying stream
can't be seeked anyway is wasteful. And since many bundle2 streams
can't be seeked, it seems like a bad idea to expose a seek API
in bundle2 parts by default. If you provide them, people will
attempt to use them.

Seekable bundle2 parts should be the exception, not the rule. This
commit starts the process dividing unbundlepart into 2 classes: a
base class that supports linear, one-time reads and a child class
that supports bi-directional seeking. In this first commit, we
split various methods and attributes out into a new
"seekableunbundlepart" class. Previous instantiators of "unbundlepart"
now instantiate "seekableunbundlepart." This preserves backwards
compatibility. The coupling between the classes is still tight:
"unbundlepart" cannot be used on its own. This will be addressed
in subsequent commits.

Differential Revision: https://phab.mercurial-scm.org/D1386
2017-11-13 19:22:11 -08:00
Zuzanna Mroczek
344962042e sshpeer: add a configurable hint for the ssh error message
Adding a possibility to configure error hint to be shown in the case of problems with SSH. Example of such hint can be "Please see http://company/internalwiki/ssh.html".

Test Plan:
- Ran hg pull with broken link and verified the output has no hint by default:

```
pulling from ssh://brokenrepository.com//repo
remote: ssh: Could not resolve hostname brokenrepository.com: Name or service not known
abort: no suitable response from remote hg!
```

- Run hg pull --config ui.ssherrorhint="Please see http://company/internalwiki/ssh.html":

```
pulling from ssh://brokenrepository.com//repo
remote: ssh: Could not resolve hostname brokenrepository.com: Name or service not known
abort: no suitable response from remote hg!
(Please see http://company/internalwiki/ssh.html)
```

Differential Revision: https://phab.mercurial-scm.org/D1431
2017-11-20 01:40:26 -08:00
rlevasseur@google.com
f0bc85352f docs: add args/returns docs for some cmdutil, context, and registrar functions
When writing my first extension, I found it hard to figure out these functions.
I figured documenting their inputs/outputs would help future authors who
are new to the codebase.

Differential Revision: https://phab.mercurial-scm.org/D1440
2017-11-16 15:01:21 -08:00
Pulkit Goyal
0b53da01f1 commands: add value for cmdtype argument for read only commands
In the previous release we added an argument `cmdtype` to registrar.command()
which is a enum and tells whether the command is read only, recoverable write or
unrecoverable write command. This patch add the value of cmdtype argument for
commands which are read only.

Differential Revision: https://phab.mercurial-scm.org/D1468
2017-11-21 04:37:51 +05:30
Phil Cohen
1d563527a4 error: add InMemoryMergeConflictsError
We'll raise this exception in the merge code, and in-memory users like rebase
can catch it and retry without IMM.

Differential Revision: https://phab.mercurial-scm.org/D1210
2017-11-15 21:07:30 -08:00
Anton Shestakov
8859c1494a hgweb: use webutil.commonentry() for nodes (but not for jsdata yet) in /graph
This makes graphdata() simpler by using existing code that gets common
changeset properties for showing in hgweb. graphdata() is a nested function in
graph() that prepares entries for /graph view, but there are two different
lists of changesets prepared: "jsdata" for JavaScript-rendered graph and
"nodes" for everything else.

For "jsdata", properties "node", "user", "age" and "desc" are passed through
various template filters because we don't have these filters in JavaScript, so
the data has to be prepared server-side. But now that commonentry() is used for
producing "nodes" list (and it doesn't apply any filters), these filters need
to be added to the appropriate templates (only raw at this moment, everything
else either doesn't implement graph or uses JavaScript).

This is a bit of refactoring that will hopefully simplify future patches. The
end result is to have /graph that only renders the actual graph with nodes and
vertices in JavaScript, and the rest is done server-side. This way server-side
code can focus on showing a list of changesets, which is easy because we
already have /log, /shortlog, etc, and JavaScript code can be simplified,
making it easier to add obsolescence graph and other features.
2017-11-20 21:59:00 +08:00
Anton Shestakov
feae76d15e hgweb: check changeset's original branch in graphdata()
This piece of code checks if a changeset is the tip of its branch, but as can
be seen above in the context, "branch" was prepared for being displayed in
hgweb by making it unicode and passing it through url.escape. It's better to
use the original ctx.branch().
2017-11-20 21:47:11 +08:00
Anton Shestakov
df1a7f71ac hgweb: show instabilities of a commit
In paper, coal, gitweb and monoblue a new "tag" (or multiple, if there are many
instabilities) is added to the same line that has phase, branch, etc of a
changeset; in gitweb and monoblue this element has a light red background, in
paper and coal the element is black and underlined. In spartan theme
instabilities are shown on a separate line.

While test-obsolete.t uses first(phasedivergent()) revset to pick a changeset
to test, that particular changeset is also an orphan, so two different
instability tags are displayed.
2017-11-19 14:02:50 +08:00
Anton Shestakov
ac68d5ffe4 context: add instabilities() method to basefilectx
This method is now used in webutils.commonentry(), which adds common data items
(commit hash, author, date, etc) for rendering changesets in hgweb. Usually,
commonentry() is given a changectx as ctx; but in views related to files (e.g.
file view, diff, annotate) it's replaced by a filectx, so the latter also needs
to have instabilities() method.
2017-11-19 13:18:54 +08:00
Jordi Gutiérrez Hermoso
565b64a53b templates: reword 'back to filelog' link anchor text
This anchor text is problematic in two ways: first, the "back to" part
assumes that you got to the page showing it via the filelog. This is
not necessarily true, as there are other ways to get to that view
besides the filelog view, such as for example following the history of
lines from a file. Second, it uses "filelog" jargon, which refers to
how each file has its own revlog. This is internal jargon that has no
business being exposed to the end user.

I just reworded this template to improve understanding.
2017-11-20 14:30:54 -05:00
Anton Shestakov
980f6b961e hgweb: show obsolescence status of a commit
As with phases, spartan theme shows a simple "obsolete: yes" on its own line
(this allows replacing "yes" with something more useful in future, like output
of obsfate* template functions). Everywhere else a new "tag" is added to the
same line that has phase, branch, etc of a changeset; in gitweb and monoblue
the element has gray background, in paper and coal the element is gray with a
dashed underline.
2017-11-18 12:04:08 +08:00
Anton Shestakov
bc9b6ce350 context: add obsolete() method to basefilectx
This method is now used in webutils.commonentry(), which adds common data items
(commit hash, author, date, etc) for rendering changesets in hgweb. Usually,
commonentry() is given a changectx as ctx; but in views related to files (e.g.
file view, diff, annotate) it's replaced by a filectx, so the latter also needs
to have obsolete() method.
2017-11-18 11:58:57 +08:00
Mark Thomas
f546f0cc70 dirstate: make map implementation overridable
Other implementations of dirstate will want to replace the class used for the
dirstate map.  Allow this to happen by making the class an attribute of the
dirstate.

Differential Revision: https://phab.mercurial-scm.org/D1347
2017-11-15 01:07:42 -08:00
Mark Thomas
c35820b286 dirstate: add explicit methods for querying directories (API)
The set-like object returned by dirstate.dirs may be difficult for other
implementations of the dirstate to provide, and is unnecessary as it is
only ever used for __contains__.  Instead, provide an explicit method for
testing for a directory.

.. api::

   dirstate no longer provides a `dirs()` method.  To test for the existence of
   a directory in the dirstate, use `dirstate.hasdir(dirname)`.

Differential Revision: https://phab.mercurial-scm.org/D1345
2017-11-15 01:07:42 -08:00
Mark Thomas
42e81ca5f7 dirstate: remove _droppath method
This method now doesn't do very much interesting and can be removed.  The
updated files set can be updated where _droppath was originally called.

Differential Revision: https://phab.mercurial-scm.org/D1344
2017-11-15 01:07:42 -08:00
Mark Thomas
6e73355f6b dirstate: move dropping of folded filenames into the dirstate map
When dropping files from the dirstate, the corresponding entry in the
filefoldmap is also dropped.  Move this into the dirstate map object.  A future
implementation of the dirstate will maintain the filefoldmap differently.

Differential Revision: https://phab.mercurial-scm.org/D1343
2017-11-15 01:07:42 -08:00
Mark Thomas
6a69e130f5 dirstate: move management of the dirstate dirs into the dirstatemap
The dirstate dirs object is owned by the map, so move management of that object
there.  A future implementation of the dirstate will manage the dirs object
differently.

Differential Revision: https://phab.mercurial-scm.org/D1342
2017-11-15 01:07:42 -08:00
Mark Thomas
c5205a95ce dirstate: move management of nonnormal sets into dirstate map
The dirstate map owns the nonnormal sets, and so should be the class to update
them.  A future implementation of the dirstate will manage these maps
differently.

The action of clearing ambiguous times is now entirely controlled by the
dirstate map, so it moves there too.

Differential Revision: https://phab.mercurial-scm.org/D1341
2017-11-15 01:07:42 -08:00
Mark Thomas
f069b05e38 dirstate: add explicit methods for modifying dirstate
Instead of assigning dirstatetuple objects to entries in the dirstate, move
responsibility for creating tuples into the dirstatemap.

Differential Revision: https://phab.mercurial-scm.org/D1340
2017-11-15 01:07:42 -08:00
Mark Thomas
82685455a3 dirstate: document dirstatemap interface
Differential Revision: https://phab.mercurial-scm.org/D1380
2017-11-15 01:07:42 -08:00
Gregory Szorc
f5517d96d5 bundlerepo: rename "bundlefilespos" variable and attribute
Strictly speaking, this variable tracks offsets within the
changegroup, not the bundle.

While we're here, mark a class attribute as private because
it is.

.. api::

   Rename bundlerepo.bundlerepository.bundlefilespos to
   _cgfilespos.

Differential Revision: https://phab.mercurial-scm.org/D1384
2017-11-13 19:12:56 -08:00
Gregory Szorc
27bc3c9021 bundlerepo: rename "bundle" arguments to "cgunpacker"
"bundle" was appropriate for the bundle1 days where a bundle
was a changegroup. In a bundle2 world, changegroup readers
are referred to as "changegroup unpackers."

Differential Revision: https://phab.mercurial-scm.org/D1383
2017-11-13 19:12:17 -08:00
Gregory Szorc
8a88beb1d7 bundlerepo: use early return
I like avoiding patterns that lead to the pyramid of doom.

Differential Revision: https://phab.mercurial-scm.org/D1382
2017-11-11 18:55:04 -08:00
Jun Wu
41d35f0ba7 crecord: fix revert -ir '.^' crash caused by 3649c3f2cd
3649c3f2cd (revert: do not reverse hunks in interactive when REV is not
parent (issue5096)) changed the record "operation" for the text version but
missed the curses version. Without this patch, running
`hg revert -ir '.^' --config ui.interface=curses` would crash with:

  ProgrammingError: unexpected operation: apply

Differential Revision: https://phab.mercurial-scm.org/D1381
2017-11-13 18:22:25 -08:00
Martin von Zweigbergk
979192be0c tweakdefaults: turn on ui.statuscopies
Seems obviously useful and probably off by default for historical
reasons.

Differential Revision: https://phab.mercurial-scm.org/D1444
2017-11-16 17:11:14 -08:00
Anton Shestakov
f8a893bdbf hgweb: show commit phase if it's not public
In spartan theme phase is shown on its own table row, because there's no single
line of "tags". Everywhere else phase is prepended to the list of "tags" of a
changeset. Its element has a purple-ish color in gitweb and monoblue, and a
dotted line under it and no color in paper and coal (as these themes are frugal
with colors).

This patch intentionally doesn't touch graph, because it needs a rewrite. I'll
get to it pretty soon and in the process will add phase and everything that's
still coming (e.g. obsolescence and instabilities).

.. feature::

   hgweb now displays phases of non-public changesets
2017-11-16 22:21:03 +08:00
Anton Shestakov
281eec2f1e hgweb: move changeset "tags" to a template in map file (paper and coal)
This patch puts all these changeset "tags" into one template shared everywhere
in paper and coal themes. But it should be noted that some of the templates had
different sets of tags, in some cases it was intended, in others - most likely
not.

First, what's up with all these different ways to get changeset's branch. There
are actually 3 ways to do it in hgweb, they can all be seen in this patch;
"branches", "inbranch" and "branch". They are all lists that consist of 1 or 0
items:

- "branches" has ctx.branch() if current changeset is the tip of that branch
- "inbranch" has ctx.branch() if current changeset is _not_ the tip of that
  branch and the branch is not "default"
- "branch" aka "changesetbranch" has ctx.branch() if the branch is not
  "default"

The majority of cases (7 vs 2 + /graph) in paper theme used only option 3,
which meant that "default" was never displayed. But other parts of the theme
disagreed with this and used option 1 and option 2 together. For example, the
default view (log) displays "default" on the branch tip (can be seen right
about now on m-s.o/repo/hg), but it disappears when you click on the commit.

Also, using option 3 alone meant that there was no way to tell if a changeset
is the tip of its branch or not (it was always assumed that it's not, see how
some css classes change from "branchname" to the correct "branchhead" in tests)
-- so the two different css styles that exist in paper just for this were
underused.

I think this patch improves the situation, even though it changes the old (even
if inconsistent) behavior. The new behavior matches that of gitweb and
monoblue.
2017-11-15 23:55:09 +08:00
Martin von Zweigbergk
13e75f668f patch: accept prefix argument to changedfiles() helper
I'd like to call the function from an extension, passing both "strip"
and "prefix", but it currently only accepts "strip". The only in-tree
caller seems to be mq.py, which doesn't even pass "strip".

Differential Revision: https://phab.mercurial-scm.org/D1413
2017-11-14 10:26:36 -08:00
Anton Shestakov
e6c6d397c1 hgweb: move changeset "tags" to a template in map file (gitweb and monoblue)
Less duplication and it's also easier to add extra "tags" everywhere at once.

These aren't tags as defined `hg help glossary` (hence the quotes), they are
simply called that. They include branch name (in different styles if changeset
is a head of that branch or not), (actual) tags and bookmarks. Good candidates
to add to this list would be changeset phase and obsoletion status.
2017-11-15 19:36:16 +08:00
Anton Shestakov
0bd28b8467 hgweb: split long lines in gitweb and monoblue (changeset summary and tags) 2017-11-15 16:06:00 +08:00
Paul Morelle
0ec1e298bd debugdeltachain: output information about sparse read if enabled 2017-10-26 09:27:09 +02:00
Gregory Szorc
a4f1d34829 bundlerepo: rename _bundle to _cgunpacker
_bundle is really a changegroup unpacker instance. Rename the
variable accordingly.

Differential Revision: https://phab.mercurial-scm.org/D1379
2017-11-11 18:41:14 -08:00
Gregory Szorc
f8da298c93 bundlerepo: assign bundle attributes in bundle type blocks
It is a bit wonky to assign the same object to multiple
attributes and then possibly overwrite them later.

Refactor the code to use a local variable and defer attribute
assignment until the final values are ready.

This required passing the bundle instance to _handlebundle2part().
The only use of this method I could find is Facebook's
treemanifest extension. Since it is a private method, I don't
think it warrants an API callout.

Differential Revision: https://phab.mercurial-scm.org/D1378
2017-11-11 18:34:50 -08:00
Gregory Szorc
d446e5fd4c bundlerepo: make bundle and bundlefile attributes private
These attributes are implementation details and shouldn't be
exposed outside the class.

.. api::

   bundlerepo.bundlerepository.bundle and
   bundlerepo.bundlerepository.bundlefile are now prefixed with an
   underscore.

Differential Revision: https://phab.mercurial-scm.org/D1377
2017-11-11 18:22:36 -08:00
Gregory Szorc
4303257e0a bundlerepo: don't assume there are only two bundle classes
exchange.readbundle() can return a type that represents a stream
clone bundle. Explicitly handle the bundle1 type and raise a
reasonable error message for unhandled bundle types.

Differential Revision: https://phab.mercurial-scm.org/D1376
2017-11-11 18:14:41 -08:00
Gregory Szorc
96510ffc31 bundlerepo: add docstring for bundlerepository class
Differential Revision: https://phab.mercurial-scm.org/D1375
2017-11-11 18:09:16 -08:00
Gregory Szorc
dfe2ba26ec bundlerepo: rename arguments to bundlerepository.__init__
To reflect what they actually are.

Differential Revision: https://phab.mercurial-scm.org/D1374
2017-11-11 18:05:02 -08:00
Gregory Szorc
ba1e1e4a72 bundlerepo: use suffix variable
It looks like the refactor in 0883a2ece555 attempted to establish
this method argument but failed to use it. My editor caught it.

Differential Revision: https://phab.mercurial-scm.org/D1373
2017-11-11 17:07:33 -08:00
Gregory Szorc
f9ea80f7a0 bundlerepo: make methods agree with base class
My editor was complaining about mismatches between method
signatures.

For methods that are implemented, we change arguments to match
the base. For those that aren't, we use variable arguments
because it shouldn't matter.

Differential Revision: https://phab.mercurial-scm.org/D1372
2017-11-11 17:02:31 -08:00
Gregory Szorc
db823f8dff bundle2: use os.SEEK_* constants
Constants make code easier to read than magic numbers.

I also threw in an explicit argument in a caller to further
increase code comprehension.

Differential Revision: https://phab.mercurial-scm.org/D1370
2017-11-11 16:48:40 -08:00
Rodrigo Damazio Bovendorp
80a38c9b47 help: adding a topic on flags
This is a short topic to explain how command-line flags can be specified.

Some users have been confused by hg offerring different flag syntax than some
other libraries, so it'd be nice to point them to this rather than explaining
it every time.

Differential Revision: https://phab.mercurial-scm.org/D1270
2017-10-30 20:35:30 -07:00
Anton Shestakov
1f9fda40f1 hgweb: fix jshint issues in mercurial.js
Everything is pretty self-explanatory except the last hunk, where jshint
complains: "Misleading line break before '||'; readers may interpret this as an
expression boundary."

There is a tweakable called "laxbreak" that allows line breaks before
operators, but I think it's fine to simply join this one line and avoid extra
config for now (we can cook up and add a sensible .jshintrc later).
2017-11-11 14:14:38 +08:00
Boris Feld
196fe39bef exchange: drop unused '_getbookmarks' function
The function was introduced in 9234f8384fd7 in mid-November 2016 but is never
used anywhere in core.
2017-10-17 15:55:40 +02:00
Boris Feld
a22d32adae pull: store binary node in pullop.remotebookmarks
The internal representation of bookmark value is binary. The fact we stored
'hex' was an implementation detail from using pushkey.

We move the values in 'pullop.remotebookmarks' to binary before adding a way to
exchange bookmarks not based on pushkey.
2017-10-17 11:01:45 +02:00
David Demelier
15d6fd309d config: rename allow_push to allow-push
As part of ConfigConsolidationPlan [1], rename the option according to
the new UI guidelines [2] and add an alias for backward compatibility.

[1]: https://www.mercurial-scm.org/wiki/ConfigConsolidationPlan
[2]: https://www.mercurial-scm.org/wiki/UIGuideline#adding_new_options
2017-10-19 11:46:41 +02:00
David Demelier
d3338e9bad config: rename allowpull to allow-pull
As part of ConfigConsolidationPlan [1], rename the option according to
the new UI guidelines [2] and add an alias for backward compatibility.

[1]: https://www.mercurial-scm.org/wiki/ConfigConsolidationPlan
[2]: https://www.mercurial-scm.org/wiki/UIGuideline#adding_new_options
2017-10-19 11:43:19 +02:00
Anton Shestakov
2713fb3796 hgweb: add missing semicolons to followlines.js
Minor stylistic issues caught by jshint.
2017-11-10 19:14:06 +08:00
Anton Shestakov
1132b26766 gitweb: apply styles from annotate tooltip to followlines popup
These new colors and styles are already used in the tooltip that gets shown
when user hovers over line numbers on annotate page. The old styles, replaced
in this patch, look completely unrelated to gitweb or any other hgweb theme.
2017-11-10 18:50:44 +08:00
Anton Shestakov
34b93f7b60 paper: apply styles from annotate tooltip to followlines popup
These new colors and styles are already used in the tooltip that gets shown
when user hovers over line numbers on annotate page. The old styles, replaced
in this patch, look completely unrelated to paper or any other hgweb theme.
2017-11-10 18:45:43 +08:00
Martin von Zweigbergk
b2813c6218 pull: clarify that -u only updates linearly
Differential Revision: https://phab.mercurial-scm.org/D1355
2017-11-10 09:44:49 -08:00
Mark Thomas
1271cb536c dirstate: don't remove normallookup files from nonnormalset
The dirstate typically tries to keep the nonnormalset and otherparentset
up-to-date when making changes to the dirstate.  In the case of files marked
normallookup, however, it erroneously removes the file from the nonnormalset,
after _addpath had just added it.

This doesn't seem to matter at the moment, as nothing relies on the
nonnormalset being correct at this point, however a future re-implementations
of the dirstate map will require this to be kept up-to-date correctly.

Differential Revision: https://phab.mercurial-scm.org/D1339
2017-11-08 09:27:14 -08:00
Mark Thomas
a4a1780063 dirstate: clear map cached properties when clearing the map
dirstatemap.clear should remove all record of the files in the map.  This
includes removing caches of values derived from these.

Differential Revision: https://phab.mercurial-scm.org/D1338
2017-11-08 09:23:53 -08:00
Mark Thomas
83d7887053 util: add util.clearcachedproperty
This utility function allows clearing of the cached value set up
@propertycache, if there is one.

Differential Revision: https://phab.mercurial-scm.org/D1337
2017-11-08 09:18:18 -08:00
Augie Fackler
1df23f1a7a merge with stable 2017-11-10 17:12:04 -05:00
Kyle Lippincott
61883896f6 changegroup: use any node, not min(), in treemanifest's generatemanifests
This is fixing quadratic behavior, which is probably not noticeable in the
common case, but if a very large directory gets added here, it can get pretty
bad. This was noticed because we had some pushes that spent >25s in changegroup
generation calling min() here, according to profiling.

The original reasoning for min() being used in 1d71430e1d28 was that, at that
point in the series, we were adding almost everything to tmfnodes during the
first iteration through the loop , so we needed to avoid sending child
directories before parents. Later changes made it so that the child directories
were added only when we visited the parent directory (not all of them on the
first iteration), so this is no longer necessary - there won't be any child
directories in tmfnodes before the parents have been sent.

This does mean that the manifests are now exchanged unordered, whereas
previously we would essentially do [a, b, b/c, b/c/d, e], we now can send a, b,
and e in any order; b/c must still follow b, and b/c/d must still follow b/c.

Differential Revision: https://phab.mercurial-scm.org/D1351
2017-11-08 18:24:43 -08:00
Durham Goode
76228a6bf0 bundle: allow bundlerepo to support alternative manifest implementations
With our treemanifest logic, the manifests are no longer transported as part of
the changegroup and are no longer stored in a revlog. This means the
self.manifestlog line in bundlerepo.filestart no longer calls
_constructmanifest, and therefore does not consume the manifest portion of the
changegroup, which means filestart is not populated and we result in an infinite
loop.

The fix is to make filestart aware that self.manifestlog might not consume the
changegroup part, and consume it manually if necessary.

There's currently no way to test this in core, but our treemanifest extension
has tests to cover this.

Differential Revision: https://phab.mercurial-scm.org/D1329
2017-11-07 10:16:53 -08:00
Boris Feld
057760a2d2 obsfate: makes successorsetverb takes the markers as argument
Right now, successorsetverb only needs successors to compute the verb. But we
will want use additional information (effect-flags and operation) in the near
future to compute a better verb.

Add the markers parameter now so extensions (like Evolve) could wrap the
function and start experimenting around better obsfate verbs.

As successorsetverb now takes both successorset and markers parameters, rename
it to obsfateverb, successorsetandmarkersverb was too long.

Differential Revision: https://phab.mercurial-scm.org/D1191
2017-10-19 12:35:47 +02:00
Ryan McElroy
b4e9abb79e cmdutil: create dirs for templated cat file output
Previously, the caller was responsible for creating the directory structure of
files written out using a path template. This is onerous, especially if the
exact filenames are not known upfront, but are being accessed via a matcher.

This patch changes things so that hg will attempt to create the appropriate
directories before writing the output file.

Differential Revision: https://phab.mercurial-scm.org/D1332
2017-11-07 13:48:33 -08:00
Augie Fackler
7ed032e935 merge with stable 2017-11-07 13:18:49 -05:00
Yuya Nishihara
dfea246882 templatekw: add verbosity keyword to select template by -q/-v/--debug flag
This can be used in conjunction with the ifeq() function.
2017-10-21 17:46:41 +09:00
Yuya Nishihara
7f232b3ac0 templatekw: move loadkeyword() to bottom
loadkeyword() isn't a template keyword function.
2017-10-21 17:31:13 +09:00
Yuya Nishihara
1a42d3581c help: hide phaseidx template keyword
I don't think it's great idea to expose the internal representation of phases.
Let's discourage use of the phaseidx keyword.
2017-10-21 17:05:04 +09:00
Denis Laxalde
e400287a20 revert: do not reverse hunks in interactive when REV is not parent (issue5096)
And introduce a new "apply" operation verb for this case as suggested in
issue5096. This replaces the no longer used "revert" operation.

In interactive revert, when reverting to something else that the parent
revision, display an "apply this change" message with a diff that is not
reversed.

The rationale is that `hg revert -i -r REV` will show hunks of the diff from
the working directory to REV and prompt the user to select them for applying
(to working directory). This contradicts 79cc693b4406 in which it was
decided to have the "direction" of prompted hunks reversed. Later on
[1], there was a broad consensus (but no decision) towards the "as to
be applied direction". Now that --interactive is no longer experimental
(97d754ba45c4), it's time to switch and thus we drop no longer used
"experimental.revertalternateinteractivemode" configuration option.

[1]: https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-November/090142.html


.. feature::

  When interactive revert is run against a revision other than the working
  directory parent, the diff shown is the diff to *apply* to the working directory,
  rather than the diff to *discard* from the working copy. This is in line with
  related user experiences with `git` and appears to be less confusing with
  `ui.interface=curses`.
2017-11-03 14:47:37 +01:00
Kevin Bullock
d82cceaa42 merge with stable 2017-11-03 10:32:38 -05:00
Yuya Nishihara
57fc1b2b62 patch: improve heuristics to not take the word "diff" as header (issue1879)
The word "diff" is likely to appear in a commit message. Let's make it less
likely by requiring "diff -" for "diff -r" or "diff --git".
2017-10-21 16:50:57 +09:00
Boris Feld
8be76ccfef obsolete: activate effect-flag by default
Let's activate effect-flag by default as Evolve is experimental and in order
to gather feedback from users.
2017-11-01 17:08:33 +01:00
Boris Feld
59dcbd2a4d debug: print parsed bundle2 capabilities with debugcapabilities
The bundle2 capabilities are hard to read in their encoded form. We parse and
print them in a human friendly way.
2017-10-30 17:09:29 +01:00
Boris Feld
9554fcac46 debug: add a debugcapabilities commands
This new debugcommand prints the capabilities of any remote in a human friendly
way. Improved bundle2 capabilities support will be introduced in the next
changesets.
2017-10-30 17:08:16 +01:00
Augie Fackler
3ff9746218 revert: no longer mark --interactive as experimental
We seem to have settled down on behavior changes here (nothing
matching revset `keyword(revert) and keyword(interactive)` since 4.2
was released), so let's go ahead and advertise this excellent feature.

.. feature:: revert --interactive

  The revert command now accepts the flag --interactive to allow reverting
  only some of the changes to the specified files.
2017-10-30 17:46:07 -04:00
Augie Fackler
ffa2157901 ui: add configlist doctest to document a bit more of the whitespace behavior
I'm surprised this wasn't explicitly tested, so I added a test.
2017-10-25 23:01:54 -04:00
Augie Fackler
9ae9ebef63 parsers: protect some case-folding tables from clang-format
We want a slightly weird format here so that it's easier to read, but
in order to preserve that we need to disable clang-format.

Differential Revision: https://phab.mercurial-scm.org/D1168
2015-04-21 16:02:23 -04:00
Boris Feld
38f9c73dbd configitems: adds a developer warning when accessing undeclared configuration
Now that all known options are declared, we setup a warning to make sure it will
stay this way.

We disable the warning in two tests checking other behavior with random options.
2017-10-16 17:41:27 +02:00
Denis Laxalde
75398ab7ec log: add -L/--line-range option to follow file history by line range
We add an experimental -L/--line-range option to 'hg log' taking file patterns
along with a line range using the (new) FILE,FROMLINE-TOLINE syntax where FILE
may be a pattern (matching exactly one file). The resulting history is similar
to what the "followlines" revset except that, if --patch is specified,
only diff hunks within specified line range are shown.

Basically, this brings the CLI on par with what currently only exists in hgweb
through line selection in "file" and "annotate" views resulting in a file log
with filtered patch to only display followed line range.

The option may be specified multiple times and can be combined with --rev and
regular file patterns to further restrict revisions. Usage of this option
requires --follow; revisions are shown in descending order and renames are
followed. Only the --graph option is currently not supported.

The UI is the result of a consensus from review feedback at:

  https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-October/106749.html


The implementation spreads between commands.log() and cmdutil module.
In commands.log(), the main loop may now use a "hunksfilter" factory (similar
to "filematcher") that, for a given "rev", produces a filtering function
for diff hunks for a given file context object.
The logic to build revisions from -L/--line-range options lives in
cmdutil.getloglinerangerevs() which produces "revs", "filematcher" and
"hunksfilter" information. Revisions obtained by following files' line range
are filtered if they do not match the revset specified by --rev option. If
regular FILE arguments are passed along with -L options, both filematchers are
combined into a new matcher.

.. feature::

   Add an experimental -L/--line-range FILE,FROMLINE-TOLINE option to 'hg log'
   command to follow the history of files by line range. In combination with
   -p/--patch option, only diff hunks within specified line range will be
   displayed. Feedback, especially on UX aspects, is welcome.
2017-10-17 21:15:31 +02:00
Denis Laxalde
356644ac1a diff: pass a diff hunks filter function from changeset_printer to patch.diff()
We add a 'hunksfilterfn' keyword argument in all functions of the call
stack from changeset_printer.show() to patch.diff(). This is a callable
that will be used to filter out hunks by line range and will be used in
the "-L/--line-range" option of "hg log" command introduced in the
following changesets.
2017-10-06 14:45:17 +02:00
Denis Laxalde
f37bd71289 diff: also yield file context objects in patch.trydiff() (API)
And retrieve them in patch.diffhunks(). We'll use these in forthcoming
changesets to filter diff hunks by line range.
2017-10-05 21:20:08 +02:00
Denis Laxalde
5c56737c70 revset: extract a parsefollowlinespattern helper function
We'll need the same logic in forthcoming changeset to handle --line-range
option in 'hg log' command.
The function lives in scmutil.py (rather than util.py) as it uses match and
pathutil modules.
2017-10-04 15:27:43 +02:00
Boris Feld
c3010f59dd obsfate: add obsfate to default mapfile
Use the verbosity aware template keyword introduced earlier. It has the nice
property of being verbosity dependent but in order to customize the obsfate
part, users will need to replace the lobsfate definition from default mapfile
with the one using template functions (by copying the one from test-obsmarker-
template.t for example).

As it's a more advanced use-case, I'm more inclined to have the same code for
the {obsfate} keyword, in the changeset printer and in the default mapfile for
consistency.

But, the definition in default mapfile could be replaced with one based on
template filter to obsfate output customization if it is a big need for users.
2017-10-06 17:53:36 +02:00
Boris Feld
d09c69f7b8 log: add obsfate by default in changeset printer
Having an obsfate by default in log will be useful for users to understand why
they have obsolete and unstable changesets. Obsfate will only be shown for
obsolete changesets, which only happens if people opt-in to experimental feature.

But when obsolete changeset are visible, it is very useful to understand where
they are. Having it in log could be sufficient for most people, so they don't
have to learn a new command (like obslog which is itself useful in case of
divergences).

For example, when pulling and working directory parent become obsolete:

  $ hg pull
  ...
  working directory parent is obsolete! (f936c1697205)

This message comes from the Evolve extension.

Obsfate would comes handy:

  $ hg log -G
  o  changeset:   2:6f91013c5136
  |  tag:         tip
  |  parent:      0:4ef7b558f3ec
  |  user:        Boris Feld <boris.feld@octobus.net>
  |  date:        Mon Oct 09 16:00:27 2017 +0200
  |  summary:     A
  |
  | @  changeset:   1:f936c1697205
  |/   user:        Boris Feld <boris.feld@octobus.net>
  |    date:        Mon Oct 09 16:00:27 2017 +0200
  |    obsfate:     rewritten using amend as 2:6f91013c5136
  |    summary:     -A
  |
  o  changeset:   0:feb4dd822b8c
     user:        Boris Feld <boris.feld@octobus.net>
     date:        Tue Oct 09 16:00:00 2017 +0200
     summary:     ROOT

And once we update, we don't have an obsolete changeset in the log anymore so
we don't show obsfate anymore, most users won't see obsfate often if they
don't have obsolete changeset often:

  @  changeset:   2:6f91013c5136
  |  tag:         tip
  |  parent:      0:4ef7b558f3ec
  |  user:        Boris Feld <boris.feld@octobus.net>
  |  date:        Mon Oct 09 16:00:27 2017 +0200
  |  summary:     A
  |
  o  changeset:   0:feb4dd822b8c
     user:        Boris Feld <boris.feld@octobus.net>
     date:        Tue Oct 09 16:00:00 2017 +0200
     summary:     ROOT
2017-10-05 15:25:18 +02:00
Boris Feld
d580cec6cc obsfate: only display date in verbose mode
The date is also not that helpful in most cases but we show it in verbose mode.
2017-10-09 15:34:26 +02:00
Boris Feld
98e0e19dcc obsfate: filter out current user if not in verbose
Obsolescence is sometimes used only locally so the obs-marker users is always
the same. Showing the user in this case does not bring much values.

In the case where multiple users rewrite the commit, display the full list of
users. Also show all users in verbose mode.
2017-10-09 15:34:12 +02:00
Boris Feld
142a0c0bf5 ui: add the possibility to returns None as username in ui
In a later patch we want to retrieve the current username or None if it isn't
defined. Add the acceptempty parameter instead of catching Abort.
2017-10-06 16:23:47 +02:00
Boris Feld
4ed4f0d702 templatekw: introduce obsfate keyword
Introduce an obsfate printer that uses all helpers functions defined in
obsutil to get all the obsfate-related data and format a string according to
the current format in test-obsmarker-template.t.

Then, introduce an obsfate templatekw that uses the obsfateprinter to return a
list of strings.

The goal is not to replace existing obsfate template functions but to propose
a default, good-enough and easily usable obsfate definition for end-users that
don't want to customize it. Such output would ultimately get included in the
default log output.

Here are some output examples for a commit amended:

rewritten using amend as 5:a9b1f8652753 by test (at 1970-01-01 00:00 +0000)

Next patches will make the output dependent on the verbosity.

Exemple of use-cases:

For having the obsfate on a single-line between brackets:

  {if(obsfate, " [{join(obsfate, "; ")}]")}

For having the obsfate in several lines:

  {if(obsfate, "{obsfate % "  Obsfate: {fate}\n"}")}
2017-10-05 17:42:56 +02:00
Pulkit Goyal
98c13e4c70 copies: add a config to limit the number of candidates to check in heuristics
The heuristics algorithm find possible candidates for move/copy and then check
whether they are actually a copy or move. In some cases, there can be lot of
candidates possible which can actually slow down the algorithm.

This patch introduces a config option
`experimental.copytrace.movecandidateslimit` using which one can limit the
candidates to check. The limit defaults to 100.

Thanks to Yuya for suggesting to skip copytracing for that file with a
warning.

Differential Revision: https://phab.mercurial-scm.org/D987
2017-10-10 02:25:03 +05:30
Martin von Zweigbergk
3fba6ca94a extensions: always include traceback when extension setup fails
I have spent a lot of time debugging extensions that failed to load
because we don't include a traceback and I didn't realize I could get
traceback for the extension failure with --traceback. Let's just turn
them on by default, since it should be rare that the user sees these
tracebacks anyway (and if they do, it's not so bad if the extra
traceback pushes them a little harder to report the problem).

Since we already had a test case with --traceback and one without, I
just removed the one with the flag.

Differential Revision: https://phab.mercurial-scm.org/D1164
2017-10-17 10:31:44 -07:00
Jun Wu
4fede3d6bc test-show: make it compatible with chg
The show extension reads `commands.show.aliasprefix` config in its
`extsetup` and that causes issues with chg. This patch adds that config item
to chg confighash to solve the issue.

Test Plan:
`run-tests.py -l --chg test-show.t`

Differential Revision: https://phab.mercurial-scm.org/D1158
2017-10-17 10:41:56 -07:00
Augie Fackler
22d88dd8c3 templater: use pycompat.sysbytes to bytes-ify some __name__ attrs
Spotted by yuya in review of 093b17c57344.

Differential Revision: https://phab.mercurial-scm.org/D1145
2017-10-17 10:51:43 -04:00
Augie Fackler
d57f1641f5 templatefilters: defend against evil unicode strs in json filter
We only want to do I/O in terms of bytes, so lets explode early
instead of recursing forever.

Differential Revision: https://phab.mercurial-scm.org/D1136
2017-10-16 22:44:43 -04:00
Boris Feld
a5658f8623 phase: use a binary phase part to push through bundle2 (BC)
The part we are using for pull is now used for push too. As we no longer use
pushkey, pushkey hooks are no longer triggered. This is an obvious backward
incompatible change. We could artificially trigger the pushkey hook within the
bundle2 part, but this seemed too hacky to me.

An option would be to disable by default this new mechanism for a couple of
versions to help people migrate to `txnclose-phase`. I took the liberal and
optimistic path to just turn it on by default directly.

.. bc::

   Push no longer triggers a pushkey hook when updating phases. Use the new
   `txnclose-phase` and `txnclose-phase` hooks instead.
   (Applies when both server and client use version 4.4 or above).
2017-09-20 19:38:06 +02:00
Phil Cohen
ed7cf84951 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
`filecmp` follows symlinks by default, which a `filectx.cmp()` call should not
be doing as it should only compare the  requested entry. After this patch, only
the contexts' data are compared, which is the correct contract.

This is a corrected version of D1122.

Differential Revision: https://phab.mercurial-scm.org/D1165
2017-10-17 12:41:24 -07:00
Mark Thomas
8e56a1507b context: audit paths before clearing unknown files and dirs
Fix regression introduced in D785.

In some circumstances, context.clearunknown can be called before the path is
audited. Audit the path before deleting any conflicting files.

Differential Revision: https://phab.mercurial-scm.org/D1157
2017-10-17 08:11:13 -07:00
Boris Feld
ad5f3bc109 configitems: move rebase config into core
The shelve extensions import and call rebase content without loading the
extension. This is problematic as the config items rebase uses are not
declared and the default value are not set, etc...

The shelve extension should be using core utilities only and the necessary bit
should be moved from rebase into core. In the meantime, I'm taking a small
step to get config registration completed with minimal overhead. The rebase
extension is shipped with core so registering its config option within core is
not a big issue.

This is the last step needed before we can install a warning that enforces all
config to be registered.
2017-10-13 23:00:31 +02:00
Boris Feld
3796be0790 configitems: register the 'web.archivesubrepos' config 2017-10-16 18:16:29 +02:00
Boris Feld
6241e08062 configitems: register the 'experimental.effect-flags' config 2017-10-08 22:22:27 +02:00
Boris Feld
ed9a31a26e configitems: register the full 'merge-tools' config and sub-options
We register the merge-tools config section (which has an arbitrary base config
value) and the possible sub-attribute. The sub-attribute has to be registered
first or at the same time otherwise the '.*' item would shadow them.

Merge tools could include "." in their name so we can't constrain any more
than just ".*".
2017-10-08 20:37:13 +02:00
Paul Morelle
549788470a revlog-sparse-read: add a lower-threshold for read block size
The option experimental.sparse-read.min-block-size specifies the minimal size
of a deltachain span, under which it won't be split by _slicechunk.
2017-10-14 17:05:41 +02:00
Paul Morelle
d1288f1f44 revlog: introduce an experimental flag to slice chunks reads when too sparse
Delta chains can become quite sparse if there is a lot of unrelated data between
relevant pieces. Right now, revlog always reads all the necessary data for the
delta chain in one single read. This can lead to a lot of unrelated data to be
read (see issue5482 for more details).
One can use the `experimental.maxdeltachainspan` option with a large value
(or -1) to easily produce a very sparse delta chain.

This change introduces the ability to slice the chunks retrieval into  multiple
reads, skipping large sections of unrelated data. Preliminary testing shows
interesting results. For example the peak memory consumption to read a manifest
on a large repository is reduced from 600MB to 250MB (200MB without
maxdeltachainspan). However, the slicing itself and the multiple reads can have
an negative impact on performance. This is why the new feature is hidden behind
an experimental flag.

Future changesets will add various parameters to control the slicing heuristics.
We hope to experiment a wide variety of repositories during 4.4 and hopefully
turn the feature on by default in 4.5.
As a first try, the algorithm itself is prone to deep changes. However, we wish
to define APIs and have a baseline to work on.
2017-10-10 17:50:27 +02:00
Paul Morelle
6d907667b2 revlog: ignore empty trailing chunks when reading segments
When a merge commit creates an empty diff in the revlog, its offset may still
be quite far from the end of the previous chunk.
Skipping these empty chunks may reduce read size significantly.
In most cases, there is no gain, and in some cases, little gain.
On my clone of pypy, `hg manifest` reads 65% less bytes (96140 i/o 275943) for
revision 4260 by ignoring the only empty trailing diff.
For revision 2229, 35% (34557 i/o 53435)
Sadly, this is difficult to reproduce, as hg clone can make its own different
structure every time.
2017-10-09 15:13:41 +02:00
Boris Feld
a3e217804d phase: isolate logic to update remote phrase through bundle2 pushkey
Move the logic to build bundle2 pushkey part into its dedicated function. It
will help to keep the logic clear when adding support for sending phases change
using 'phase-heads' part.
2017-09-20 19:17:37 +02:00
Boris Feld
e0099ff757 phase: generate a push-race detection part on push
We are about to switch phase pushing from using pushkey to using a the new
dedicated binary part. We introduce the push race detection on its own to help
detect potential impact.
2017-10-11 07:40:00 +02:00
Boris Feld
f74c12124e phase: introduce a new 'check:phases' part
This part checks if revisions are still in the same phase as when the
bundle was generated. This is similar to what 'check:heads' or
'check:updated-heads' bundle2 part achieves for changesets.

We needs seems before we can move away from pushkey usage from phase since
pushkey has it own built-in push-race detection.
2017-10-11 07:13:02 +02:00
Boris Feld
68629fa552 phase: gather remote phase information in a summary object
We keep useful phase information around. The data will be reused with detecting
push-race in later changesets.
2017-10-11 18:39:04 +02:00
Boris Feld
048b95b938 phase: simplify the check for issue3781 shortcut in discovery
We'll rework the code around this check. Limiting the entanglement will help
with later changesets
2017-10-11 18:39:34 +02:00
Boris Feld
02117664d7 exchange: fix issue3781 reference in the comment
This comment is about:

  issue3781: Courtesy Phases synchronisation to publishing server prevent
             subrepo push
Not about:

  issue3871: Slow hg log when template contains {file_adds}, {file_mods} and
             {file_dels}
2017-10-16 12:36:42 +02:00
Boris Feld
bf2608127e phase: filter out non-draft item in "draft root"
The on-disk file can contain draft root that are descendants of secret root.
The resulting phase computation is correct, but the phases root content is
not. I will send another series to introduce code that remove some of the
cases where this can happens, but we first need to damage control the existing
case.

After this changeset, we can no longer advertise secret changeset as draft
root.
2017-10-11 20:08:02 +02:00
Matt Harbison
408a3898be subrepo: share instead of clone if the parent repo is shared (issue5675) (BC)
Previously, only the top level repo was shared, and then any subrepos were
cloned on demand.  This is problematic because commits to the parent repo would
write an updated .hgsubstate to the share source, but the corresponding subrepo
commit would be stuck in the local subrepo.  That would prevent an update in the
source repo.  We already go to great lengths to avoid having inconsistent repos
(e.g., `hg push -r rev` will push _everything_ in a subrepo, even if it isn't
referenced in one of the parent's outgoing commits).  Therefore, this seems like
a bug fix, and there's no option to get the old behavior.  I can't imagine the
previous behavior was useful to anybody.

There shouldn't be an issue with svn, since it is centralized.  Maybe --git-dir
can be used for git subrepos, but I'll leave that to someone more familiar with
git.

An integer was previously being implicitly returned from commands.share(), which
caused dispatch() to start crashing when changing over to returning the shared
repo.  All error paths appear to raise, so this can be hardcoded to success.
The clone command checks for 'is None' in a similar pattern, but since
hg.clone() always returns a tuple, that seems wrong?

.. fix:: Issue 5675

   Creating a share of a repository with a Mercurial subrepository will now
   share the subrepository.

and

.. bc::

   Mercurial subrepositories are now shared instead of cloned when the parent
   repository is shared.  This prevents dangling subrepository references in the
   share source.  Previously shared repositories with cloned subrepositories
   will continue to function unchanged.
2017-10-15 22:48:02 -04:00
Augie Fackler
bcaad82b20 webcommands: replace str(ctx) etc with pycompat.bytestr(ctx) etc
hgweb can now serve the graph view in Python 3.

Differential Revision: https://phab.mercurial-scm.org/D1138
2017-10-16 22:51:58 -04:00
Augie Fackler
4c963a0721 templater: don't blow up when trying to build an abort message
__name__ is unicode, but we need bytes. For now, we'll make the
(mostly-safe) assumption that template filter names will be ascii.

Differential Revision: https://phab.mercurial-scm.org/D1137
2017-10-16 22:50:39 -04:00
Augie Fackler
45c9441c0e webutil: use pycompat.bytestr() instead of str()
Stops us from choking the templater on Python 3. With this patch
applied, much of hgweb works correctly in Python 3. The notable
exception is the graph page, which chokes because it gets node IDs as
str instead of bytes.

Differential Revision: https://phab.mercurial-scm.org/D1135
2017-10-16 22:44:06 -04:00
Augie Fackler
c6a33e23e1 hgweb: correct an earlier error of mine - start should be bytes
Gets hgweb very close to working with Python 3.

Differential Revision: https://phab.mercurial-scm.org/D1134
2017-10-16 22:43:19 -04:00
Boris Feld
902027adea config: simplify aliasing commands.update.check
experimental.updatecheck was renamed into commands.update.check, use the
config system to provides the fallback on the old config name instead of
adding more code.

Differential Revision: https://phab.mercurial-scm.org/D1117
2017-10-16 18:58:16 +02:00
Augie Fackler
44f638de23 mpatch: switch alignment of wrapped line from tab to spaces with clang-format
I may be a weird person for liking this style, but our C style is
historically nominally the Linux Kernel style, and when you configure
clang-format to be kernel-ish, this is what you get. If we want to
change it, we can do so by tweaking the formatter rules in the future.

Differential Revision: https://phab.mercurial-scm.org/D1132
2017-10-04 11:00:04 -04:00
Augie Fackler
210a208635 mpatch: reformat function prototypes with clang-format
Differential Revision: https://phab.mercurial-scm.org/D1131
2017-10-04 10:56:33 -04:00
Ryan McElroy
97fa443439 merge: allow user to halt merge on merge-tool failures
Depends on D932.

Call the new _onfilemergefailure function when a merge tool reports failure
via a return code.

Differential Revision: https://phab.mercurial-scm.org/D951
2017-10-06 06:48:43 -07:00
Ryan McElroy
cc72ebf3bc filemerge: introduce functions to halt merge flow
Depends on D931.

This patch introduces functions and a config option that will allow a user
to halt the merge if there are failures during a file merge. These functions
will be used in the next patch.

Differential Revision: https://phab.mercurial-scm.org/D932
2017-10-06 06:48:43 -07:00
Pulkit Goyal
8fe8ec1089 cmdutil: pass metadata from amend() to cleanupnodes
`commit --amend` and amend command in core and extensions rely on
cmdutil.amend() for amending a commit. So the logic to add a note to amend must
reside here. This patch assumes that note will be passed in opts dictionary to
the function and it will be passed to cleanupnodes and then createmarkers to
store the note in the obsmarker metadata.

After this patch, note can be stored on an amend changeset by passing notes as a
part of opts to cmdutil.amend().

Differential Revision: https://phab.mercurial-scm.org/D1094
2017-10-15 15:32:03 +05:30
Pulkit Goyal
66d216220e scmutil: add capability to cleanupnodes to take obsmarker metadata
This patch adds a metadata argument to cleanupnodes() which will be dict and can
be passed to obsmarker.createmarkers() and can be stored on the obsmarker.
In cases when obsolescence is not enabled, the metadata argument is useless.

This is a step towards storing a note in amend.

Differential Revision: https://phab.mercurial-scm.org/D1093
2017-10-15 14:34:24 +05:30
Phil Cohen
a04280b2f9 context: add workingfilectx.markcopied
With in-memory merge, copy information needs to be stored in-memory, not in the
dirstate.

To make this transition easy, move the existing dirstate-based approach to
workingfilectx; that way, other implementations can choose to store it
somewhere else.

Differential Revision: https://phab.mercurial-scm.org/D1106
2017-10-15 20:36:29 -07:00
Phil Cohen
fac2e07a2a merge: don't use workers in in-memory mode
The worker processes can't share memory, so workers should not be used.

Differential Revision: https://phab.mercurial-scm.org/D1105
2017-10-15 20:36:29 -07:00
Phil Cohen
a76f841e4e filemerge: add a missing flushall()
Differential Revision: https://phab.mercurial-scm.org/D1060
2017-10-15 20:36:29 -07:00
Phil Cohen
a93f277c4b filemerge: store backups in the overlayworkingctx if using imm
Differential Revision: https://phab.mercurial-scm.org/D1059
2017-10-13 12:34:22 -07:00
Phil Cohen
220e45c6d6 context: add overlayfilectx.cmp()
Differential Revision: https://phab.mercurial-scm.org/D1058
2017-10-13 12:34:22 -07:00
Phil Cohen
e16963ee65 filemerge: use arbitraryfilectx for backups
With in-memory merge, backup files might be overlayworkingfilectxs stored
in memory. But they could also be real files if the user's backup directory is
outside the working dir.

Rather than have two code paths everywhere, let's use arbitraryfilectx so they
can be consistent.

Differential Revision: https://phab.mercurial-scm.org/D1057
2017-10-16 13:10:55 -07:00