Martin von Zweigbergk <martinvonz@google.com> [Fri, 07 Aug 2020 21:59:43 -0700] rev 45350
makefile: stop setting unused HGEXTDIR variable during osx build
The variable was added in
a38ed42cd23c (osx: include chg by default,
2017-03-20), but I can't find any others references to the variable in
that commit or in any other commits.
Differential Revision: https://phab.mercurial-scm.org/D8915
Pulkit Goyal <7895pulkit@gmail.com> [Thu, 06 Aug 2020 13:51:43 +0530] rev 45349
merge: drop commitinfo argument to applyupdates (API)
We now pass the mergeresult object and hence there is no need to have a separate
commitinfo argument as the required info is present in mergeresult object.
Differential Revision: https://phab.mercurial-scm.org/D8904
Pulkit Goyal <7895pulkit@gmail.com> [Thu, 06 Aug 2020 13:27:38 +0530] rev 45348
merge: remove emptyactions() and use collections.defaultdict(list) instead
emptyactions() used to return a dict which was populated and passed into
applyupdates(). However, with recent changes, we no longer pass a plain dict,
instead we pass the mergeresult object.
There was only one usage of emptyactions and that too inside mergeresult object.
That usage is replaced with collections.defaultdict(list) instead.
Not sure why we were not using collections.defaultdict(list) from the beginning.
Differential Revision: https://phab.mercurial-scm.org/D8903
Pulkit Goyal <7895pulkit@gmail.com> [Wed, 05 Aug 2020 16:52:51 +0530] rev 45347
merge: pass mergeresult obj in _forgetremoved() (API)
Instead of returning a dict of actions and then updating it, let's pass the
object directly and update it there.
This makes `updateactions()` on mergeresult unused and this patch removes that.
After this patch, we have couple of methods left on mergeresult class which
still exposes the internal dict based action storage.
Differential Revision: https://phab.mercurial-scm.org/D8889
Pulkit Goyal <7895pulkit@gmail.com> [Wed, 05 Aug 2020 16:00:25 +0530] rev 45346
mergeresult: introduce filemap() which yields filename based mapping
We wanted to remove `actions` as this was leaking how we store things internally
and was direct access to one of the member. This introduces filemap() which
yields a map of `filename` -> `action, args, msg`.
`mergeresult.actions` has been deleted as it's no longer required.
Differential Revision: https://phab.mercurial-scm.org/D8888
Pulkit Goyal <7895pulkit@gmail.com> [Wed, 05 Aug 2020 15:41:23 +0530] rev 45345
mergeresult: add `files()` and use it
`files()` will return a list of files on which an action needs to be performed.
This is a step to stop exposing the underlying map to the user of this object.
Differential Revision: https://phab.mercurial-scm.org/D8887
Pulkit Goyal <7895pulkit@gmail.com> [Wed, 05 Aug 2020 15:37:26 +0530] rev 45344
mergeresult: introduce getfile() and use it where required
We want to hide the underlying dictionary from the users and provide API for
valid and sane use cases.
Differential Revision: https://phab.mercurial-scm.org/D8886
Pulkit Goyal <7895pulkit@gmail.com> [Wed, 05 Aug 2020 14:03:59 +0530] rev 45343
merge: use ACTION_* constants instead of values in _filternarrowactions()
It makes easier to check what noconflicttypes are and which are not included.
I hope we can have a state where we always use ACTION_* constants instead of
these values which are very hard to understand.
Differential Revision: https://phab.mercurial-scm.org/D8885
Pulkit Goyal <7895pulkit@gmail.com> [Wed, 05 Aug 2020 13:50:49 +0530] rev 45342
merge: rework iteration over mergeresult object in checkpathconflicts()
Instead of following pattern:
```
for f, (m, args, msg) in mresult.actions.items():
if m == mergestatemod.ACTION_*:
...
elif m == mergestatemod.ACTION_*:
...
....
```
We do:
```
for (f, args, msg) in mresult.getaction((mergestatemod.ACTION_*,)):
...
for (f, args, msg) in mresult.getaction((mergestatemod.ACTION_*,)):
...
....
```
This makes code bit easier to understand and prevent iterating over actions
which we don't need.
Differential Revision: https://phab.mercurial-scm.org/D8884
Pulkit Goyal <7895pulkit@gmail.com> [Wed, 05 Aug 2020 13:21:06 +0530] rev 45341
applyupdates: simplfy calculation of number of updated files
Instead of increasing the `updated` variable each time in a loop, let's use the
mergeresult object API to calculate the updated value in one call.
Differential Revision: https://phab.mercurial-scm.org/D8883
Pulkit Goyal <7895pulkit@gmail.com> [Mon, 03 Aug 2020 18:08:37 +0530] rev 45340
mergeresult: yield from getactions() instead of buidling a list and returning
Only 7 out of 29 callers change the underlying dict while iterating. So it's
better to yield and wrap the 7 callers with `list()`.
Differential Revision: https://phab.mercurial-scm.org/D8882
Pulkit Goyal <7895pulkit@gmail.com> [Mon, 03 Aug 2020 18:33:00 +0530] rev 45339
sparse: replace merge action values with mergestate.ACTION_* constants
Having bytestrings like `b'r'` makes it hard to understand for people who don't
know the code much or looking at it for the first time.
Differential Revision: https://phab.mercurial-scm.org/D8881
Pulkit Goyal <7895pulkit@gmail.com> [Mon, 03 Aug 2020 17:58:18 +0530] rev 45338
mergeresult: implement a len() function and use it
In next patch we will start yielding from `getactions()` instead of building and
returning a list. Hence we can no longer rely on that for getting us a length.
Differential Revision: https://phab.mercurial-scm.org/D8880
Pulkit Goyal <7895pulkit@gmail.com> [Mon, 03 Aug 2020 17:32:30 +0530] rev 45337
merge: replace use of actions dict with mergeresult object
There are still some places which can be improved by having a dedicated API,
this patch for now make all users of actions dict go through the mergeresult
object API.
Differential Revision: https://phab.mercurial-scm.org/D8879
Pulkit Goyal <7895pulkit@gmail.com> [Mon, 03 Aug 2020 14:54:45 +0530] rev 45336
mergeresult: add sort argument to getactions() method
This will be used in next patch.
Differential Revision: https://phab.mercurial-scm.org/D8878
Pulkit Goyal <7895pulkit@gmail.com> [Mon, 03 Aug 2020 14:19:06 +0530] rev 45335
merge: pass mergeresult obj in merge._prefetchfiles()
Differential Revision: https://phab.mercurial-scm.org/D8877
Pulkit Goyal <7895pulkit@gmail.com> [Mon, 03 Aug 2020 14:12:13 +0530] rev 45334
merge: pass mergeresult obj instead of actions in applyupdates() (API)
This is similar to past 20 patches or so where we are replacing use of a bare
actions dict with a dedicated mergeresult object. The goal is to have a
dedicated powerful object instead of a dict while making the code more easier to
understand.
In past few patches, we have already simplified the code at some places using
the newly introduced object.
This patch does not updates applyupdates() to use the mergeresult object
directly. That will be done in next patch to make things easier to review.
Differential Revision: https://phab.mercurial-scm.org/D8876
Pulkit Goyal <7895pulkit@gmail.com> [Mon, 03 Aug 2020 13:30:14 +0530] rev 45333
merge: pass mergeresult obj instead of actions in _checkcollision() (API)
The goal is to not use the actions dict and replace it with a rich mergeresult
object.
Differential Revision: https://phab.mercurial-scm.org/D8875
Pierre-Yves David <pierre-yves.david@octobus.net> [Tue, 28 Jul 2020 20:21:06 +0200] rev 45332
commitctx: directly update the touched and added set of files
Instead of going through intermediate variable, we can simply use the
ChangingFiles object. The object will take care of the consistency.
Pierre-Yves David <pierre-yves.david@octobus.net> [Tue, 28 Jul 2020 20:19:09 +0200] rev 45331
commitctx: directly updated the set of removed files
The change is non-trivial so I made it in its own changeset.
Pierre-Yves David <pierre-yves.david@octobus.net> [Wed, 29 Jul 2020 16:48:31 +0200] rev 45330
commitctx: create the `ChangingFiles` object sooner
Let us change the `_commit_manifest` call before other changes.
Pierre-Yves David <pierre-yves.david@octobus.net> [Sat, 25 Jul 2020 16:34:02 +0200] rev 45329
commitctx: move ChangingFiles creation directly inside `_process_files`
As announced, we move it there. We focus on the signature change first, we will
update the code afterward.
Pierre-Yves David <pierre-yves.david@octobus.net> [Sat, 25 Jul 2020 16:13:32 +0200] rev 45328
commitctx: create the ChangingFiles object directly in the various case
No need to compute all data then create the object, we can create it early and
directly store data in it. We start simple by moving create higher in the
function, but the end goal is to eventually move the creation inside the
`_process_files` function to take advantage of the object there.
Pierre-Yves David <pierre-yves.david@octobus.net> [Sat, 25 Jul 2020 16:13:17 +0200] rev 45327
commitctx: no longer make the storage and added/removed file optional
The code using this variable is always using other, stricter, condition before
using these value. So it is safe to always carry them along.
Pierre-Yves David <pierre-yves.david@octobus.net> [Sat, 25 Jul 2020 16:07:38 +0200] rev 45326
commitctx: directly gather p1 and p2 copies in `files`
The only thing we do with the p1copies and p2copies is to pass them around, we
we can gather them later and directly stored them in the `ChangingFiles` object.
Pierre-Yves David <pierre-yves.david@octobus.net> [Sat, 25 Jul 2020 16:02:26 +0200] rev 45325
commitctx: extract sidedata encoding inside its own function
This part of the code is quite independent from the rest. Thank to the new
ChangingFiles object, moving with the rest of the sidedata code (in metadata.py)
is simple.
The changelog.add method is simply passing the `files` object to the new
function. It will be easy to increase/change the data we gather and encode
without impacting the changelog method.
Pierre-Yves David <pierre-yves.david@octobus.net> [Sat, 25 Jul 2020 15:55:09 +0200] rev 45324
commitctx: directly pass a ChangingFiles object to changelog.add
We pass the rich object to the changelog and it read the field it needs.
Pierre-Yves David <pierre-yves.david@octobus.net> [Sat, 25 Jul 2020 15:49:12 +0200] rev 45323
commitctx: return a richer object from _prepare_files
Instead of returning a lot of different list, we introduce a rich object that
hold all the file related information. The unique object help with data
consistency and simply functions arguments and return.
In the rest of this series we will increase usage of this object to simplify
more code.
Martin von Zweigbergk <martinvonz@google.com> [Thu, 06 Aug 2020 10:53:00 -0700] rev 45322
templater: teach template loader to use open_template() function
The template loader can apparently load templates from relative paths,
so I needed to add that support to `open_template()`.
This takes the number of failing tests with PyOxidizer from 54 to 34.
Differential Revision: https://phab.mercurial-scm.org/D8907
Martin von Zweigbergk <martinvonz@google.com> [Thu, 06 Aug 2020 10:52:52 -0700] rev 45321
templater: restructure open_template() a little to prepare for relative paths
I found that it was easier to add support for relative paths after
this restructuring. It also made it easier to explain each case with a
code comment (which I did).
Differential Revision: https://phab.mercurial-scm.org/D8906
Martin von Zweigbergk <martinvonz@google.com> [Thu, 06 Aug 2020 09:50:10 -0700] rev 45320
templater: add exception-raising version of open_template()
I'm about to add another caller of `open_template()` (in the template
loader). That caller will want to get exceptions instead of `(None,
None)` if the template doesn't exist. This patch therefore changes
`open_template()` to raise exceptions and adds a new
`try_open_template()` that returns the `(None, None)` value.
Differential Revision: https://phab.mercurial-scm.org/D8905
Martin von Zweigbergk <martinvonz@google.com> [Wed, 05 Aug 2020 22:13:51 -0700] rev 45319
templater: replace Py3-only exception types by super-types available in Py2
As noted by @indygreg, `test-check-pyflakes.t` started failing on Py2
after my recent D8894, because that introduced catching of the
Py3-only types `ModuleNotFoundError` and `FileNotFoundError`. Let's
switch to less precise types that are also available in Py2.
Differential Revision: https://phab.mercurial-scm.org/D8902
Martin von Zweigbergk <martinvonz@google.com> [Wed, 05 Aug 2020 14:19:42 -0700] rev 45318
hgweb: enable reading styles from resources in frozen binaries
All we need to do to read styles from resources is to pass the
file-like object we get from `open_template()` on to `frommapfile()`.
This takes the number of failing tests with PyOxidizer from 62 to 54.
Differential Revision: https://phab.mercurial-scm.org/D8901
Martin von Zweigbergk <martinvonz@google.com> [Wed, 05 Aug 2020 14:03:45 -0700] rev 45317
hgweb: rely on open_template()'s fallback to using templatedir()
Differential Revision: https://phab.mercurial-scm.org/D8900
Martin von Zweigbergk <martinvonz@google.com> [Wed, 05 Aug 2020 14:03:14 -0700] rev 45316
hgweb: open mapfile using templater.open_template()
This will help us read templates from resources in frozen binaries.
Differential Revision: https://phab.mercurial-scm.org/D8899
Martin von Zweigbergk <martinvonz@google.com> [Wed, 05 Aug 2020 13:58:30 -0700] rev 45315
hgweb: simplify a constant-length list by converting to literal tuple
The call to `.append()` has been unnecessary since
d3dbdca92458
(hgweb: don't choke when an inexistent style is requested (
issue1901),
2009-11-12).
Differential Revision: https://phab.mercurial-scm.org/D8898
Martin von Zweigbergk <martinvonz@google.com> [Wed, 05 Aug 2020 13:33:07 -0700] rev 45314
hgweb: remove some accesses to private member uimod._unset
Differential Revision: https://phab.mercurial-scm.org/D8897
Martin von Zweigbergk <martinvonz@google.com> [Thu, 30 Jul 2020 21:36:29 -0700] rev 45313
templater: try to read %include in mapfiles from resources
The "show" style is an example of a style that uses an "%include"
statement in its definition. This patch makes `hg log --style show`
work.
This takes the number of failing tests with PyOxidizer from 72 to 62.
Differential Revision: https://phab.mercurial-scm.org/D8896
Martin von Zweigbergk <martinvonz@google.com> [Thu, 30 Jul 2020 15:29:06 -0700] rev 45312
templater: unroll loop over mapfile directories
I'll rewrite the handling of the `templatedir()` case in the next
patch, so the two cases will be more different and the loop won't make
as much sense.
Differential Revision: https://phab.mercurial-scm.org/D8895
Martin von Zweigbergk <martinvonz@google.com> [Tue, 04 Aug 2020 10:51:25 -0700] rev 45311
templater: make open_template() read from resources if in frozen binary
This takes the number of failing tests with PyOxidizer from 87 to 72.
Differential Revision: https://phab.mercurial-scm.org/D8894
Martin von Zweigbergk <martinvonz@google.com> [Tue, 04 Aug 2020 13:22:00 -0700] rev 45310
templater: pass opened file-like object to templatespec
I think I said earlier that I planned to create a special templatespec
variant for built-in templates. That was true (I planned that), but I
ended up (in this patch) just adding a file-like object to the
`mapfile_templatespec()` variant instead.
Differential Revision: https://phab.mercurial-scm.org/D8893
Martin von Zweigbergk <martinvonz@google.com> [Tue, 04 Aug 2020 13:21:29 -0700] rev 45309
templater: replace templatepath() with function that also opens the file
For frozen binaries, such as those created by PyOxidizer, I plan to
make it so the templatespec can keep an opened file/resource to read
from instead of needing a file path. Having `templatepath()` return an
opened file should help with that. At this point, it's just a wasteful
extra opening of mapfiles that we'll open again later. I'll update the
read-side next so it reads from the file-like object without opening
the file again.
Differential Revision: https://phab.mercurial-scm.org/D8892
Martin von Zweigbergk <martinvonz@google.com> [Thu, 30 Jul 2020 13:44:06 -0700] rev 45308
templater: start passing resource to read from into _readmapfile()
This patch makes it so we pass in a file-like resource to read from
instead of having `_readmapfile()` open the file. This is one more
step towards making `_readmapfile()` able to read resources opened by
from `importlib.resources`. We still need to pass in the mapfile path
because it's used for loading dependent mapfiles from `%include` and
`__base__`, and it's also used for giving the user better error
messages. Besides that, one can safely call `_readmapfile()` with any
file-like resource after this patch.
Differential Revision: https://phab.mercurial-scm.org/D8891
Martin von Zweigbergk <martinvonz@google.com> [Tue, 04 Aug 2020 09:13:10 -0700] rev 45307
templater: move stylemap() to hgweb_mod, since that's its only user
`stylemap()` even has an error message that mentions "hgweb
templates", so it seems that it's meant specifically for hgweb.
Differential Revision: https://phab.mercurial-scm.org/D8890
Martin von Zweigbergk <martinvonz@google.com> [Mon, 03 Aug 2020 22:15:45 -0700] rev 45306
hgweb: simplify staticfile() now that we always pass it a single directory
I didn't realize this further simplifications enabled by D8786 until
now.
Differential Revision: https://phab.mercurial-scm.org/D8874
Martin von Zweigbergk <martinvonz@google.com> [Fri, 31 Jul 2020 10:05:07 -0700] rev 45305
packaging: include templates with their package as key in package_data
This is similar to an earlier patch in this series. It seems more
correct to use `mercurial.templates.coal` etc as keys in the
`package_data` dict now that those modules are packages.
Differential Revision: https://phab.mercurial-scm.org/D8858
Martin von Zweigbergk <martinvonz@google.com> [Fri, 31 Jul 2020 09:49:52 -0700] rev 45304
packaging: mark mercurial.templates and subdirs as packages
We need these packages to be installed so PyOxidizer picks them up.
Differential Revision: https://phab.mercurial-scm.org/D8855
Martin von Zweigbergk <martinvonz@google.com> [Thu, 12 Dec 2019 12:41:01 -0800] rev 45303
templates: add __init__.py files to templates/ dirs
This is necessary for them to be loaded with `importlib.resources`,
which we want to do for PyOxidizer and similar. `importlib.resources`
cannot read resources from submodules
(`resources.open_binary('mercurial.templates', 'coal/map')` is not
valid), so we need one `__init__.py` per directory.
Differential Revision: https://phab.mercurial-scm.org/D8854
Augie Fackler <augie@google.com> [Wed, 05 Aug 2020 13:36:50 -0400] rev 45302
merge with stable
Pulkit Goyal <7895pulkit@gmail.com> [Tue, 21 Jul 2020 18:21:27 +0530] rev 45301
localrepo: abort creating a shared repo if the source does not have store
We cannot create a shared repository without a store IIUC. Let's abort in such
cases.
Differential Revision: https://phab.mercurial-scm.org/D8772
Pulkit Goyal <7895pulkit@gmail.com> [Tue, 21 Jul 2020 13:58:58 +0530] rev 45300
localrepo: only use 'bookmarksinstore' requirement if we have 'store'
This adds check that whether we have the 'store' requirement or not. If we don't
have that, we skip adding the 'bookmarksinstore' requirement and warn user about
it.
Differential Revision: https://phab.mercurial-scm.org/D8771
Pulkit Goyal <7895pulkit@gmail.com> [Sat, 25 Jul 2020 01:42:41 +0530] rev 45299
mergeresult: make actionmapping a dict of dict instead of dict of lists
This makes deleting a specific filename entry faster and easier.
Differential Revision: https://phab.mercurial-scm.org/D8837
Pulkit Goyal <7895pulkit@gmail.com> [Sat, 25 Jul 2020 14:44:29 +0530] rev 45298
largefiles: introduce a constant for 'lfmr' action
It's better to use a dedicated constant instead of a string which makes pretty
less sense.
Differential Revision: https://phab.mercurial-scm.org/D8836
Pulkit Goyal <7895pulkit@gmail.com> [Sat, 25 Jul 2020 14:41:20 +0530] rev 45297
largefiles: override merge.emptyactions() to include `lfmr`
I found it weird that we were not already doing this. I encountered this while
using `emptyactions()` in mergeresult() class.
Differential Revision: https://phab.mercurial-scm.org/D8835
Pulkit Goyal <7895pulkit@gmail.com> [Sat, 25 Jul 2020 01:17:35 +0530] rev 45296
merge: unify logic of couple of if-else's in manifestmerge()
Right now manifestmerge() contains very nested if-else conditions and it's not
easy to understand what is happening. I was looking for easy unifications and
found these two.
Differential Revision: https://phab.mercurial-scm.org/D8834
Pulkit Goyal <7895pulkit@gmail.com> [Fri, 24 Jul 2020 23:49:08 +0530] rev 45295
sparse: add comment for an if condition which I tried to refactor
I tried to refactor this if condition and make it part of the if-else above but
tests failed. I decided to add a comment about the check we are doing and why
it's a separate if.
Differential Revision: https://phab.mercurial-scm.org/D8833
Pulkit Goyal <7895pulkit@gmail.com> [Fri, 24 Jul 2020 23:40:07 +0530] rev 45294
mergeactions: use action constants instead of string values
Having constants inplace of strings like 'c', 'cm' etc. makes it easier to
understand the code.
Differential Revision: https://phab.mercurial-scm.org/D8832
Pulkit Goyal <7895pulkit@gmail.com> [Sun, 02 Aug 2020 10:24:28 -0700] rev 45293
merge: use the new action based mapping introduced in mergeresult obj
Before this patch, we have good number of instances of following types:
```
for f, (m, args, msg) in mresult.actions:
if m == ACTION_X:
do_something
```
We iterate over the whole list and then filter for a certain action. Previous
patch introduced a action based mapping in mergeresult object. The above code
now looks like:
```
for f, args, msg in mresult.getactions([ACTION_X, ...]):
do_something
```
Differential Revision: https://phab.mercurial-scm.org/D8831
Pulkit Goyal <7895pulkit@gmail.com> [Fri, 24 Jul 2020 19:48:38 +0530] rev 45292
mergeresult: introduce action -> (filename, data, msg) mapping and related API
Good number of places in code, we iterate over the actions dict which has
filename as keys and filter based on the action.
This patch introduced another mapping which has action as key. This will help in
refactoring the code much more in upcoming patch.
Differential Revision: https://phab.mercurial-scm.org/D8830
Pulkit Goyal <7895pulkit@gmail.com> [Sun, 02 Aug 2020 10:15:55 -0700] rev 45291
mergeresult: rename _actions to _filemapping
This is done because we will be introducing another dict which introduces the
same information but with action name as key.
Differential Revision: https://phab.mercurial-scm.org/D8829