Mercurial > hg
annotate hgext/share.py @ 52293:77b38c86915d
ci: add a small script one can run to purge older pipeline
We have over ten thousands old pipeline that take a huge space and that I
suspect to be the source of some slowdown in merge request.
However it seems that the only way to clear them is manually and through the
API, so lets do it.
The script was run today.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 12 Nov 2024 12:45:23 +0100 |
parents | f4733654f144 |
children |
rev | line source |
---|---|
46819
d4ba4d51f85f
contributor: change mentions of mpm to olivia
Raphaël Gomès <rgomes@octobus.net>
parents:
46082
diff
changeset
|
1 # Copyright 2006, 2007 Olivia Mackall <olivia@selenic.com> |
8801
28eaf6f8abce
share: add experimental share extension
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
2 # |
28eaf6f8abce
share: add experimental share extension
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
3 # This software may be used and distributed according to the terms of the |
10263 | 4 # GNU General Public License version 2 or any later version. |
8801
28eaf6f8abce
share: add experimental share extension
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
5 |
25761
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
6 '''share a common history between several working directories |
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
7 |
44979
2fd8a8c11273
share: provide a more useful text for hg help
Joerg Sonnenberger <joerg@bec.de>
parents:
43506
diff
changeset
|
8 The share extension introduces a new command :hg:`share` to create a new |
2fd8a8c11273
share: provide a more useful text for hg help
Joerg Sonnenberger <joerg@bec.de>
parents:
43506
diff
changeset
|
9 working directory. This is similar to :hg:`clone`, but doesn't involve |
2fd8a8c11273
share: provide a more useful text for hg help
Joerg Sonnenberger <joerg@bec.de>
parents:
43506
diff
changeset
|
10 copying or linking the storage of the repository. This allows working on |
2fd8a8c11273
share: provide a more useful text for hg help
Joerg Sonnenberger <joerg@bec.de>
parents:
43506
diff
changeset
|
11 different branches or changes in parallel without the associated cost in |
2fd8a8c11273
share: provide a more useful text for hg help
Joerg Sonnenberger <joerg@bec.de>
parents:
43506
diff
changeset
|
12 terms of disk space. |
2fd8a8c11273
share: provide a more useful text for hg help
Joerg Sonnenberger <joerg@bec.de>
parents:
43506
diff
changeset
|
13 |
2fd8a8c11273
share: provide a more useful text for hg help
Joerg Sonnenberger <joerg@bec.de>
parents:
43506
diff
changeset
|
14 Note: destructive operations or extensions like :hg:`rollback` should be |
2fd8a8c11273
share: provide a more useful text for hg help
Joerg Sonnenberger <joerg@bec.de>
parents:
43506
diff
changeset
|
15 used with care as they can result in confusing problems. |
2fd8a8c11273
share: provide a more useful text for hg help
Joerg Sonnenberger <joerg@bec.de>
parents:
43506
diff
changeset
|
16 |
25761
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
17 Automatic Pooled Storage for Clones |
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
18 ----------------------------------- |
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
19 |
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
20 When this extension is active, :hg:`clone` can be configured to |
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
21 automatically share/pool storage across multiple clones. This |
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
22 mode effectively converts :hg:`clone` to :hg:`clone` + :hg:`share`. |
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
23 The benefit of using this mode is the automatic management of |
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
24 store paths and intelligent pooling of related repositories. |
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
25 |
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
26 The following ``share.`` config options influence this feature: |
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
27 |
25851
bf3d10f0c34a
share: make option docs more check-config friendly
Matt Mackall <mpm@selenic.com>
parents:
25761
diff
changeset
|
28 ``share.pool`` |
25761
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
29 Filesystem path where shared repository data will be stored. When |
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
30 defined, :hg:`clone` will automatically use shared repository |
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
31 storage instead of creating a store inside each clone. |
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
32 |
25851
bf3d10f0c34a
share: make option docs more check-config friendly
Matt Mackall <mpm@selenic.com>
parents:
25761
diff
changeset
|
33 ``share.poolnaming`` |
25761
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
34 How directory names in ``share.pool`` are constructed. |
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
35 |
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
36 "identity" means the name is derived from the first changeset in the |
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
37 repository. In this mode, different remotes share storage if their |
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
38 root/initial changeset is identical. In this mode, the local shared |
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
39 repository is an aggregate of all encountered remote repositories. |
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
40 |
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
41 "remote" means the name is derived from the source repository's |
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
42 path or URL. In this mode, storage is only shared if the path or URL |
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
43 requested in the :hg:`clone` command matches exactly to a repository |
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
44 that was cloned before. |
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
45 |
34948
ff178743e59b
help: minor copy editing for grammar
Matt Harbison <matt_harbison@yahoo.com>
parents:
34878
diff
changeset
|
46 The default naming mode is "identity". |
46006
91425656e2b1
share: add documentation about share-safe mode in `hg help -e share`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45942
diff
changeset
|
47 |
91425656e2b1
share: add documentation about share-safe mode in `hg help -e share`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45942
diff
changeset
|
48 .. container:: verbose |
91425656e2b1
share: add documentation about share-safe mode in `hg help -e share`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45942
diff
changeset
|
49 |
46082
c80f9e3daec3
share: remove unexpected heading from "verbose" container in help test
Martin von Zweigbergk <martinvonz@google.com>
parents:
46006
diff
changeset
|
50 Sharing requirements and configs of source repository with shares: |
46006
91425656e2b1
share: add documentation about share-safe mode in `hg help -e share`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45942
diff
changeset
|
51 |
91425656e2b1
share: add documentation about share-safe mode in `hg help -e share`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45942
diff
changeset
|
52 By default creating a shared repository only enables sharing a common |
91425656e2b1
share: add documentation about share-safe mode in `hg help -e share`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45942
diff
changeset
|
53 history and does not share requirements and configs between them. This |
91425656e2b1
share: add documentation about share-safe mode in `hg help -e share`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45942
diff
changeset
|
54 may lead to problems in some cases, for example when you upgrade the |
91425656e2b1
share: add documentation about share-safe mode in `hg help -e share`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45942
diff
changeset
|
55 storage format from one repository but does not set related configs |
91425656e2b1
share: add documentation about share-safe mode in `hg help -e share`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45942
diff
changeset
|
56 in the shares. |
91425656e2b1
share: add documentation about share-safe mode in `hg help -e share`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45942
diff
changeset
|
57 |
91425656e2b1
share: add documentation about share-safe mode in `hg help -e share`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45942
diff
changeset
|
58 Setting `format.exp-share-safe = True` enables sharing configs and |
91425656e2b1
share: add documentation about share-safe mode in `hg help -e share`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45942
diff
changeset
|
59 requirements. This only applies to shares which are done after enabling |
91425656e2b1
share: add documentation about share-safe mode in `hg help -e share`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45942
diff
changeset
|
60 the config option. |
91425656e2b1
share: add documentation about share-safe mode in `hg help -e share`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45942
diff
changeset
|
61 |
91425656e2b1
share: add documentation about share-safe mode in `hg help -e share`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45942
diff
changeset
|
62 For enabling this in existing shares, enable the config option and reshare. |
91425656e2b1
share: add documentation about share-safe mode in `hg help -e share`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45942
diff
changeset
|
63 |
91425656e2b1
share: add documentation about share-safe mode in `hg help -e share`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45942
diff
changeset
|
64 For resharing existing shares, make sure your working directory is clean |
91425656e2b1
share: add documentation about share-safe mode in `hg help -e share`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45942
diff
changeset
|
65 and there are no untracked files, delete that share and create a new share. |
25761
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
66 ''' |
8873
e872ef2e6758
help: add/fix docstrings for a bunch of extensions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8807
diff
changeset
|
67 |
51863
f4733654f144
typing: add `from __future__ import annotations` to most files
Matt Harbison <matt_harbison@yahoo.com>
parents:
50797
diff
changeset
|
68 from __future__ import annotations |
29485
6a98f9408a50
py3: make files use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29424
diff
changeset
|
69 |
8801
28eaf6f8abce
share: add experimental share extension
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
70 from mercurial.i18n import _ |
29485
6a98f9408a50
py3: make files use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29424
diff
changeset
|
71 from mercurial import ( |
6a98f9408a50
py3: make files use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29424
diff
changeset
|
72 bookmarks, |
6a98f9408a50
py3: make files use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29424
diff
changeset
|
73 commands, |
6a98f9408a50
py3: make files use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29424
diff
changeset
|
74 error, |
6a98f9408a50
py3: make files use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29424
diff
changeset
|
75 extensions, |
6a98f9408a50
py3: make files use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29424
diff
changeset
|
76 hg, |
32337
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31334
diff
changeset
|
77 registrar, |
31052
0332b8fafd05
bookmarks: check HG_PENDING strictly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29841
diff
changeset
|
78 txnutil, |
29485
6a98f9408a50
py3: make files use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29424
diff
changeset
|
79 util, |
6a98f9408a50
py3: make files use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29424
diff
changeset
|
80 ) |
6a98f9408a50
py3: make files use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29424
diff
changeset
|
81 |
21253
d2ce7a20fe86
share: declare commands using decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
20056
diff
changeset
|
82 cmdtable = {} |
32337
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31334
diff
changeset
|
83 command = registrar.command(cmdtable) |
29841
d5883fd055c6
extensions: change magic "shipped with hg" string
Augie Fackler <augie@google.com>
parents:
29506
diff
changeset
|
84 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for |
25186
80c5b2666a96
extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents:
24364
diff
changeset
|
85 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
80c5b2666a96
extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents:
24364
diff
changeset
|
86 # be specifying the version(s) of Mercurial they are tested with, or |
80c5b2666a96
extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents:
24364
diff
changeset
|
87 # leave the attribute unspecified. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
88 testedwith = b'ships-with-hg-core' |
16743
38caf405d010
hgext: mark all first-party extensions as such
Augie Fackler <raf@durin42.com>
parents:
15082
diff
changeset
|
89 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42325
diff
changeset
|
90 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42325
diff
changeset
|
91 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
92 b'share', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42325
diff
changeset
|
93 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
94 (b'U', b'noupdate', None, _(b'do not create a working directory')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
95 (b'B', b'bookmarks', None, _(b'also share bookmarks')), |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44979
diff
changeset
|
96 ( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44979
diff
changeset
|
97 b'', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44979
diff
changeset
|
98 b'relative', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44979
diff
changeset
|
99 None, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44979
diff
changeset
|
100 _(b'point to source using a relative path'), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44979
diff
changeset
|
101 ), |
31133
23080c03a604
share: add --relative flag to store a relative path to the source
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
31052
diff
changeset
|
102 ], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
103 _(b'[-U] [-B] SOURCE [DEST]'), |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
36159
diff
changeset
|
104 helpcategory=command.CATEGORY_REPO_CREATION, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42325
diff
changeset
|
105 norepo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42325
diff
changeset
|
106 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42325
diff
changeset
|
107 def share( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42325
diff
changeset
|
108 ui, source, dest=None, noupdate=False, bookmarks=False, relative=False |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42325
diff
changeset
|
109 ): |
10798
e46c19c586fa
share: drop experimental label
Martin Geisler <mg@lazybytes.net>
parents:
10263
diff
changeset
|
110 """create a new shared repository |
8801
28eaf6f8abce
share: add experimental share extension
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
111 |
9273
4b8b0c124b99
share: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9075
diff
changeset
|
112 Initialize a new repository and working directory that shares its |
23614
cd79fb4d75fd
share: add option to share bookmarks
Ryan McElroy <rmcelroy@fb.com>
parents:
23548
diff
changeset
|
113 history (and optionally bookmarks) with another repository. |
8801
28eaf6f8abce
share: add experimental share extension
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
114 |
12389 | 115 .. note:: |
19997
de16c673455b
documentation: add an extra newline after note directive
Simon Heimberg <simohe@besonet.ch>
parents:
19399
diff
changeset
|
116 |
12389 | 117 using rollback or extensions that destroy/modify history (mq, |
118 rebase, etc.) can cause considerable confusion with shared | |
119 clones. In particular, if two shared clones are both updated to | |
120 the same changeset, and one of them destroys that changeset | |
121 with rollback, the other clone will suddenly stop working: all | |
122 operations will fail with "abort: working directory has unknown | |
123 parent". The only known workaround is to use debugsetparents on | |
19399
02465cafb0a9
share: remove reference to tip
Matt Mackall <mpm@selenic.com>
parents:
18825
diff
changeset
|
124 the broken clone to reset it to a changeset that still exists. |
8801
28eaf6f8abce
share: add experimental share extension
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
125 """ |
28eaf6f8abce
share: add experimental share extension
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
126 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42325
diff
changeset
|
127 hg.share( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42325
diff
changeset
|
128 ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42325
diff
changeset
|
129 source, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42325
diff
changeset
|
130 dest=dest, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42325
diff
changeset
|
131 update=not noupdate, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42325
diff
changeset
|
132 bookmarks=bookmarks, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42325
diff
changeset
|
133 relative=relative, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42325
diff
changeset
|
134 ) |
34815
68e0bcb90357
subrepo: share instead of clone if the parent repo is shared (issue5675) (BC)
Matt Harbison <matt_harbison@yahoo.com>
parents:
34498
diff
changeset
|
135 return 0 |
8801
28eaf6f8abce
share: add experimental share extension
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
136 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42325
diff
changeset
|
137 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
138 @command(b'unshare', [], b'', helpcategory=command.CATEGORY_MAINTENANCE) |
15079
ea96bdda593c
hgext: introduce unshare command
Simon Heimberg <simohe@besonet.ch>
parents:
12389
diff
changeset
|
139 def unshare(ui, repo): |
ea96bdda593c
hgext: introduce unshare command
Simon Heimberg <simohe@besonet.ch>
parents:
12389
diff
changeset
|
140 """convert a shared repository to a normal one |
ea96bdda593c
hgext: introduce unshare command
Simon Heimberg <simohe@besonet.ch>
parents:
12389
diff
changeset
|
141 |
ea96bdda593c
hgext: introduce unshare command
Simon Heimberg <simohe@besonet.ch>
parents:
12389
diff
changeset
|
142 Copy the store data to the repo and remove the sharedpath data. |
ea96bdda593c
hgext: introduce unshare command
Simon Heimberg <simohe@besonet.ch>
parents:
12389
diff
changeset
|
143 """ |
ea96bdda593c
hgext: introduce unshare command
Simon Heimberg <simohe@besonet.ch>
parents:
12389
diff
changeset
|
144 |
23666
965788d9ae09
localrepo: introduce shared method to check if a repository is shared
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
23626
diff
changeset
|
145 if not repo.shared(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
146 raise error.Abort(_(b"this is not a shared repo")) |
15079
ea96bdda593c
hgext: introduce unshare command
Simon Heimberg <simohe@besonet.ch>
parents:
12389
diff
changeset
|
147 |
34878
9f7ecc5bbc28
share: move the implementation of 'unshare' to the 'hg' module
Matt Harbison <matt_harbison@yahoo.com>
parents:
34815
diff
changeset
|
148 hg.unshare(ui, repo) |
23548
141baca16059
share: implement shared bookmark functionality
Ryan McElroy <rmcelroy@fb.com>
parents:
21772
diff
changeset
|
149 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42325
diff
changeset
|
150 |
25761
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
151 # Wrap clone command to pass auto share options. |
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
152 def clone(orig, ui, source, *args, **opts): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
153 pool = ui.config(b'share', b'pool') |
25761
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
154 if pool: |
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
155 pool = util.expandpath(pool) |
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
156 |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43270
diff
changeset
|
157 opts['shareopts'] = { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
158 b'pool': pool, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
159 b'mode': ui.config(b'share', b'poolnaming'), |
33021
24c0a9a7fa86
share: use dict literal instead of dict(key=value)
Yuya Nishihara <yuya@tcha.org>
parents:
33020
diff
changeset
|
160 } |
25761
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
161 |
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
162 return orig(ui, source, *args, **opts) |
0d37b9b21467
hg: support for auto sharing stores when cloning
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25666
diff
changeset
|
163 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42325
diff
changeset
|
164 |
23548
141baca16059
share: implement shared bookmark functionality
Ryan McElroy <rmcelroy@fb.com>
parents:
21772
diff
changeset
|
165 def extsetup(ui): |
50796
7a50e1720f6d
wrapfunction: use sysstr instead of bytes as argument in "share"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49306
diff
changeset
|
166 extensions.wrapfunction(bookmarks, '_getbkfile', getbkfile) |
7a50e1720f6d
wrapfunction: use sysstr instead of bytes as argument in "share"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49306
diff
changeset
|
167 extensions.wrapfunction(bookmarks.bmstore, '_recordchange', recordchange) |
7a50e1720f6d
wrapfunction: use sysstr instead of bytes as argument in "share"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49306
diff
changeset
|
168 extensions.wrapfunction(bookmarks.bmstore, '_writerepo', writerepo) |
50797
4c6151b69085
wrapfunction: use sysstr instead of bytes as argument in "sqlitestore"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50796
diff
changeset
|
169 extensions.wrapcommand(commands.table, b'clone', clone) |
23548
141baca16059
share: implement shared bookmark functionality
Ryan McElroy <rmcelroy@fb.com>
parents:
21772
diff
changeset
|
170 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42325
diff
changeset
|
171 |
23548
141baca16059
share: implement shared bookmark functionality
Ryan McElroy <rmcelroy@fb.com>
parents:
21772
diff
changeset
|
172 def _hassharedbookmarks(repo): |
141baca16059
share: implement shared bookmark functionality
Ryan McElroy <rmcelroy@fb.com>
parents:
21772
diff
changeset
|
173 """Returns whether this repo has shared bookmarks""" |
42325
526750cdd02d
bookmarks: keep bookmarks in .hg/store if new config set
Martin von Zweigbergk <martinvonz@google.com>
parents:
40293
diff
changeset
|
174 if bookmarks.bookmarksinstore(repo): |
526750cdd02d
bookmarks: keep bookmarks in .hg/store if new config set
Martin von Zweigbergk <martinvonz@google.com>
parents:
40293
diff
changeset
|
175 # Kind of a lie, but it means that we skip our custom reads and writes |
526750cdd02d
bookmarks: keep bookmarks in .hg/store if new config set
Martin von Zweigbergk <martinvonz@google.com>
parents:
40293
diff
changeset
|
176 # from/to the source repo. |
526750cdd02d
bookmarks: keep bookmarks in .hg/store if new config set
Martin von Zweigbergk <martinvonz@google.com>
parents:
40293
diff
changeset
|
177 return False |
23548
141baca16059
share: implement shared bookmark functionality
Ryan McElroy <rmcelroy@fb.com>
parents:
21772
diff
changeset
|
178 try: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
179 shared = repo.vfs.read(b'shared').splitlines() |
49306
2e726c934fcd
py3: catch FileNotFoundError instead of checking errno == ENOENT
Manuel Jacob <me@manueljacob.de>
parents:
48875
diff
changeset
|
180 except FileNotFoundError: |
23548
141baca16059
share: implement shared bookmark functionality
Ryan McElroy <rmcelroy@fb.com>
parents:
21772
diff
changeset
|
181 return False |
29424
f21e0d91d386
share: move magic string to a constant
Martijn Pieters <mjpieters@fb.com>
parents:
27353
diff
changeset
|
182 return hg.sharedbookmarks in shared |
23548
141baca16059
share: implement shared bookmark functionality
Ryan McElroy <rmcelroy@fb.com>
parents:
21772
diff
changeset
|
183 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42325
diff
changeset
|
184 |
27186
34d26e22a2b0
bookmarks: hoist getbkfile out of bmstore class
Augie Fackler <augie@google.com>
parents:
26933
diff
changeset
|
185 def getbkfile(orig, repo): |
23548
141baca16059
share: implement shared bookmark functionality
Ryan McElroy <rmcelroy@fb.com>
parents:
21772
diff
changeset
|
186 if _hassharedbookmarks(repo): |
36159
0fe7e39dc683
hg: move share._getsrcrepo into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34982
diff
changeset
|
187 srcrepo = hg.sharedreposource(repo) |
23548
141baca16059
share: implement shared bookmark functionality
Ryan McElroy <rmcelroy@fb.com>
parents:
21772
diff
changeset
|
188 if srcrepo is not None: |
31052
0332b8fafd05
bookmarks: check HG_PENDING strictly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29841
diff
changeset
|
189 # just orig(srcrepo) doesn't work as expected, because |
0332b8fafd05
bookmarks: check HG_PENDING strictly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29841
diff
changeset
|
190 # HG_PENDING refers repo.root. |
0332b8fafd05
bookmarks: check HG_PENDING strictly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29841
diff
changeset
|
191 try: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42325
diff
changeset
|
192 fp, pending = txnutil.trypending( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
193 repo.root, repo.vfs, b'bookmarks' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42325
diff
changeset
|
194 ) |
31052
0332b8fafd05
bookmarks: check HG_PENDING strictly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29841
diff
changeset
|
195 if pending: |
0332b8fafd05
bookmarks: check HG_PENDING strictly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29841
diff
changeset
|
196 # only in this case, bookmark information in repo |
0332b8fafd05
bookmarks: check HG_PENDING strictly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29841
diff
changeset
|
197 # is up-to-date. |
0332b8fafd05
bookmarks: check HG_PENDING strictly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29841
diff
changeset
|
198 return fp |
0332b8fafd05
bookmarks: check HG_PENDING strictly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29841
diff
changeset
|
199 fp.close() |
49306
2e726c934fcd
py3: catch FileNotFoundError instead of checking errno == ENOENT
Manuel Jacob <me@manueljacob.de>
parents:
48875
diff
changeset
|
200 except FileNotFoundError: |
2e726c934fcd
py3: catch FileNotFoundError instead of checking errno == ENOENT
Manuel Jacob <me@manueljacob.de>
parents:
48875
diff
changeset
|
201 pass |
31052
0332b8fafd05
bookmarks: check HG_PENDING strictly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29841
diff
changeset
|
202 |
0332b8fafd05
bookmarks: check HG_PENDING strictly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29841
diff
changeset
|
203 # otherwise, we should read bookmarks from srcrepo, |
0332b8fafd05
bookmarks: check HG_PENDING strictly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29841
diff
changeset
|
204 # because .hg/bookmarks in srcrepo might be already |
0332b8fafd05
bookmarks: check HG_PENDING strictly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29841
diff
changeset
|
205 # changed via another sharing repo |
23548
141baca16059
share: implement shared bookmark functionality
Ryan McElroy <rmcelroy@fb.com>
parents:
21772
diff
changeset
|
206 repo = srcrepo |
31052
0332b8fafd05
bookmarks: check HG_PENDING strictly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29841
diff
changeset
|
207 |
0332b8fafd05
bookmarks: check HG_PENDING strictly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29841
diff
changeset
|
208 # TODO: Pending changes in repo are still invisible in |
0332b8fafd05
bookmarks: check HG_PENDING strictly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29841
diff
changeset
|
209 # srcrepo, because bookmarks.pending is written only into repo. |
0332b8fafd05
bookmarks: check HG_PENDING strictly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29841
diff
changeset
|
210 # See also https://www.mercurial-scm.org/wiki/SharedRepository |
27186
34d26e22a2b0
bookmarks: hoist getbkfile out of bmstore class
Augie Fackler <augie@google.com>
parents:
26933
diff
changeset
|
211 return orig(repo) |
23548
141baca16059
share: implement shared bookmark functionality
Ryan McElroy <rmcelroy@fb.com>
parents:
21772
diff
changeset
|
212 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42325
diff
changeset
|
213 |
23548
141baca16059
share: implement shared bookmark functionality
Ryan McElroy <rmcelroy@fb.com>
parents:
21772
diff
changeset
|
214 def recordchange(orig, self, tr): |
141baca16059
share: implement shared bookmark functionality
Ryan McElroy <rmcelroy@fb.com>
parents:
21772
diff
changeset
|
215 # Continue with write to local bookmarks file as usual |
141baca16059
share: implement shared bookmark functionality
Ryan McElroy <rmcelroy@fb.com>
parents:
21772
diff
changeset
|
216 orig(self, tr) |
141baca16059
share: implement shared bookmark functionality
Ryan McElroy <rmcelroy@fb.com>
parents:
21772
diff
changeset
|
217 |
141baca16059
share: implement shared bookmark functionality
Ryan McElroy <rmcelroy@fb.com>
parents:
21772
diff
changeset
|
218 if _hassharedbookmarks(self._repo): |
36159
0fe7e39dc683
hg: move share._getsrcrepo into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34982
diff
changeset
|
219 srcrepo = hg.sharedreposource(self._repo) |
23548
141baca16059
share: implement shared bookmark functionality
Ryan McElroy <rmcelroy@fb.com>
parents:
21772
diff
changeset
|
220 if srcrepo is not None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
221 category = b'share-bookmarks' |
23548
141baca16059
share: implement shared bookmark functionality
Ryan McElroy <rmcelroy@fb.com>
parents:
21772
diff
changeset
|
222 tr.addpostclose(category, lambda tr: self._writerepo(srcrepo)) |
141baca16059
share: implement shared bookmark functionality
Ryan McElroy <rmcelroy@fb.com>
parents:
21772
diff
changeset
|
223 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42325
diff
changeset
|
224 |
26933
a7eecd021782
share: wrap bmstore._writerepo for transaction sensitivity (issue4940)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26587
diff
changeset
|
225 def writerepo(orig, self, repo): |
23548
141baca16059
share: implement shared bookmark functionality
Ryan McElroy <rmcelroy@fb.com>
parents:
21772
diff
changeset
|
226 # First write local bookmarks file in case we ever unshare |
26933
a7eecd021782
share: wrap bmstore._writerepo for transaction sensitivity (issue4940)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26587
diff
changeset
|
227 orig(self, repo) |
a7eecd021782
share: wrap bmstore._writerepo for transaction sensitivity (issue4940)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26587
diff
changeset
|
228 |
23548
141baca16059
share: implement shared bookmark functionality
Ryan McElroy <rmcelroy@fb.com>
parents:
21772
diff
changeset
|
229 if _hassharedbookmarks(self._repo): |
36159
0fe7e39dc683
hg: move share._getsrcrepo into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34982
diff
changeset
|
230 srcrepo = hg.sharedreposource(self._repo) |
23548
141baca16059
share: implement shared bookmark functionality
Ryan McElroy <rmcelroy@fb.com>
parents:
21772
diff
changeset
|
231 if srcrepo is not None: |
26933
a7eecd021782
share: wrap bmstore._writerepo for transaction sensitivity (issue4940)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26587
diff
changeset
|
232 orig(self, srcrepo) |