Commit Graph

20104 Commits

Author SHA1 Message Date
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
Mark Thomas
ce1d136e58 scmutil: don't try to delete origbackup symlinks to directories (issue5731)
When origbackuppath is set, when looking to see if a file we are backing up
conflicts with a directory in the origbackuppath, we incorrectly match on
symlinks to directories.  This means we try to call vfs.rmtree on the
symlink, which fails.

Differential Revision: https://phab.mercurial-scm.org/D1311
2017-11-03 09:27:36 -07:00
Augie Fackler
d0223576fe stable: merge with security patches 2017-11-07 11:22:24 -05:00
Gregory Szorc
bcd6d015d2 subrepo: use per-type config options to enable subrepos
We change subrepos.allowed from a list of allowed subrepo types to
a combination of a master switch and per-type boolean flag.

If the master switch is set, subrepos can be disabled wholesale.

If subrepos are globally enabled, then per-type options are
consulted. Mercurial repos are enabled by default. Everything else
is disabled by default.
2017-11-06 22:32:41 -08:00
Augie Fackler
68d8df395d config: add some more documentation around why svn and git subrepos are off 2017-11-06 14:56:17 -05:00
Gregory Szorc
53801830bd share: move config item declarations into core
These config items control share behavior that is implemented in core.
Since the functionality is implemented in core, extensions may
leverage it.

Mozilla has one such extension. And, it needs to access share.pool.
Before this patch, a devel warning regarding accessing an unregistered
config option would be issued unless the share extension were loaded.
Moving the registration of the config options to core fixes this.
2017-11-06 10:33:40 -08:00
Yuya Nishihara
e5730ba521 subrepo: disable git and svn subrepos by default (BC) (SEC)
We have a security issue with git subrepos. I'm not sure if svn subrepo is
vulnerable, but it seems not 100% safe to allow writing arbitrary data into
a metadata directory. So for now, only hg subrepo is enabled by default.

Maybe we should improve the help to describe why git/svn subrepos are
disabled.
2017-11-05 21:51:42 +09:00
Yuya Nishihara
9752ef714d subrepo: extend config option to disable subrepos by type (SEC)
This allows us to minimize the behavior change introduced by the next patch.

I have no idea which config style is preferred in UX POV, but I decided to
get things done.

 a) list: 'allowed = hg, git, svn'
 b) sub option: 'allowed.hg = True' or 'allowed:hg = True'
 c) per-type action: 'hg = allow', 'git = abort'
2017-11-05 21:48:58 +09:00
Yuya Nishihara
f864544d81 subrepo: add config option to reject any subrepo operations (SEC)
This is an alternative workaround for the issue5730.

Perhaps this is the simplest way of disabling subrepo operations. It does
nothing clever, but just aborts if Mercurial starts accessing to a subrepo.

I think Greg's patch is more useful since it allows us to at least check
out the parent repository. However, that would be confusing if the default
is flipped to checkout=False and subrepos are silently ignored.

I don't like the config name 'allowed', but I couldn't get any better name.
2017-11-05 21:22:07 +09:00
Matt Harbison
2be4ce7af1 morestatus: don't crash with different drive letters for repo.root and CWD
Previously, if there were unresolved files and the CWD drive was different from
the repo drive, `hg status -v` would page the normal status, followed by the
exception header.  A stacktrace was waiting when the pager exited.  The
underlying cause was the same as 12441ef4442f.

Unfortunately, I don't see any reasonable way to write a test this [1].

[1] https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-November/107401.html
2017-11-04 23:39:54 -04:00
Matt Harbison
212ee63a25 pathutil: add doctests for canonpath()
This is a followup to 12441ef4442f.  Since there's no way to ensure that more
drive letters than C: exist, this seems like the only way to test it.  This is
enough to catch the 12441ef4442f scenario, as well as CWD outside of the repo
when the path isn't prefixed with path/to/repo.
2017-11-03 22:22:50 -04:00
Yuya Nishihara
dac75264c0 subrepo: disallow symlink traversal across subrepo mount point (SEC)
It wasn't easy to extend the pathauditor to check symlink traversal across
subrepos because pathauditor._checkfs() rejects a directory having ".hg"
directory. That's why I added the explicit islink() check.

No idea if this patch is necessary after we've fixed the issue5730 by
splitting submerge() into planning and execution phases.
2017-11-03 20:12:50 +09:00
Matt Harbison
31925dd9ca share: handle --relative shares to a different drive letter gracefully
This had the same problem as 12441ef4442f.  Banning os.path.relpath() is
tempting, but the hint it provides is useful here.
2017-11-02 23:55:09 -04:00
Matt Harbison
325a0abc6e pathutil: use util.pathto() to calculate relative cwd in canonpath()
os.path.relpath() exploded if the 'root' and 'cwd' directories had different
drive letters.  I noticed this in TortoiseHg when typing a fileset into the
filter, and it kept complaining until the closing '()' was typed.  This was
reproducible on the command line with:

  $ cd /d
  $ hg -R /c/Users/Matt/Projects/hg files 'set:e'
  Traceback (most recent call last):
  ...
  File "mercurial\pathutil.pyc", line 182, in canonpath
  File "ntpath.pyc", line 529, in relpath
  ValueError: path is on drive c:, start on drive d:
2017-11-02 20:35:31 -04:00