Commit Graph

6178 Commits

Author SHA1 Message Date
Jun Wu
ec32c2f725 histedit: use scmutil.cleanupnodes (BC)
This is marked as BC because the strip backup file name has changed.
2017-07-08 16:50:31 -07:00
Jun Wu
f9577750a4 histedit: unify strip backup files on success (BC)
Previously we wrote two different strip backup files on success. This patch
unifies them. It will make scmutil.cleanupnodes migration more smooth.
2017-07-08 16:50:31 -07:00
Jun Wu
94f02e40d4 histedit: pass multiple nodes to strip (BC)
Previously, histedit.cleanupnode pass root nodes one by one. Since
repair.strip takes multiple nodes and can handle them just fine, pass all
strip roots at once.

This is BC because the number of strip backup files may change from N to 1.
2017-07-08 16:50:31 -07:00
Jun Wu
491b12c96e histedit: remove "name" parameter from cleanupnode functions
The "name" parameter is not used any longer so let's remove it.
2017-07-08 16:50:31 -07:00
Jun Wu
83e4cd62fc histedit: remove "should strip" debug message
The debug message was not used anywhere. Removed it to make
scmutil.cleanupnodes migration easier to reason about.
2017-07-08 16:50:31 -07:00
Jun Wu
4019f12521 histedit: move topmost bookmark movement to a separate function
histedit treats topmost bookmark movement specially. The rest of the
bookmark movement could be handled by scmutil.cleanupnodes. So let's move
the special logic out to make the patch easier to review.
2017-07-08 16:47:25 -07:00
Jun Wu
e9417ea1fc histedit: remove moving bookmarks message on verbose (BC)
This is more consistent with other commands, like "commit -v" won't show
bookmark movement messages.

It will make migrating to scmutil.cleanupnodes easier.
2017-07-08 16:04:21 -07:00
Jun Wu
8046e7f0bb rebase: remove "if True"
The "if True" block was to make the last patch easier to review. This patch
removes "if True" and unindents the block.
2017-07-07 19:03:03 -07:00
Jun Wu
936199e02d rebase: use scmutil.cleanupnodes (issue5606) (BC)
This patch migrates rebase to use scmutil.cleanupnodes API. It simplifies
the code and makes rebase code reusable inside a transaction.

This is a BC because the backup file is no longer strip-backup/*-backup.hg,
but strip-backup/*-rebase.hg. The latter looks more reasonable since the
directory name is "strip-backup" so there is no need to repeat "backup".

I think the backup file name change is probably fine as a BC, since we have
changed it before (2e51c9a7a08f) and didn't get complains. The end result
of this series will be a much more consistent and unified backup names:

  command  | old backup file suffix       | new backup file suffix
  -------------------------------------------------------------------
  amend    | amend-backup.hg              | amend.hg
  histedit | backup.hg (could be 2 files) | histedit.hg (single file)
  rebase   | backup.hg                    | rebase.hg
  strip    | backup.hg                    | backup.hg

(note: backup files are under .hg/strip-backup)

It also fixes issue5606 as a side effect because the new "delayedstrip" code
path will carefully examine nodes (safestriproots) to make sure orphaned
changesets won't get stripped by accident.

Some warning messages are changed to the new "warning: orphaned descendants
detected, not stripping HASHES", which provides more information about
exactly what changesets are left behind.

Another minor behavior change is when there is an obsoleted changeset with a
successor in the destination branch, bookmarks pointing to that obsoleted
changeset will not be moved. I have commented in test-rebase-obsolete.t
explaining why that is more desirable.
2017-07-07 18:51:46 -07:00
Gregory Szorc
793c8fb431 sparse: move working directory refreshing into core
This is a pretty straightforward move of the code.

I converted the "force" argument to a keyword argument.

Like other recent changes, this code is tightly coupled with
working directory update code in merge.py. I suspect the code
will become more tightly coupled over time, possibly even moved
to merge.py. For now, let's get the code in core.
2017-07-06 14:53:08 -07:00
Gregory Szorc
7fec603f86 sparse: refactor update actions filtering and call from core
merge.calculateupdates() now filters the update actions through sparse
by default.

The filtering no-ops if sparse isn't enabled or no sparse config
is defined.

The function has been refactored to behave more like a filter
instead of a wrapper of merge.calculateupdates().

We should arguably take sparse into account earlier in
merge.calculateupdates(). This patch preserves the old behavior
of applying sparse at the end of update calculation, which is the
simplest and safest approach.
2017-07-06 16:29:31 -07:00
Gregory Szorc
7fff0417c9 sparse: move update action filtering into core
This is a relatively straight port of the function. It is pretty large.
So refactoring will be postponed to a subsequent commit.
2017-07-06 16:17:35 -07:00
Gregory Szorc
6dce563cd3 sparse: move pruning of temporary includes into core
This was our last method on the custom repo type, meaning we could
remove that custom type and inline the 2 lines of code into
reposetup().

As part of the move, instead of wrapping merge.update() from
the sparse extension, we inline the function call. The ported
function now no-ops if sparse isn't enabled, making it safe to
always call.

The call site in update() may not be the most appropriate. But
it matches the previous behavior, which is the safest thing
to do. It can be improved later.
2017-07-06 14:33:18 -07:00
Gregory Szorc
26fd8a7af7 sparse: move function for resolving sparse matcher into core
As part of the move, the function arguments changed so revs are
passed as a list instead of *args. This allows us to use keyword
arguments properly.

Since the plan is to integrate sparse into core and have it
enabled by default, we need to prepare for a sparse matcher
to always be obtained and operated on. As part of the move,
we inserted code that returns an always matcher if sparse
isn't enabled. Some callers in the sparse extension take this
into account and conditionally perform matching depending on
whether the special always matcher is seen. I /think/ this
may have sped up some operations where the extension is
installed but no sparse config is activated.

One thing I'm ensure of in this code is whether os.path.dirname()
is semantically correct. os.posixpath.dirname() (which is
exported as pathutil.dirname) might be a better choise because
all patterns should be using posix directory separators (/)
instead of Windows (\). There's an inline comment that implies
Windows was tested. So hopefully it won't be a problem. We
can improve this in a follow-up. I've added a TODO to track it.
2017-07-06 17:41:45 -07:00
Gregory Szorc
16c192411d match: move matchers from sparse into core
The sparse extension contains some matcher types that are
generic and can exist in core.

As part of the move, the classes now inherit from basematcher.
always(), files(), and isexact() have been dropped because
they match the default implementations in basematcher.
2017-07-06 17:39:24 -07:00
Gregory Szorc
0338e1f32a sparse: move config signature logic into core
This is a pretty straightforward port. It will be cleaned up in
a subsequent commit.
2017-07-06 16:11:56 -07:00
Gregory Szorc
35151669b9 sparse: remove custom hash matcher
With the recent change to always use repr(), this function was
functionally identical to the version in fsmonitor it was
replacing. So remove it.
2017-07-06 17:31:33 -07:00
Martin von Zweigbergk
585fc127ad sparse: override __repr__ in matchers
sparse.py in FB's hg-experimental repo switched to using __repr__ for
non-sparse matchers soon after hg core started overriding __repr__ in
the matchers in match.py (because the core matchers also stopped
having "includepat" and other attributes that sparse used to depend
on). Let's finish that migration by implementing __repr__ in the
sparse matchers as well. That also lets us remove the special handling
of them in _hashmatcher().
2017-07-06 16:37:36 -07:00
Martin von Zweigbergk
e9ccfc8938 shelve: don't reimplement mergestate.unresolved() 2015-12-01 09:19:54 -08:00
Gregory Szorc
fa7c02cef4 sparse: move some temporary includes functions into core
Functions for reading and writing the tempsparse file have been
moved. prunetemporaryincludes() will be moved separately
because it is non-trivial.
2017-07-06 14:48:16 -07:00
Gregory Szorc
23bd6434bf sparse: move config file writing into core
The code was refactored during the move to be more procedural
instead of using string formatting. This has the benefit of not
writing empty sections, which changed tests.
2017-07-06 12:24:55 -07:00
Gregory Szorc
0cd417305b localrepo: add sparse caches
The sparse extension maintains caches for the sparse files
to a signature and a signature to a matcher. This allows the
sparse matchers to be resolved quickly, which is apparently
something that can occur in loops.

This patch ports the sparse caches to the localrepo class
pretty much as-is. There is potentially room to improve the
caching mechanism. But that can be done as a follow-up.

The default invalidatecaches() now clears the relevant sparse
cache. invalidatesignaturecache() has been moved to sparse.py.
2017-07-06 12:20:53 -07:00
Gregory Szorc
82797a75d4 sparse: move active profiles function into core
Also includes some light formatting changes.
2017-07-06 12:26:04 -07:00
Gregory Szorc
b77eafa212 sparse: move resolving of sparse patterns for rev into core
This method is reasonably well-contained and simple to move.

As part of the move, some light formatting was performed.

A "working copy" reference in an error message was changed to
"working directory."

The biggest change was to _refreshoncommit() in sparse.py. It
was previously checking for the existence of an attribute on
the repo instance. Since the moved function now returns empty
data if sparse isn't enabled, we unconditionally call the
new function. However, we do have to protect another method
call in that function. This will all be unhacked eventually.
2017-07-06 12:15:14 -07:00
Gregory Szorc
19d9143b89 sparse: variable to track if sparse is enabled
Currently, the sparse extension sniffs repo instances for
attributes defined by the sparse extension to determine if
sparse is enabled. As we move code away from repo instances,
these checks will be a bit more brittle.

We introduce a module-level variable to track whether sparse is
enabled as a temporary workaround.
2017-07-06 12:06:37 -07:00
Gregory Szorc
c16ee0ee8c sparse: move profile reading into core
One more step towards weaning off methods on repo instances and
moving code to core. While this function is only used once and
is simple, it needs to exist on its own so Facebook can monkeypatch
it to enable simplecache integration.
2017-07-06 12:14:12 -07:00
Gregory Szorc
2316ea9a38 sparse: move config parsing into core
This patch marks the beginning of moving code from the sparse
extension into core. The goal is to move as much of the
functionality as possible into core, where it will be an
experimental feature. The extension will likely continue to
exist to enable the feature and provide UI elements.

As part of the move, the repo method was converted to a module
function. It doesn't need to exist on repos.

An error message was also updated to reflect that an error isn't
necessarily from the .hg/sparse file. The API should be updated
later to pass in a filename so the error can be more descriptive.

Copyright of the added file was copied from the sparse extension.
2017-07-06 12:14:03 -07:00
Gregory Szorc
1db9bed779 sparse: use vfs.tryread()
vfs.exists() followed by a file read is an anti-pattern because it
incurs an extra stat() to test for file presence. vfs.tryread()
returns empty string on missing file and avoids the stat().
2017-07-06 10:58:45 -07:00
Gregory Szorc
49b16cba64 sparse: refactor sparsechecksum()
This was relying on garbage collection to close the opened
file, which is a bug. Both callers simply called into self.vfs
to resolve the path. So refactor to use the vfs layer.

While we're here, rename the method to reflect it is internal
and to break anyone relying on the old behavior.
2017-07-01 11:56:39 -07:00
Gregory Szorc
8febc1c48e sparse: document config file format
This was previously undocumented. Seems useful to have.
2017-07-06 10:57:26 -07:00
Gregory Szorc
259226f5d1 sparse: rename command to debugsparse
Sparse checkout is still highly experimental and not protected
by BC guarantees yet. We also haven't had a discussion on the UX.

To discourage use, we rename the sparse command to debugsparse.
2017-07-01 10:29:27 -07:00
Gregory Szorc
6a8520b1b6 sparse: remove reference to simplecache
This is a 3rd party extension authored by Facebook. References in
core are not appropriate.

It will be possible to restore this code/optimization via
monkeypatching. So Facebook won't lose any functionality.

The removed code is important for performance. So add a comment
tracking it.
2017-07-06 10:54:23 -07:00
Gregory Szorc
4ff8c49366 sparse: remove reference to hgwatchman
This is a legacy extension. Now that the extension is in core,
we only need to support what's in core, which is fsmonitor.
2017-07-01 10:24:31 -07:00
Gregory Szorc
6301d186f7 sparse: expand module docstring
Clarify lack of BC guarantees. And say a bit more about the extension.
2017-07-01 10:36:03 -07:00
Gregory Szorc
82b7f72254 sparse: vendor Facebook-developed extension
Facebook has developed an extension to enable "sparse" checkouts -
a working directory with a subset of files. This feature is a critical
component in enabling repositories to scale to infinite number of
files while retaining reasonable performance. It's worth noting
that sparse checkout is only one possible solution to this problem:
another is virtual filesystems that realize files on first access.
But given that virtual filesystems may not be accessible to all
users, sparse checkout is necessary as a fallback.

Per mailing list discussion at
https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-March/095868.html
we want to add sparse checkout to the Mercurial distribution via
roughly the following mechanism:

1. Vendor extension as-is with minimal modifications (this patch)
2. Refactor extension so it is more clearly experimental and inline
   with Mercurial practices
3. Move code from extension into core where possible
4. Drop experimental labeling and/or move feature into core
   after sign-off from narrow clone feature owners

This commit essentially copies the sparse extension and tests
from revision 71e0a2aeca92a4078fe1b8c76e32c88ff1929737 of the
https://bitbucket.org/facebook/hg-experimental repository.

A list of modifications made as part of vendoring is as follows:

* "EXPERIMENTAL" added to module docstring
* Imports were changed to match Mercurial style conventions
* "testedwith" value was updated to core Mercurial special value and
  comment boilerplate was inserted
* A "clone_sparse" function was renamed to "clonesparse" to appease
  the style checker
* Paths to the sparse extension in tests reflect built-in location
* test-sparse-extensions.t was renamed to test-sparse-fsmonitor.t
  and references to "simplecache" were removed. The test always skips
  because it isn't trivial to run it given the way we currently run
  fsmonitor tests
* A double empty line was removed from test-sparse-profiles.t

There are aspects of the added code that are obviously not ideal.
The goal is to make a minimal number of modifications as part of
the vendoring to make it easier to track changes from the original
implementation. Refactoring will occur in subsequent patches.
2017-07-01 10:43:29 -07:00
Pierre-Yves David
0c7dcefb43 configitems: register the 'factotum.service' config 2017-06-30 03:42:15 +02:00
Pierre-Yves David
cf658b866d configitems: register the 'factotum.mountpoint' config 2017-06-30 03:42:13 +02:00
Pierre-Yves David
5fe99bc6f6 configitems: register the 'factotum.executable' config 2017-06-30 03:42:12 +02:00
Pierre-Yves David
afaa007c67 configitem: create a new list of each 'acl.sources' access
Thanks for goes to Yuya for spotting this.
2017-07-02 23:10:33 +02:00
Gregory Szorc
42af67624f show: document why accidentally quadratic is (probably) acceptable 2017-07-03 21:26:39 -07:00
Gregory Szorc
0a3762821d show: also catch AmbiguousCommand
cmdutil.findcmd() can raise this as well. While we'll almost certainly
never encounter this in the wild, guard against it regardless.
2017-07-03 21:18:32 -07:00
Gregory Szorc
ef389a50e2 show: avoid extra list operations 2017-07-03 21:12:04 -07:00
Gregory Szorc
663cfcdd36 show: tweak warning message
'.' is "working directory parent" not "working directory."
2017-07-03 21:10:48 -07:00
Gregory Szorc
0520797e9d show: implement "stack" view
People often want to know what they are working on *now*. As part of
this, they also commonly want to know how that work is related to other
changesets in the repo so they can perform common actions like rebase,
histedit, and merge.

`hg show work` made headway into this space. However, it is geared
towards a complete repo view as opposed to just the current line of
work. If you have a lot of in-flight work or the repo has many heads,
the output can be overwhelming. The closest thing Mercurial has to
"show me the current thing I'm working on" that doesn't require custom
revsets is `hg qseries`. And this requires MQ, which completely changes
workflows and repository behavior and has horrible performance on large
repos. But as sub-optimal as MQ is, it does some things right, such as
expose a model of the repo that is easy for people to reason about.
This simplicity is why I think a lot of people prefer to use MQ, despite
its shortcomings.

One common development workflow is to author a series of linear
changesets, using bookmarks, branches, anonymous heads, or even topics
(3rd party extension). I'll call this a "stack." You periodically
rewrite history in place (using `hg histedit`) and reparent the stack
against newer changesets (using `hg rebase`). This workflow can be
difficult because there is no obvious way to quickly see the current
"stack" nor its relation to other changesets. Figuring out arguments to
`hg rebase` can be difficult and may require highlighting and pasting
multiple changeset nodes to construct a command.

The goal of this commit is to make stack based workflows simpler
by exposing a view of the current stack and its relationship to
other releant changesets, notably the parent of the base changeset
in the stack and newer heads that the stack could be rebased or merged
into.

Introduced is the `hg show stack` view. Essentially, it finds all
mutable changesets from the working directory revision in both
directions, stopping at a merge or branch point. This limits the
revisions to a DAG linear range.

The stack is rendered as a concise list of changesets. Alongside the
stack is a visualization of the DAG, similar to `hg log -G`.

Newer public heads from the branch point of the stack are rendered
above the stack. The presence of these heads helps people understand
the DAG model and the relationship between the stack and changes made
since the branch point of that stack. If the "rebase" command is
available, a `hg rebase` command is printed for each head so a user
can perform a simple copy and paste to perform a rebase.

This view is alpha quality. There are tons of TODOs documented
inline. But I think it is good enough for a first iteration.
2017-07-01 22:38:42 -07:00
Pierre-Yves David
dd58f467f2 configitems: register the 'blackbox.logsource' config 2017-06-30 03:28:18 +02:00
Pierre-Yves David
e633829f37 configitems: register the 'blackbox.dirty' config 2017-06-30 03:28:11 +02:00
Pierre-Yves David
6b8771d327 configitems: register the 'automv.similarity' config
Default value has been ported.
2017-06-30 03:27:24 +02:00
Pierre-Yves David
0554b7fad5 acl: use configlist to retrieve the source config
This is what the previous code was about.
2017-07-01 20:58:34 +02:00
Pierre-Yves David
137b284c91 configitems: register the 'acl.sources' config
The existing default value is now formally declared. It seems like the whole
config should be a list, but this is an adventure for the next changesets.
2017-06-30 03:27:07 +02:00
Pierre-Yves David
ba936f63d6 configitems: register the 'acl.config' config 2017-06-30 03:26:57 +02:00