Mercurial > hg
annotate hgext/remotenames.py @ 36070:90ca4986616c
wireprotoserver: rename getfile() to forwardpayload() (API)
"file" can mean a lot of things. Let's rename the interface
method to something more descriptive.
While I was here, I moved the docs about the payload format to
the implementation of the SSH protocol, because it was lying
about what the HTTP payload looked like.
Differential Revision: https://phab.mercurial-scm.org/D2085
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 01 Feb 2018 17:12:07 -0800 |
parents | 5a53af7d09aa |
children | 828f44cdfee3 |
rev | line source |
---|---|
36060
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
1 # remotenames.py - extension to display remotenames |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
2 # |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
3 # Copyright 2017 Augie Fackler <raf@durin42.com> |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
4 # Copyright 2017 Sean Farley <sean@farley.io> |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
5 # |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
6 # This software may be used and distributed according to the terms of the |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
7 # GNU General Public License version 2 or any later version. |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
8 |
36062
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
9 """ showing remotebookmarks and remotebranches in UI |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
10 |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
11 By default both remotebookmarks and remotebranches are turned on. Config knob to |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
12 control the individually are as follows. |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
13 |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
14 Config options to tweak the default behaviour: |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
15 |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
16 remotenames.bookmarks |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
17 Boolean value to enable or disable showing of remotebookmarks |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
18 |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
19 remotenames.branches |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
20 Boolean value to enable or disable showing of remotebranches |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
21 """ |
36060
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
22 |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
23 from __future__ import absolute_import |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
24 |
36061
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
25 import UserDict |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
26 |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
27 from mercurial.node import ( |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
28 bin, |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
29 ) |
36060
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
30 from mercurial import ( |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
31 logexchange, |
36062
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
32 namespaces, |
36063
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
33 pycompat, |
36062
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
34 registrar, |
36063
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
35 templatekw, |
36060
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
36 ) |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
37 |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
38 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
39 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
40 # be specifying the version(s) of Mercurial they are tested with, or |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
41 # leave the attribute unspecified. |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
42 testedwith = 'ships-with-hg-core' |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
43 |
36062
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
44 configtable = {} |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
45 configitem = registrar.configitem(configtable) |
36063
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
46 templatekeyword = registrar.templatekeyword() |
36062
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
47 |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
48 configitem('remotenames', 'bookmarks', |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
49 default=True, |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
50 ) |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
51 configitem('remotenames', 'branches', |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
52 default=True, |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
53 ) |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
54 |
36061
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
55 class lazyremotenamedict(UserDict.DictMixin): |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
56 """ |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
57 Read-only dict-like Class to lazily resolve remotename entries |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
58 |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
59 We are doing that because remotenames startup was slow. |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
60 We lazily read the remotenames file once to figure out the potential entries |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
61 and store them in self.potentialentries. Then when asked to resolve an |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
62 entry, if it is not in self.potentialentries, then it isn't there, if it |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
63 is in self.potentialentries we resolve it and store the result in |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
64 self.cache. We cannot be lazy is when asked all the entries (keys). |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
65 """ |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
66 def __init__(self, kind, repo): |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
67 self.cache = {} |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
68 self.potentialentries = {} |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
69 self._kind = kind # bookmarks or branches |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
70 self._repo = repo |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
71 self.loaded = False |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
72 |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
73 def _load(self): |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
74 """ Read the remotenames file, store entries matching selected kind """ |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
75 self.loaded = True |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
76 repo = self._repo |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
77 for node, rpath, rname in logexchange.readremotenamefile(repo, |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
78 self._kind): |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
79 name = rpath + '/' + rname |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
80 self.potentialentries[name] = (node, rpath, name) |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
81 |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
82 def _resolvedata(self, potentialentry): |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
83 """ Check that the node for potentialentry exists and return it """ |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
84 if not potentialentry in self.potentialentries: |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
85 return None |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
86 node, remote, name = self.potentialentries[potentialentry] |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
87 repo = self._repo |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
88 binnode = bin(node) |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
89 # if the node doesn't exist, skip it |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
90 try: |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
91 repo.changelog.rev(binnode) |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
92 except LookupError: |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
93 return None |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
94 # Skip closed branches |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
95 if (self._kind == 'branches' and repo[binnode].closesbranch()): |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
96 return None |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
97 return [binnode] |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
98 |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
99 def __getitem__(self, key): |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
100 if not self.loaded: |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
101 self._load() |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
102 val = self._fetchandcache(key) |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
103 if val is not None: |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
104 return val |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
105 else: |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
106 raise KeyError() |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
107 |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
108 def _fetchandcache(self, key): |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
109 if key in self.cache: |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
110 return self.cache[key] |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
111 val = self._resolvedata(key) |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
112 if val is not None: |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
113 self.cache[key] = val |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
114 return val |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
115 else: |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
116 return None |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
117 |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
118 def keys(self): |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
119 """ Get a list of bookmark or branch names """ |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
120 if not self.loaded: |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
121 self._load() |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
122 return self.potentialentries.keys() |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
123 |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
124 def iteritems(self): |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
125 """ Iterate over (name, node) tuples """ |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
126 |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
127 if not self.loaded: |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
128 self._load() |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
129 |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
130 for k, vtup in self.potentialentries.iteritems(): |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
131 yield (k, [bin(vtup[0])]) |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
132 |
36060
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
133 class remotenames(dict): |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
134 """ |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
135 This class encapsulates all the remotenames state. It also contains |
36061
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
136 methods to access that state in convenient ways. Remotenames are lazy |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
137 loaded. Whenever client code needs to ensure the freshest copy of |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
138 remotenames, use the `clearnames` method to force an eventual load. |
36060
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
139 """ |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
140 |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
141 def __init__(self, repo, *args): |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
142 dict.__init__(self, *args) |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
143 self._repo = repo |
36061
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
144 self.clearnames() |
36060
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
145 |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
146 def clearnames(self): |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
147 """ Clear all remote names state """ |
36061
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
148 self['bookmarks'] = lazyremotenamedict("bookmarks", self._repo) |
be72f6420f3c
remotenames: introduce a class to lazily resolve remotnames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36060
diff
changeset
|
149 self['branches'] = lazyremotenamedict("branches", self._repo) |
36060
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
150 self._invalidatecache() |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
151 |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
152 def _invalidatecache(self): |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
153 self._nodetobmarks = None |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
154 self._nodetobranch = None |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
155 |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
156 def bmarktonodes(self): |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
157 return self['bookmarks'] |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
158 |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
159 def nodetobmarks(self): |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
160 if not self._nodetobmarks: |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
161 bmarktonodes = self.bmarktonodes() |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
162 self._nodetobmarks = {} |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
163 for name, node in bmarktonodes.iteritems(): |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
164 self._nodetobmarks.setdefault(node[0], []).append(name) |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
165 return self._nodetobmarks |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
166 |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
167 def branchtonodes(self): |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
168 return self['branches'] |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
169 |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
170 def nodetobranch(self): |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
171 if not self._nodetobranch: |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
172 branchtonodes = self.branchtonodes() |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
173 self._nodetobranch = {} |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
174 for name, nodes in branchtonodes.iteritems(): |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
175 for node in nodes: |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
176 self._nodetobranch.setdefault(node, []).append(name) |
cabe8ef5c71e
remotenames: introduce class to encapsulate remotenames info in an extension
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
177 return self._nodetobranch |
36062
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
178 |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
179 def reposetup(ui, repo): |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
180 if not repo.local(): |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
181 return |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
182 |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
183 repo._remotenames = remotenames(repo) |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
184 ns = namespaces.namespace |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
185 |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
186 if ui.configbool('remotenames', 'bookmarks'): |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
187 remotebookmarkns = ns( |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
188 'remotebookmarks', |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
189 templatename='remotebookmarks', |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
190 logname='remote bookmark', |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
191 colorname='remotebookmark', |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
192 listnames=lambda repo: repo._remotenames.bmarktonodes().keys(), |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
193 namemap=lambda repo, name: |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
194 repo._remotenames.bmarktonodes().get(name, []), |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
195 nodemap=lambda repo, node: |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
196 repo._remotenames.nodetobmarks().get(node, [])) |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
197 repo.names.addnamespace(remotebookmarkns) |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
198 |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
199 if ui.configbool('remotenames', 'branches'): |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
200 remotebranchns = ns( |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
201 'remotebranches', |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
202 templatename='remotebranches', |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
203 logname='remote branch', |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
204 colorname='remotebranch', |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
205 listnames = lambda repo: repo._remotenames.branchtonodes().keys(), |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
206 namemap = lambda repo, name: |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
207 repo._remotenames.branchtonodes().get(name, []), |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
208 nodemap = lambda repo, node: |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
209 repo._remotenames.nodetobranch().get(node, [])) |
382aefea8faf
remotenames: add new namespaces for remotebookmarks and remotebranches
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36061
diff
changeset
|
210 repo.names.addnamespace(remotebranchns) |
36063
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
211 |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
212 @templatekeyword('remotenames') |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
213 def remotenameskw(**args): |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
214 """:remotenames: List of strings. List of remote names associated with the |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
215 changeset. |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
216 """ |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
217 args = pycompat.byteskwargs(args) |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
218 repo, ctx = args['repo'], args['ctx'] |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
219 |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
220 remotenames = [] |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
221 if 'remotebookmarks' in repo.names: |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
222 remotenames = repo.names['remotebookmarks'].names(repo, ctx.node()) |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
223 |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
224 if 'remotebranches' in repo.names: |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
225 remotenames += repo.names['remotebranches'].names(repo, ctx.node()) |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
226 |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
227 return templatekw.showlist('remotename', remotenames, args, |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
228 plural='remotenames') |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
229 |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
230 @templatekeyword('remotebookmarks') |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
231 def remotebookmarkskw(**args): |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
232 """:remotebookmarks: List of strings. List of remote bookmarks associated |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
233 with the changeset. |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
234 """ |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
235 args = pycompat.byteskwargs(args) |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
236 repo, ctx = args['repo'], args['ctx'] |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
237 |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
238 remotebmarks = [] |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
239 if 'remotebookmarks' in repo.names: |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
240 remotebmarks = repo.names['remotebookmarks'].names(repo, ctx.node()) |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
241 |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
242 return templatekw.showlist('remotebookmark', remotebmarks, args, |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
243 plural='remotebookmarks') |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
244 |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
245 @templatekeyword('remotebranches') |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
246 def remotebrancheskw(**args): |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
247 """:remotebranches: List of strings. List of remote branches associated |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
248 with the changeset. |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
249 """ |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
250 args = pycompat.byteskwargs(args) |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
251 repo, ctx = args['repo'], args['ctx'] |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
252 |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
253 remotebranches = [] |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
254 if 'remotebranches' in repo.names: |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
255 remotebranches = repo.names['remotebranches'].names(repo, ctx.node()) |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
256 |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
257 return templatekw.showlist('remotebranch', remotebranches, args, |
5a53af7d09aa
remotenames: introduce new template keywords for remotenames
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36062
diff
changeset
|
258 plural='remotebranches') |