Show More
@@ -130,6 +130,7 b' from mercurial.i18n import _' | |||||
130 |
|
130 | |||
131 | from mercurial import ( |
|
131 | from mercurial import ( | |
132 | config, |
|
132 | config, | |
|
133 | context, | |||
133 | error, |
|
134 | error, | |
134 | exchange, |
|
135 | exchange, | |
135 | extensions, |
|
136 | extensions, | |
@@ -329,6 +330,8 b' def _resolverevlogstorevfsoptions(orig, ' | |||||
329 | def _extsetup(ui): |
|
330 | def _extsetup(ui): | |
330 | wrapfilelog(filelog.filelog) |
|
331 | wrapfilelog(filelog.filelog) | |
331 |
|
332 | |||
|
333 | context.basefilectx.islfs = wrapper.filectxislfs | |||
|
334 | ||||
332 | scmutil.fileprefetchhooks.add('lfs', wrapper._prefetchfiles) |
|
335 | scmutil.fileprefetchhooks.add('lfs', wrapper._prefetchfiles) | |
333 |
|
336 | |||
334 | # Make bundle choose changegroup3 instead of changegroup2. This affects |
|
337 | # Make bundle choose changegroup3 instead of changegroup2. This affects |
@@ -208,7 +208,6 b' def filectxisbinary(orig, self):' | |||||
208 | return bool(int(metadata.get('x-is-binary', 1))) |
|
208 | return bool(int(metadata.get('x-is-binary', 1))) | |
209 | return orig(self) |
|
209 | return orig(self) | |
210 |
|
210 | |||
211 | @eh.addattr(context.basefilectx, 'islfs') |
|
|||
212 | def filectxislfs(self): |
|
211 | def filectxislfs(self): | |
213 | return _islfs(self.filelog(), self.filenode()) |
|
212 | return _islfs(self.filelog(), self.filenode()) | |
214 |
|
213 |
@@ -82,7 +82,6 b' class exthelper(object):' | |||||
82 | self._commandwrappers = [] |
|
82 | self._commandwrappers = [] | |
83 | self._extcommandwrappers = [] |
|
83 | self._extcommandwrappers = [] | |
84 | self._functionwrappers = [] |
|
84 | self._functionwrappers = [] | |
85 | self._duckpunchers = [] |
|
|||
86 | self.cmdtable = {} |
|
85 | self.cmdtable = {} | |
87 | self.command = registrar.command(self.cmdtable) |
|
86 | self.command = registrar.command(self.cmdtable) | |
88 | self.configtable = {} |
|
87 | self.configtable = {} | |
@@ -102,7 +101,6 b' class exthelper(object):' | |||||
102 | self._commandwrappers.extend(other._commandwrappers) |
|
101 | self._commandwrappers.extend(other._commandwrappers) | |
103 | self._extcommandwrappers.extend(other._extcommandwrappers) |
|
102 | self._extcommandwrappers.extend(other._extcommandwrappers) | |
104 | self._functionwrappers.extend(other._functionwrappers) |
|
103 | self._functionwrappers.extend(other._functionwrappers) | |
105 | self._duckpunchers.extend(other._duckpunchers) |
|
|||
106 | self.cmdtable.update(other.cmdtable) |
|
104 | self.cmdtable.update(other.cmdtable) | |
107 | for section, items in other.configtable.iteritems(): |
|
105 | for section, items in other.configtable.iteritems(): | |
108 | if section in self.configtable: |
|
106 | if section in self.configtable: | |
@@ -129,8 +127,6 b' class exthelper(object):' | |||||
129 | - Setup of pre-* and post-* hooks |
|
127 | - Setup of pre-* and post-* hooks | |
130 | - pushkey setup |
|
128 | - pushkey setup | |
131 | """ |
|
129 | """ | |
132 | for cont, funcname, func in self._duckpunchers: |
|
|||
133 | setattr(cont, funcname, func) |
|
|||
134 | for command, wrapper, opts in self._commandwrappers: |
|
130 | for command, wrapper, opts in self._commandwrappers: | |
135 | entry = extensions.wrapcommand(commands.table, command, wrapper) |
|
131 | entry = extensions.wrapcommand(commands.table, command, wrapper) | |
136 | if opts: |
|
132 | if opts: | |
@@ -302,29 +298,3 b' class exthelper(object):' | |||||
302 | self._functionwrappers.append((container, funcname, wrapper)) |
|
298 | self._functionwrappers.append((container, funcname, wrapper)) | |
303 | return wrapper |
|
299 | return wrapper | |
304 | return dec |
|
300 | return dec | |
305 |
|
||||
306 | def addattr(self, container, funcname): |
|
|||
307 | """Decorated function is to be added to the container |
|
|||
308 |
|
||||
309 | This function takes two arguments, the container and the name of the |
|
|||
310 | function to wrap. The wrapping is performed during `uisetup`. |
|
|||
311 |
|
||||
312 | Adding attributes to a container like this is discouraged, because the |
|
|||
313 | container modification is visible even in repositories that do not |
|
|||
314 | have the extension loaded. Therefore, care must be taken that the |
|
|||
315 | function doesn't make assumptions that the extension was loaded for the |
|
|||
316 | current repository. For `ui` and `repo` instances, a better option is |
|
|||
317 | to subclass the instance in `uipopulate` and `reposetup` respectively. |
|
|||
318 |
|
||||
319 | https://www.mercurial-scm.org/wiki/WritingExtensions |
|
|||
320 |
|
||||
321 | example:: |
|
|||
322 |
|
||||
323 | @eh.addattr(context.changectx, 'babar') |
|
|||
324 | def babar(ctx): |
|
|||
325 | return 'babar' in ctx.description |
|
|||
326 | """ |
|
|||
327 | def dec(func): |
|
|||
328 | self._duckpunchers.append((container, funcname, func)) |
|
|||
329 | return func |
|
|||
330 | return dec |
|
General Comments 0
You need to be logged in to leave comments.
Login now