Mercurial > hg-stable
annotate hgext/narrow/__init__.py @ 43076:2372284d9457
formatting: blacken the codebase
This is using my patch to black
(https://github.com/psf/black/pull/826) so we don't un-wrap collection
literals.
Done with:
hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**"' | xargs black -S
# skip-blame mass-reformatting only
# no-check-commit reformats foo_bar functions
Differential Revision: https://phab.mercurial-scm.org/D6971
author | Augie Fackler <augie@google.com> |
---|---|
date | Sun, 06 Oct 2019 09:45:02 -0400 |
parents | 268662aac075 |
children | 687b865b95ad |
rev | line source |
---|---|
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
1 # __init__.py - narrowhg extension |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
2 # |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
3 # Copyright 2017 Google, Inc. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
4 # |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
6 # GNU General Public License version 2 or any later version. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
7 '''create clones which fetch history data for subset of files (EXPERIMENTAL)''' |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
8 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
9 from __future__ import absolute_import |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
10 |
36123
4b843cb6eb8c
narrow: remove old version-checking logic and declare internal
Augie Fackler <augie@google.com>
parents:
36118
diff
changeset
|
11 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for |
4b843cb6eb8c
narrow: remove old version-checking logic and declare internal
Augie Fackler <augie@google.com>
parents:
36118
diff
changeset
|
12 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
4b843cb6eb8c
narrow: remove old version-checking logic and declare internal
Augie Fackler <augie@google.com>
parents:
36118
diff
changeset
|
13 # be specifying the version(s) of Mercurial they are tested with, or |
4b843cb6eb8c
narrow: remove old version-checking logic and declare internal
Augie Fackler <augie@google.com>
parents:
36118
diff
changeset
|
14 # leave the attribute unspecified. |
4b843cb6eb8c
narrow: remove old version-checking logic and declare internal
Augie Fackler <augie@google.com>
parents:
36118
diff
changeset
|
15 testedwith = 'ships-with-hg-core' |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
16 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
17 from mercurial import ( |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
18 localrepo, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
19 registrar, |
42823
268662aac075
interfaces: create a new folder for interfaces and move repository.py in it
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40074
diff
changeset
|
20 ) |
268662aac075
interfaces: create a new folder for interfaces and move repository.py in it
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40074
diff
changeset
|
21 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
22 from mercurial.interfaces import repository |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
23 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
24 from . import ( |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
25 narrowbundle2, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
26 narrowcommands, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
27 narrowrepo, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
28 narrowtemplates, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
29 narrowwirepeer, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
30 ) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
31 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
32 configtable = {} |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
33 configitem = registrar.configitem(configtable) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
34 # Narrowhg *has* support for serving ellipsis nodes (which are used at |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
35 # least by Google's internal server), but that support is pretty |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
36 # fragile and has a lot of problems on real-world repositories that |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
37 # have complex graph topologies. This could probably be corrected, but |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
38 # absent someone needing the full support for ellipsis nodes in |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
39 # repositories with merges, it's unlikely this work will get done. As |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
40 # of this writining in late 2017, all repositories large enough for |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
41 # ellipsis nodes to be a hard requirement also enforce strictly linear |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
42 # history for other scaling reasons. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
43 configitem( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
44 'experimental', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
45 'narrowservebrokenellipses', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
46 default=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
47 alias=[('narrow', 'serveellipses')], |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
48 ) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
49 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
50 # Export the commands table for Mercurial to see. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
51 cmdtable = narrowcommands.table |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
52 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
53 |
37139
e2d386b8a38f
narrow: use featuresetupfuncs
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36502
diff
changeset
|
54 def featuresetup(ui, features): |
38874
a232e6744ba3
narrow: move requirement constant from changegroup to repository
Martin von Zweigbergk <martinvonz@google.com>
parents:
38161
diff
changeset
|
55 features.add(repository.NARROW_REQUIREMENT) |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
56 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
57 |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
58 def uisetup(ui): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
59 """Wraps user-facing mercurial commands with narrow-aware versions.""" |
37139
e2d386b8a38f
narrow: use featuresetupfuncs
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36502
diff
changeset
|
60 localrepo.featuresetupfuncs.add(featuresetup) |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
61 narrowbundle2.setup() |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
62 narrowcommands.setup() |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
63 narrowwirepeer.uisetup() |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
64 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
65 |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
66 def reposetup(ui, repo): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
67 """Wraps local repositories with narrow repo support.""" |
37188
6d43b39fbaa0
narrow: use repo.local() instead of isinstance()
Martin von Zweigbergk <martinvonz@google.com>
parents:
37139
diff
changeset
|
68 if not repo.local(): |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
69 return |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
70 |
40074
e92454e69dc3
narrow: introduce a config option to check if narrow is enabled or not
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39967
diff
changeset
|
71 repo.ui.setconfig('experimental', 'narrow', True, 'narrow-ext') |
38874
a232e6744ba3
narrow: move requirement constant from changegroup to repository
Martin von Zweigbergk <martinvonz@google.com>
parents:
38161
diff
changeset
|
72 if repository.NARROW_REQUIREMENT in repo.requirements: |
38161
1cba497491be
narrow: only wrap dirstate functions once, instead of per-reposetup
Kyle Lippincott <spectral@google.com>
parents:
38079
diff
changeset
|
73 narrowrepo.wraprepo(repo) |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
74 narrowwirepeer.reposetup(repo) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
75 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42823
diff
changeset
|
76 |
36129
ea02be8665ef
narrowtemplates: update to use registrar mechanism
Augie Fackler <augie@google.com>
parents:
36126
diff
changeset
|
77 templatekeyword = narrowtemplates.templatekeyword |
ea02be8665ef
narrowtemplates: update to use registrar mechanism
Augie Fackler <augie@google.com>
parents:
36126
diff
changeset
|
78 revsetpredicate = narrowtemplates.revsetpredicate |