Mercurial > evolve
comparison hgext3rd/serverminitopic.py @ 4814:48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Using the format-source extension smooth out the pain of merging after
auto-formatting.
This change makes all of the Evolve test suite pass under python3 and has
added benefit of being 100% automated using mercurial's `byteify-strings`
script version 1.0 (revision 11498aa91c036c6d70f7ac5ee5af2664a84a1130).
How to benefit from the help of format-source is explained in the README.
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Tue, 06 Aug 2019 15:06:38 +0200 |
parents | 079dbf36e884 |
children | 51d0f2355215 |
comparison
equal
deleted
inserted
replaced
4812:67567d7f1174 | 4814:48b30ff742cb |
---|---|
31 | 31 |
32 if util.safehasattr(registrar, 'configitem'): | 32 if util.safehasattr(registrar, 'configitem'): |
33 | 33 |
34 configtable = {} | 34 configtable = {} |
35 configitem = registrar.configitem(configtable) | 35 configitem = registrar.configitem(configtable) |
36 configitem('experimental', 'server-mini-topic', | 36 configitem(b'experimental', b'server-mini-topic', |
37 default=False, | 37 default=False, |
38 ) | 38 ) |
39 | 39 |
40 def hasminitopic(repo): | 40 def hasminitopic(repo): |
41 """true if minitopic is enabled on the repository | 41 """true if minitopic is enabled on the repository |
42 | 42 |
43 (The value is cached on the repository) | 43 (The value is cached on the repository) |
44 """ | 44 """ |
45 enabled = getattr(repo, '_hasminitopic', None) | 45 enabled = getattr(repo, '_hasminitopic', None) |
46 if enabled is None: | 46 if enabled is None: |
47 enabled = (repo.ui.configbool('experimental', 'server-mini-topic') | 47 enabled = (repo.ui.configbool(b'experimental', b'server-mini-topic') |
48 and not repo.publishing()) | 48 and not repo.publishing()) |
49 repo._hasminitopic = enabled | 49 repo._hasminitopic = enabled |
50 return enabled | 50 return enabled |
51 | 51 |
52 ### make topic visible though "ctx.branch()" | 52 ### make topic visible though "ctx.branch()" |
53 | 53 |
54 def topicbranch(orig, self): | 54 def topicbranch(orig, self): |
55 branch = orig(self) | 55 branch = orig(self) |
56 if hasminitopic(self._repo) and self.phase(): | 56 if hasminitopic(self._repo) and self.phase(): |
57 topic = self._changeset.extra.get('topic') | 57 topic = self._changeset.extra.get(b'topic') |
58 if topic is not None: | 58 if topic is not None: |
59 topic = encoding.tolocal(topic) | 59 topic = encoding.tolocal(topic) |
60 branch = '%s:%s' % (branch, topic) | 60 branch = b'%s:%s' % (branch, topic) |
61 return branch | 61 return branch |
62 | 62 |
63 ### avoid caching topic data in rev-branch-cache | 63 ### avoid caching topic data in rev-branch-cache |
64 | 64 |
65 class revbranchcacheoverlay(object): | 65 class revbranchcacheoverlay(object): |
118 key = node.nullid | 118 key = node.nullid |
119 revs = sorted(revs) | 119 revs = sorted(revs) |
120 if revs: | 120 if revs: |
121 s = hashlib.sha1() | 121 s = hashlib.sha1() |
122 for rev in revs: | 122 for rev in revs: |
123 s.update('%d;' % rev) | 123 s.update(b'%d;' % rev) |
124 key = s.digest() | 124 key = s.digest() |
125 return key | 125 return key |
126 | 126 |
127 # needed to prevent reference used for 'super()' call using in branchmap.py to | 127 # needed to prevent reference used for 'super()' call using in branchmap.py to |
128 # no go into cycle. (yes, URG) | 128 # no go into cycle. (yes, URG) |
136 yield | 136 yield |
137 finally: | 137 finally: |
138 branchmap.branchcache = previous | 138 branchmap.branchcache = previous |
139 | 139 |
140 _publiconly = set([ | 140 _publiconly = set([ |
141 'base', | 141 b'base', |
142 'immutable', | 142 b'immutable', |
143 ]) | 143 ]) |
144 | 144 |
145 def mighttopic(repo): | 145 def mighttopic(repo): |
146 return hasminitopic(repo) and repo.filtername not in _publiconly | 146 return hasminitopic(repo) and repo.filtername not in _publiconly |
147 | 147 |
214 # advertise topic capabilities | 214 # advertise topic capabilities |
215 | 215 |
216 def wireprotocaps(orig, repo, proto): | 216 def wireprotocaps(orig, repo, proto): |
217 caps = orig(repo, proto) | 217 caps = orig(repo, proto) |
218 if hasminitopic(repo): | 218 if hasminitopic(repo): |
219 caps.append('topics') | 219 caps.append(b'topics') |
220 return caps | 220 return caps |
221 | 221 |
222 # wrap the necessary bit | 222 # wrap the necessary bit |
223 | 223 |
224 def wrapclass(container, oldname, new): | 224 def wrapclass(container, oldname, new): |