Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/namespaces.py @ 43077:687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Done with
python3.7 contrib/byteify-strings.py -i $(hg files 'set:mercurial/**.py - mercurial/thirdparty/** + hgext/**.py - hgext/fsmonitor/pywatchman/** - mercurial/__init__.py')
black -l 80 -t py33 -S $(hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**" - hgext/fsmonitor/pywatchman/**')
# skip-blame mass-reformatting only
Differential Revision: https://phab.mercurial-scm.org/D6972
author | Augie Fackler <augie@google.com> |
---|---|
date | Sun, 06 Oct 2019 09:48:39 -0400 |
parents | 2372284d9457 |
children | d783f945a701 |
comparison
equal
deleted
inserted
replaced
43076:2372284d9457 | 43077:687b865b95ad |
---|---|
34 # branches) to be initialized somewhere, so that place is here | 34 # branches) to be initialized somewhere, so that place is here |
35 bmknames = lambda repo: repo._bookmarks.keys() | 35 bmknames = lambda repo: repo._bookmarks.keys() |
36 bmknamemap = lambda repo, name: tolist(repo._bookmarks.get(name)) | 36 bmknamemap = lambda repo, name: tolist(repo._bookmarks.get(name)) |
37 bmknodemap = lambda repo, node: repo.nodebookmarks(node) | 37 bmknodemap = lambda repo, node: repo.nodebookmarks(node) |
38 n = namespace( | 38 n = namespace( |
39 "bookmarks", | 39 b"bookmarks", |
40 templatename="bookmark", | 40 templatename=b"bookmark", |
41 logfmt=columns['bookmark'], | 41 logfmt=columns[b'bookmark'], |
42 listnames=bmknames, | 42 listnames=bmknames, |
43 namemap=bmknamemap, | 43 namemap=bmknamemap, |
44 nodemap=bmknodemap, | 44 nodemap=bmknodemap, |
45 builtin=True, | 45 builtin=True, |
46 ) | 46 ) |
48 | 48 |
49 tagnames = lambda repo: [t for t, n in repo.tagslist()] | 49 tagnames = lambda repo: [t for t, n in repo.tagslist()] |
50 tagnamemap = lambda repo, name: tolist(repo._tagscache.tags.get(name)) | 50 tagnamemap = lambda repo, name: tolist(repo._tagscache.tags.get(name)) |
51 tagnodemap = lambda repo, node: repo.nodetags(node) | 51 tagnodemap = lambda repo, node: repo.nodetags(node) |
52 n = namespace( | 52 n = namespace( |
53 "tags", | 53 b"tags", |
54 templatename="tag", | 54 templatename=b"tag", |
55 logfmt=columns['tag'], | 55 logfmt=columns[b'tag'], |
56 listnames=tagnames, | 56 listnames=tagnames, |
57 namemap=tagnamemap, | 57 namemap=tagnamemap, |
58 nodemap=tagnodemap, | 58 nodemap=tagnodemap, |
59 deprecated={'tip'}, | 59 deprecated={b'tip'}, |
60 builtin=True, | 60 builtin=True, |
61 ) | 61 ) |
62 self.addnamespace(n) | 62 self.addnamespace(n) |
63 | 63 |
64 bnames = lambda repo: repo.branchmap().keys() | 64 bnames = lambda repo: repo.branchmap().keys() |
65 bnamemap = lambda repo, name: tolist(repo.branchtip(name, True)) | 65 bnamemap = lambda repo, name: tolist(repo.branchtip(name, True)) |
66 bnodemap = lambda repo, node: [repo[node].branch()] | 66 bnodemap = lambda repo, node: [repo[node].branch()] |
67 n = namespace( | 67 n = namespace( |
68 "branches", | 68 b"branches", |
69 templatename="branch", | 69 templatename=b"branch", |
70 logfmt=columns['branch'], | 70 logfmt=columns[b'branch'], |
71 listnames=bnames, | 71 listnames=bnames, |
72 namemap=bnamemap, | 72 namemap=bnamemap, |
73 nodemap=bnodemap, | 73 nodemap=bnodemap, |
74 builtin=True, | 74 builtin=True, |
75 ) | 75 ) |
102 | 102 |
103 # we only generate a template keyword if one does not already exist | 103 # we only generate a template keyword if one does not already exist |
104 if namespace.name not in templatekw.keywords: | 104 if namespace.name not in templatekw.keywords: |
105 templatekeyword = registrar.templatekeyword(templatekw.keywords) | 105 templatekeyword = registrar.templatekeyword(templatekw.keywords) |
106 | 106 |
107 @templatekeyword(namespace.name, requires={'repo', 'ctx'}) | 107 @templatekeyword(namespace.name, requires={b'repo', b'ctx'}) |
108 def generatekw(context, mapping): | 108 def generatekw(context, mapping): |
109 return templatekw.shownames(context, mapping, namespace.name) | 109 return templatekw.shownames(context, mapping, namespace.name) |
110 | 110 |
111 def singlenode(self, repo, name): | 111 def singlenode(self, repo, name): |
112 """ | 112 """ |
118 """ | 118 """ |
119 for ns, v in self._names.iteritems(): | 119 for ns, v in self._names.iteritems(): |
120 n = v.singlenode(repo, name) | 120 n = v.singlenode(repo, name) |
121 if n: | 121 if n: |
122 return n | 122 return n |
123 raise KeyError(_('no such name: %s') % name) | 123 raise KeyError(_(b'no such name: %s') % name) |
124 | 124 |
125 | 125 |
126 class namespace(object): | 126 class namespace(object): |
127 """provides an interface to a namespace | 127 """provides an interface to a namespace |
128 | 128 |
202 self.colorname = self.logname | 202 self.colorname = self.logname |
203 | 203 |
204 # if logfmt is not specified, compose it from logname as backup | 204 # if logfmt is not specified, compose it from logname as backup |
205 if self.logfmt is None: | 205 if self.logfmt is None: |
206 # i18n: column positioning for "hg log" | 206 # i18n: column positioning for "hg log" |
207 self.logfmt = ("%s:" % self.logname).ljust(13) + "%s\n" | 207 self.logfmt = (b"%s:" % self.logname).ljust(13) + b"%s\n" |
208 | 208 |
209 if deprecated is None: | 209 if deprecated is None: |
210 self.deprecated = set() | 210 self.deprecated = set() |
211 else: | 211 else: |
212 self.deprecated = deprecated | 212 self.deprecated = deprecated |