comparison mercurial/hg.py @ 20858:bc56ec9e64df stable

hg: introduce "wirepeersetupfuncs" to setup wire peer by extensions (issue4109) Since changeset 6f72e7d28b35, "reposetup()" of each extensions is invoked only on repositories enabling corresponded extensions. This causes that largefiles specific interactions between the repository enabling largefiles locally and remote (wire) peer fail, because there is no way to know whether largefiles is enabled on the remote repository behind the wire peer, and largefiles specific "wireproto functions" are not given to any wire peers. To avoid this problem, largefiles should be enabled in wider scope than each repositories (e.g. user-wide "${HOME}/.hgrc"). This patch introduces "wirepeersetupfuncs" to setup wire peer by extensions already enabled. Functions registered into "wirepeersetupfuncs" are invoked for all wire peers. This patch uses plain list instead of "util.hooks" for "wirepeersetupfuncs", because the former allows to control order of function invocation by order of extension enabling: it may be useful for workaround of problems with combination of enabled extensions
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Sat, 29 Mar 2014 01:20:07 +0900
parents dda11e799529
children 5db105f216c3 81d6dc8c3c63
comparison
equal deleted inserted replaced
20857:6eb55310fcbc 20858:bc56ec9e64df
96 if pathurl.islocal(): 96 if pathurl.islocal():
97 return util.posixfile(pathurl.localpath(), 'rb') 97 return util.posixfile(pathurl.localpath(), 'rb')
98 else: 98 else:
99 return url.open(ui, path) 99 return url.open(ui, path)
100 100
101 # a list of (ui, repo) functions called for wire peer initialization
102 wirepeersetupfuncs = []
103
101 def _peerorrepo(ui, path, create=False): 104 def _peerorrepo(ui, path, create=False):
102 """return a repository object for the specified path""" 105 """return a repository object for the specified path"""
103 obj = _peerlookup(path).instance(ui, path, create) 106 obj = _peerlookup(path).instance(ui, path, create)
104 ui = getattr(obj, "ui", ui) 107 ui = getattr(obj, "ui", ui)
105 for name, module in extensions.extensions(ui): 108 for name, module in extensions.extensions(ui):
106 hook = getattr(module, 'reposetup', None) 109 hook = getattr(module, 'reposetup', None)
107 if hook: 110 if hook:
108 hook(ui, obj) 111 hook(ui, obj)
112 if not obj.local():
113 for f in wirepeersetupfuncs:
114 f(ui, obj)
109 return obj 115 return obj
110 116
111 def repository(ui, path='', create=False): 117 def repository(ui, path='', create=False):
112 """return a repository object for the specified path""" 118 """return a repository object for the specified path"""
113 peer = _peerorrepo(ui, path, create) 119 peer = _peerorrepo(ui, path, create)