Mercurial > hgrepos > DevTools > mercurial-extensions
diff extensions/kwarchive.py @ 29:58f47399691c
New successful PoC: monkey-patch all relevant archiver's "addfile()" method
| author | Franz Glasner <hg@dom66.de> |
|---|---|
| date | Sat, 11 Nov 2017 12:17:12 +0100 |
| parents | c8b7d0635656 |
| children | 1670760f695f |
line wrap: on
line diff
--- a/extensions/kwarchive.py Fri Nov 10 09:14:16 2017 +0100 +++ b/extensions/kwarchive.py Sat Nov 11 12:17:12 2017 +0100 @@ -74,9 +74,6 @@ Returns 0 on success. ''' - print "HUHU" - repo.adddatafilter("filter2", filter2) - repo.ui.setconfig("decode", "**.py", "filter2", 'kw') opts = pycompat.byteskwargs(opts) ctx = scmutil.revsingle(repo, opts.get('rev')) if not ctx: @@ -98,9 +95,23 @@ prefix = cmdutil.makefilename(repo, prefix, node) matchfn = scmutil.match(ctx, [], opts) + + # + # Monkey patch archival's archivers so that an archiver's "addfile()" + # expands keywords + # + + orig_fileit_addfile = archival.fileit.addfile + def new_fileit_addfile(self, name, mode, isline, data): + print "ARCHIVER: --------------->", name, mode, isline + return orig_fileit_addfile(self, name, mode, isline, data) + archival.fileit.addfile = new_fileit_addfile + archival.archive(repo, dest, node, kind, not opts.get('no_decode'), matchfn, prefix, subrepos=opts.get('subrepos')) + # XXX FIXME: Should we restore the original methods here? + def filter2(s, params, ui, **kwargs): print "=============>", repr(params), repr(kwargs)
