Mercurial > hg
diff mercurial/localrepo.py @ 39849:d3d4b4b5f725
localrepo: support writing shared file (API)
Now that we can create a shared repository via creation options, we
can handle other special actions related to share at repo creation time
as well.
One of the things we do after creating a shared repository is write
out a .hg/shared file containing the list of additional things to
share. Of which only "bookmarks" is supported.
We add a creation option to hold the set of additional items to
share. If items are defined, we write out the .hg/shared file at
repo creation time.
As part of this, we no longer hold the repo lock when writing the
file. I'm pretty sure we don't care about the tiny race condition
window. I'm also pretty sure the reason we used the lock was because
the vfs auditor on the repo instance complained otherwise. Since the
repo creation code doesn't have an audited vfs, we don't need to
appease it.
Because we no longer need to tell the post share hook what items
are shared, the "bookmarks" argument to that function has been
dropped, incurring an API change.
Differential Revision: https://phab.mercurial-scm.org/D4708
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 19 Sep 2018 17:27:37 -0700 |
parents | 4ece3cdfd907 |
children | d89d5bc06eaa |
line wrap: on
line diff
--- a/mercurial/localrepo.py Wed Sep 19 17:05:59 2018 -0700 +++ b/mercurial/localrepo.py Wed Sep 19 17:27:37 2018 -0700 @@ -2786,6 +2786,7 @@ 'narrowfiles', 'sharedrepo', 'sharedrelative', + 'shareditems', } return {k: v for k, v in createopts.items() if k not in known} @@ -2806,6 +2807,8 @@ Boolean indicating if the path to the shared repo should be stored as relative. By default, the pointer to the "parent" repo is stored as an absolute path. + shareditems + Set of items to share to the new repository (in addition to storage). """ createopts = createopts or {} @@ -2867,6 +2870,10 @@ if 'sharedrepo' in createopts: hgvfs.write(b'sharedpath', sharedpath) + if createopts.get('shareditems'): + shared = b'\n'.join(sorted(createopts['shareditems'])) + b'\n' + hgvfs.write(b'shared', shared) + def poisonrepository(repo): """Poison a repository instance so it can no longer be used.""" # Perform any cleanup on the instance.