Martin von Zweigbergk <martinvonz@google.com> [Tue, 04 Aug 2020 13:22:00 -0700] rev 45331
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 45330
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 45329
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 45328
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 45327
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 45326
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 45325
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 45324
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 45323
merge with stable
Pulkit Goyal <7895pulkit@gmail.com> [Tue, 21 Jul 2020 18:21:27 +0530] rev 45322
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 45321
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 45320
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 45319
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 45318
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 45317
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 45316
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 45315
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 45314
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 45313
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 45312
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
Pulkit Goyal <7895pulkit@gmail.com> [Fri, 24 Jul 2020 19:19:47 +0530] rev 45311
sparse: pass mergeresult obj in sparse.filterupdatesactions() (API)
Not able to see much which can be improved in this function by passing in
mergeresult object but for API consistency and no function directly touching
actions dict, it sounds like a good idea.
Differential Revision: https://phab.mercurial-scm.org/D8828
Pulkit Goyal <7895pulkit@gmail.com> [Fri, 24 Jul 2020 19:13:20 +0530] rev 45310
merge: filter actions before calling _resolvetrivial()
In d49e490a9e85252886fd43258803bcad4fc88edb I made _resolvetrivial() to be
called after upadting the sparse checkout.
Looking at the code now, it seems to that me there is no need to even run
_resolvetrivial() on actions which are filtered away.
So let's update the actions before passing them into _resolvetrivial().
Differential Revision: https://phab.mercurial-scm.org/D8827
Pulkit Goyal <7895pulkit@gmail.com> [Fri, 24 Jul 2020 18:16:29 +0530] rev 45309
merge: introduce mergeresult.updateactions() and use it
We don't want direct editing and access of mergeresult._actions because soon we
will like to maintain data in other structures also.
Differential Revision: https://phab.mercurial-scm.org/D8826
Pulkit Goyal <7895pulkit@gmail.com> [Fri, 24 Jul 2020 17:57:23 +0530] rev 45308
merge: pass mergeresult instead of actions in _checkunknownfiles() (API)
Differential Revision: https://phab.mercurial-scm.org/D8825
Pulkit Goyal <7895pulkit@gmail.com> [Fri, 24 Jul 2020 17:52:33 +0530] rev 45307
merge: pass mergeresult obj instead of actions dict in _resolvetrivial()
Differential Revision: https://phab.mercurial-scm.org/D8824
Pulkit Goyal <7895pulkit@gmail.com> [Fri, 24 Jul 2020 17:49:13 +0530] rev 45306
merge: pass mergeresult obj instead of actions in _filternarrowactions()
We want to use rich mergeresult object and it's APIs instead of handling a
dictionary.
Differential Revision: https://phab.mercurial-scm.org/D8823
Pulkit Goyal <7895pulkit@gmail.com> [Fri, 24 Jul 2020 17:31:26 +0530] rev 45305
merge: pass mergeresult in checkpassconflicts() instead of actions (API)
This is a part of series which aims to use mergeresult obj instead of an action
dictionary.
Differential Revision: https://phab.mercurial-scm.org/D8822
Pulkit Goyal <7895pulkit@gmail.com> [Fri, 24 Jul 2020 16:23:55 +0530] rev 45304
merge: add removefile() to mergeresult object
There are cases where some further calculation makes the file not needing to be
merged anymore and hence needs to be dropped in mergeresult object. This adds a
function for that.
Differential Revision: https://phab.mercurial-scm.org/D8821
Pulkit Goyal <7895pulkit@gmail.com> [Fri, 24 Jul 2020 16:18:39 +0530] rev 45303
merge: introduce mergeresult.addfile() and use it
We want to use mergeresult object at more and more places instead of this
actions dict to simplify code and further add new APIs to mergeresult object.
This patch introduces `addfile()` which adds a new file to the internal actions
dict for now.
Differential Revision: https://phab.mercurial-scm.org/D8820
Pulkit Goyal <7895pulkit@gmail.com> [Fri, 24 Jul 2020 15:56:11 +0530] rev 45302
merge: make mergeresult constructor initialize empty object
In future patches, we will be going to update mergeresult object
instead of building an actions dict and then setting it in the object.
Differential Revision: https://phab.mercurial-scm.org/D8819