128 return super(kwfilelog, self).cmp(node, text) |
128 return super(kwfilelog, self).cmp(node, text) |
129 |
129 |
130 filelog.filelog = kwfilelog |
130 filelog.filelog = kwfilelog |
131 repo.__class__ = kwrepo |
131 repo.__class__ = kwrepo |
132 # make pretxncommit hook import kwmodule regardless of where it's located |
132 # make pretxncommit hook import kwmodule regardless of where it's located |
133 moddir = os.path.abspath(os.path.dirname(__file__)) |
133 for k, v in sys.modules.iteritems(): |
134 if os.path.dirname(moddir) in sys.path: |
134 if v is None: |
135 moddir = os.path.split(moddir)[1]+'.' |
135 continue |
|
136 if not hasattr(v, '__file__'): |
|
137 continue |
|
138 if v.__file__.startswith(__file__): |
|
139 mod = k |
|
140 break |
136 else: |
141 else: |
137 sys.path.insert(0, moddir) |
142 sys.path.insert(0, os.path.abspath(os.path.dirname(__file__))) |
138 moddir = '' |
143 mod = os.path.splitext(os.path.basename(__file__))[0] |
139 ui.setconfig('hooks', 'pretxncommit.keyword', 'python:%s%s.pretxnkw' |
144 ui.setconfig('hooks', 'pretxncommit.keyword', 'python:%s.pretxnkw' % mod) |
140 % (moddir, os.path.splitext(os.path.basename(__file__))[0])) |
145 del mod |
141 del moddir |
|
142 |
146 |
143 |
147 |
144 def pretxnkw(ui, repo, hooktype, **args): |
148 def pretxnkw(ui, repo, hooktype, **args): |
145 '''pretxncommit hook that collects candidates for keyword expansion |
149 '''pretxncommit hook that collects candidates for keyword expansion |
146 on commit and expands keywords in working dir.''' |
150 on commit and expands keywords in working dir.''' |