comparison hgext/fastannotate/support.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 c59eb1560c44
comparison
equal deleted inserted replaced
43076:2372284d9457 43077:687b865b95ad
62 return results 62 return results
63 63
64 64
65 def _getmaster(fctx): 65 def _getmaster(fctx):
66 """(fctx) -> str""" 66 """(fctx) -> str"""
67 return fctx._repo.ui.config('fastannotate', 'mainbranch') or 'default' 67 return fctx._repo.ui.config(b'fastannotate', b'mainbranch') or b'default'
68 68
69 69
70 def _doannotate(fctx, follow=True, diffopts=None): 70 def _doannotate(fctx, follow=True, diffopts=None):
71 """like the vanilla fctx.annotate, but do it via fastannotate, and make 71 """like the vanilla fctx.annotate, but do it via fastannotate, and make
72 the output format compatible with the vanilla fctx.annotate. 72 the output format compatible with the vanilla fctx.annotate.
81 fctx.rev(), master=master, showpath=True, showlines=True 81 fctx.rev(), master=master, showpath=True, showlines=True
82 ) 82 )
83 except Exception: 83 except Exception:
84 ac.rebuild() # try rebuild once 84 ac.rebuild() # try rebuild once
85 fctx._repo.ui.debug( 85 fctx._repo.ui.debug(
86 'fastannotate: %s: rebuilding broken cache\n' % fctx._path 86 b'fastannotate: %s: rebuilding broken cache\n' % fctx._path
87 ) 87 )
88 try: 88 try:
89 annotated, contents = ac.annotate( 89 annotated, contents = ac.annotate(
90 fctx.rev(), master=master, showpath=True, showlines=True 90 fctx.rev(), master=master, showpath=True, showlines=True
91 ) 91 )
96 return _convertoutputs(fctx._repo, annotated, contents) 96 return _convertoutputs(fctx._repo, annotated, contents)
97 97
98 98
99 def _hgwebannotate(orig, fctx, ui): 99 def _hgwebannotate(orig, fctx, ui):
100 diffopts = patch.difffeatureopts( 100 diffopts = patch.difffeatureopts(
101 ui, untrusted=True, section='annotate', whitespace=True 101 ui, untrusted=True, section=b'annotate', whitespace=True
102 ) 102 )
103 return _doannotate(fctx, diffopts=diffopts) 103 return _doannotate(fctx, diffopts=diffopts)
104 104
105 105
106 def _fctxannotate( 106 def _fctxannotate(
113 ) 113 )
114 try: 114 try:
115 return _doannotate(self, follow, diffopts) 115 return _doannotate(self, follow, diffopts)
116 except Exception as ex: 116 except Exception as ex:
117 self._repo.ui.debug( 117 self._repo.ui.debug(
118 'fastannotate: falling back to the vanilla ' 'annotate: %r\n' % ex 118 b'fastannotate: falling back to the vanilla ' b'annotate: %r\n' % ex
119 ) 119 )
120 return orig(self, follow=follow, skiprevs=skiprevs, diffopts=diffopts) 120 return orig(self, follow=follow, skiprevs=skiprevs, diffopts=diffopts)
121 121
122 122
123 def _remotefctxannotate(orig, self, follow=False, skiprevs=None, diffopts=None): 123 def _remotefctxannotate(orig, self, follow=False, skiprevs=None, diffopts=None):
128 self, follow, skiprevs=skiprevs, diffopts=diffopts, prefetchskip=skipset 128 self, follow, skiprevs=skiprevs, diffopts=diffopts, prefetchskip=skipset
129 ) 129 )
130 130
131 131
132 def replacehgwebannotate(): 132 def replacehgwebannotate():
133 extensions.wrapfunction(hgweb.webutil, 'annotate', _hgwebannotate) 133 extensions.wrapfunction(hgweb.webutil, b'annotate', _hgwebannotate)
134 134
135 135
136 def replacefctxannotate(): 136 def replacefctxannotate():
137 extensions.wrapfunction(hgcontext.basefilectx, 'annotate', _fctxannotate) 137 extensions.wrapfunction(hgcontext.basefilectx, b'annotate', _fctxannotate)