Martin von Zweigbergk <martinvonz@google.com> [Thu, 17 Sep 2020 23:12:48 -0700] rev 45511
mergestate: make in-memory mergestate not clear on-disk mergestate on reset()
Oops, I thought I had remove the `rmtree()` call earlier. Maybe I
accidentally got it back in a histedit or something.
Differential Revision: https://phab.mercurial-scm.org/D9042
Martin von Zweigbergk <martinvonz@google.com> [Tue, 15 Sep 2020 16:10:16 -0700] rev 45510
merge: use in-memory mergestate when using in-memory context
This is my version of Augie's D8568. It makes it so we don't touch the
mergestate on disk when using an in-memory context.
The reason that I want this is not the same as the reason that Augie
write his patch (though I agree with that reason too). My hope is to
make in-memory rebase not fall back to on-disk rebase when there are
conflict. I plan to do that by adding a
`overlayworkingctx.reflect_in_workingcopy()`. The idea is that that
will update the working copy, the dirstate and the mergestate as
necessary.
Differential Revision: https://phab.mercurial-scm.org/D9040
Martin von Zweigbergk <martinvonz@google.com> [Tue, 15 Sep 2020 11:17:24 -0700] rev 45509
mergestate: extract a base class to be shared by future memmergestate
This extracts a new base class from `mergestate` and leaves all the
vfs-touching code in `mergestate`.
Differential Revision: https://phab.mercurial-scm.org/D9039
Martin von Zweigbergk <martinvonz@google.com> [Tue, 15 Sep 2020 11:33:26 -0700] rev 45508
mergestate: extract overridable methods for making/restoring file backups
In-memory merge currently still uses on-disk mergestate. That's mostly
harmless (I don't think I've seen any problem it's actually
caused). It's still a little weird. I'm planning to add an in-memory
mergestate, which will be used with `overlayworkingctx`. This patch
prepares for that by extracting that logic, so it's easier to change
per subclass.
Differential Revision: https://phab.mercurial-scm.org/D9038
Martin von Zweigbergk <martinvonz@google.com> [Wed, 16 Sep 2020 13:39:26 -0700] rev 45507
mergestate: initialize all properties in __init__()
This is hopefully not very controverial. I found the initialization
before this patch unorthodox. It wasn't clear which properties the
object was supposed to have.
Differential Revision: https://phab.mercurial-scm.org/D9037
Martin von Zweigbergk <martinvonz@google.com> [Thu, 17 Sep 2020 19:33:55 -0700] rev 45506
mergestate: remove unnecessary clearing of `localctx` and `otherctx`
As noted in the previous commit, there are no callers that (re-)use
the instance after calling `reset()`. There are also no callers that
call `_read()` after doing anything with the instance (it's only
called right after an instance is created).
If reviewers feel that this is too risky, I can extract and reuse the
poisoning code that indygreg once added for poisining repo instances.
Differential Revision: https://phab.mercurial-scm.org/D9036
Martin von Zweigbergk <martinvonz@google.com> [Wed, 16 Sep 2020 13:25:49 -0700] rev 45505
mergestate: move most of of reset() into start()
`ms.reset()` has somehow become a combination of two different things:
1. A constructor-like function creating an empty instance
2. A call to `shutil.rmtree()` to clear the mergestate.
It seems that all callers now care only about the latter (since we
changed one caller to use the new `ms.start()` method instead). Let's
move the code for the former into `start()`, since that's the only
place it's needed.
Differential Revision: https://phab.mercurial-scm.org/D9035
Martin von Zweigbergk <martinvonz@google.com> [Thu, 17 Sep 2020 09:23:21 -0700] rev 45504
mergestate: make clean() only be about creating a clean mergestate
This is similar to the previous patch, but moves the separation one
step further out, to `merge.py`.
Differential Revision: https://phab.mercurial-scm.org/D9034
Martin von Zweigbergk <martinvonz@google.com> [Wed, 16 Sep 2020 10:09:37 -0700] rev 45503
mergestate: split up reset() for its two use cases
We only have one place that calls `ms.reset()` with any
arguments. That place is `mergestate.clean()`. The callers that call
the function with no arguments seem to all just want delete the
mergestate -- none of them look at the instance after calling
`reset()`. Let's separate out the two different use cases to make the
code clearer. I'll clean up further soon.
Differential Revision: https://phab.mercurial-scm.org/D9033
Martin von Zweigbergk <martinvonz@google.com> [Tue, 15 Sep 2020 23:19:14 -0700] rev 45502
mergestate: simplify reset(), knowing that `other` and `node` go together
There's only one caller of `reset()` that passes any arguments at all,
and that originates from `merge.py:1371`. That code always passes
values for both `node` and `other`.
Differential Revision: https://phab.mercurial-scm.org/D9032
Martin von Zweigbergk <martinvonz@google.com> [Tue, 15 Sep 2020 22:40:26 -0700] rev 45501
mergestate: make some callers not pass pointless node argument
The node argument is set on the created `mergestate` instance, but
these callers don't even look at that instance.
Differential Revision: https://phab.mercurial-scm.org/D9031
Martin von Zweigbergk <martinvonz@google.com> [Thu, 17 Sep 2020 09:56:05 -0700] rev 45500
py3: don't risk passing a None value to error.ManifestLookupError()
This makes the test case added in 20dd2a259b0f (test-grep: add tests
for --follow with/without --diff and/or paths, 2020-09-11) pass on
Python 3.
Differential Revision: https://phab.mercurial-scm.org/D9030
Pulkit Goyal <7895pulkit@gmail.com> [Thu, 03 Sep 2020 13:25:29 +0530] rev 45499
merge: move initial handling of mergeactions near to later one
We build `mergeactions` in the beginning and use it in end. Let's build it just
before where it will be used. Helps making code much easier to understand.
Differential Revision: https://phab.mercurial-scm.org/D8983
Pulkit Goyal <7895pulkit@gmail.com> [Thu, 25 Jun 2020 13:16:55 +0530] rev 45498
upgrade: support running upgrade if repository has share-safe requirement
This helps us in testing changing requirements of source repository and checking
that the shared repository works.
Differential Revision: https://phab.mercurial-scm.org/D8660
Pulkit Goyal <7895pulkit@gmail.com> [Thu, 17 Sep 2020 18:49:57 -0700] rev 45497
config: add `--shared` flag to edit config file of shared source
With `format.exp-share-safe` enabled, we now read the `.hg/hgrc` of the shared
source also.
This patch adds `--shared` flag to `hg config` command which can be used to edit
that shared source config file. It only works if the repository is shared one
and is shared using the safe method.
Differential Revision: https://phab.mercurial-scm.org/D8659
Pulkit Goyal <7895pulkit@gmail.com> [Thu, 02 Jul 2020 16:23:36 +0530] rev 45496
localrepo: load the share source .hg/hgrc also in share-safe mode (API)
The second part of the Share Safe Plan is to share source repo config also.
This patch adds logic to load the source repo .hg/hgrc if we are in share safe
mode. On unshare, we copy and prepend source config to current repo so that
config which was shared is persisted.
A test is added to show that now if we enable a hook on the source repo, that
also runs on the shared repositories.
API change as a new optional argument sharedvfs added to localrepo.loadhgrc()
Differential Revision: https://phab.mercurial-scm.org/D8656
Pulkit Goyal <7895pulkit@gmail.com> [Fri, 07 Aug 2020 17:42:15 +0530] rev 45495
helptext: document exp-sharesafe in internals/requirements.txt
`exp-sharesafe` is a new requirement and we should document it.
Differential Revision: https://phab.mercurial-scm.org/D8914
Pulkit Goyal <7895pulkit@gmail.com> [Tue, 14 Apr 2020 21:07:09 +0530] rev 45494
share: introduce config option to store requires in .hg/store
This introduces a config option which enabled stores the requirements on a
repository in store instead.
When enabled, `.hg/requires` will contain the `share-safe` requirement which
marks that the requirements are present in the store.
This is done so that repository requirements can be shared with shares made
using `hg share` command.
After this patch, `hg share` checks whether the source repository has
share-safe requirement, if yes, it does not copy the requirements.
Test for the new functionality is added and a test case in exitsing share tests
is also added.
Differential Revision: https://phab.mercurial-scm.org/D8633
Pulkit Goyal <7895pulkit@gmail.com> [Fri, 07 Aug 2020 16:11:19 +0530] rev 45493
scmutil: introduce filterrequirements() to split reqs into wc and store ones
In upcoming patches where we try to implement requirements in store, we will
need a mechanism to split all requirements on some basis and decide which one
goes to `.hg/requires` and which one goes to `.hg/store/requires`.
This patch introduce a separate function for that. Filtering logic for now is
put under an `if False:`. In upcoming patches it will be removed.
Differential Revision: https://phab.mercurial-scm.org/D8913
Pulkit Goyal <7895pulkit@gmail.com> [Thu, 17 Sep 2020 18:28:53 -0700] rev 45492
remotefilelog: acquire lock before writing requirements on clone
Performing a shallow clone in remotefilelog does not acquire lock. This leads to
following warning when we try to write some requirements in store:
```
--- /home/gps/src/hg-committed/tests/test-remotefilelog-share.t
+++ /home/gps/src/hg-committed/tests/test-remotefilelog-share.t#safe.err
@@ -28,6 +28,7 @@
$ hgcloneshallow ssh://user@dummy/master source --noupdate -q
+ devel-warn: write with no lock: "requires" at: /home/gps/src/hg-committed/mercurial/scmutil.py:1505 (writerequires)
$ hg share source dest
updating working directory
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
```
Let's lock before writing the requirements file.
Another solution which I can think of is not warn about missing lock when
writing to requires file in store.
Differential Revision: https://phab.mercurial-scm.org/D8952
Yuya Nishihara <yuya@tcha.org> [Thu, 10 Sep 2020 14:23:12 +0900] rev 45491
grep: make -frREV follow history from the specified revision (BC)
This is close to what "log -frREV" will do, and is backported from
8b4b9ee6001a, "log: make -fr show complete history from the given revs"
except for the "del opts['follow']" bit.
I'm planning to rewrite cmdutil.walkchangerevs() to share the core logic
with logcmdutil, and this is the first step towards that. There are still
many broken tests, but the fundamental behavior should be fixed by this
patch.
.. bc::
`hg grep -fr REV` now follows history from the specified `REV`, works in
the same way as `hg log -fr REV`. The previous behavior was to limit
the search space to `REV` while following the history.
Yuya Nishihara <yuya@tcha.org> [Fri, 11 Sep 2020 18:33:41 +0900] rev 45490
cmdutil: make walkchangerevs() gracefully handle wdir parents
This code will be completely rewritten, but test-grep.t would fail without
fixing it.
Yuya Nishihara <yuya@tcha.org> [Thu, 10 Sep 2020 13:30:34 +0900] rev 45489
grep: fix --follow with no --diff nor --rev to not fall back to plain grep
Before, "grep --follow" would only print matches in the working directory.
Since --follow is the option to specify the search space, it should disable
the plain (i.e. wdir) grep.
Yuya Nishihara <yuya@tcha.org> [Fri, 11 Sep 2020 12:39:45 +0900] rev 45488
test-grep: add tests for --follow with/without --diff and/or paths
This tests the behavior of cmdutil.walkchangerevs().
I'm going to rewrite cmdutil.walkchangerevs() to leverage the "log -f"
logic, but the code coverage looked quite small. And the history traversal
of "grep -f" goes wrong in various ways.
Yuya Nishihara <yuya@tcha.org> [Thu, 10 Sep 2020 13:10:53 +0900] rev 45487
grep: clarify that --all works exactly the same way as --diff
7fbb5d76c555 "grep: add --diff flag" says as such, but the help strings
have diverged since, and it's getting fuzzier what this --all will do.
"Stephane" <stephane@yaal.fr> [Thu, 17 Sep 2020 15:34:13 +0200] rev 45486
churn: add an usage example in docstring
Pulkit Goyal <7895pulkit@gmail.com> [Thu, 17 Sep 2020 15:47:19 +0530] rev 45485
tests: run test-check-py3-compat only in pure python mode
This test was added few years ago to detect syntax and import related warnings
and kickstart the python-3 porting efforts. It tries to parse the ast and import
the module.
When using in strict modes like `HGMODULEPOLICY=rust` or `HGMODULEPOLICY=c`, the
test fails. Let's run the test only on pure python mode.
We now have full test suite being run with python 3 and some people even use hg
with python 3 in production (like me).
Yuya Nishihara <yuya@tcha.org> [Sat, 12 Sep 2020 07:23:47 +0900] rev 45484
log: make -frREV PATH detect missing files before falling back to slow path
If -rREV isn't specified, "log --follow" would abort on nonexistent paths.
Let's implement this behavior for "-frREV" case as we have ctx.hasdir() now.
Otherwise "log -frREV PATH" would silently fall back to slow path and files
wouldn't be followed across renames.
The loop is quadratic (as before), but the size of the startctxs and
match.files() should be small in general.
Some tests are marked as BROKEN since file renames aren't tracked in the
slow path. This is a known limitation of the current history traversal
function.
Yuya Nishihara <yuya@tcha.org> [Fri, 11 Sep 2020 15:13:35 +0900] rev 45483
log: fix -fr'wdir()' PATH to follow newly added file
Testing filelog doesn't make sense in this case because the file existence
is tested against the specified changectxs. If the filelog is empty and
if startctxs != [wctx], 'f not in c' should be triggered.
Yuya Nishihara <yuya@tcha.org> [Fri, 11 Sep 2020 15:08:58 +0900] rev 45482
log: reorganize if-else and for loop in logcmdutil._makematcher()
The test conditions are branchy depending on --follow and --rev options,
so it should be better to switch first by --follow --rev.
Note that revs is not empty so "if follow and startctxs" can be replaced
with "if follow and opts.get(b'rev')".