# HG changeset patch # User Christian Ebert # Date 1203103053 -3600 # Node ID e089672ef9b427597bce0b91477d20e22bd93f9a # Parent 13043607c6ae17b7455a535b1b79067375de917d (0.9.2compat) incorporate changes from default branch diff -r 13043607c6ae -r e089672ef9b4 hgkw/keyword.py --- a/hgkw/keyword.py Thu Feb 14 18:55:49 2008 +0100 +++ b/hgkw/keyword.py Fri Feb 15 20:17:33 2008 +0100 @@ -108,7 +108,7 @@ # make keyword tools accessible -kwx = { 'templater': None, 'hgcmd': None } +kwtools = {'templater': None, 'hgcmd': None} # monkeypatches and backwards compatibility hacks @@ -126,7 +126,7 @@ def _kwdispatch_parse(ui, args): '''Monkeypatch dispatch._parse to obtain running hg command.''' cmd, func, args, options, cmdoptions = _dispatch_parse(ui, args) - kwx['hgcmd'] = cmd + kwtools['hgcmd'] = cmd return cmd, func, args, options, cmdoptions try: @@ -150,7 +150,7 @@ except TypeError: # "missing" arg added in e90e72c6b4c7 _patchfile_init(self, ui, fname) - self.lines = kwx['templater'].shrinklines(self.fname, self.lines) + self.lines = kwtools['templater'].shrinklines(self.fname, self.lines) except AttributeError: pass @@ -159,9 +159,9 @@ fp=None, changes=None, opts=None): # only expand if comparing against working dir if node2 is not None: - kwx['templater'].matcher = util.never + kwtools['templater'].matcher = util.never elif node1 is not None and node1 != repo.changectx().node(): - kwx['templater'].restrict = True + kwtools['templater'].restrict = True _patch_diff(repo, node1=node1, node2=node2, files=files, match=match, fp=fp, changes=changes, opts=opts) @@ -170,14 +170,14 @@ def _kwweb_changeset(web, req, tmpl): '''Wraps webcommands.changeset turning off keyword expansion.''' - if kwx['templater']: - kwx['templater'].matcher = util.never + if kwtools['templater']: + kwtools['templater'].matcher = util.never return web.changeset(tmpl, web.changectx(req)) def _kwweb_filediff(web, req, tmpl): '''Wraps webcommands.filediff turning off keyword expansion.''' - if kwx['templater']: - kwx['templater'].matcher = util.never + if kwtools['templater']: + kwtools['templater'].matcher = util.never return web.filediff(tmpl, web.filectx(req)) webcommands.changeset = webcommands.rev = _kwweb_changeset @@ -187,13 +187,13 @@ from mercurial.hgweb.hgweb_mod import hgweb def _kwweb_do_changeset(self, req): - if kwx['templater']: - kwx['templater'].matcher = util.never + if kwtools['templater']: + kwtools['templater'].matcher = util.never req.write(self.changeset(self.changectx(req))) def _kwweb_do_filediff(self, req): - if kwx['templater']: - kwx['templater'].matcher = util.never + if kwtools['templater']: + kwtools['templater'].matcher = util.never req.write(self.filediff(self.filectx(req))) hgweb.do_changeset = hgweb.do_rev = _kwweb_do_changeset @@ -311,7 +311,7 @@ self.ui = ui self.repo = repo self.matcher = util.matcher(repo.root, inc=inc, exc=exc)[1] - self.restrict = kwx['hgcmd'] in restricted.split() + self.restrict = kwtools['hgcmd'] in restricted.split() kwmaps = self.ui.configitems('keywordmaps') if kwmaps: # override default templates @@ -336,7 +336,8 @@ False, None, '', False) def getnode(self, path, fnode): - '''Derives changenode from file context.''' + '''Derives changenode from file path and filenode.''' + # used by kwfilelog.read and kwexpand c = context.filectx(self.repo, path, fileid=fnode) return c.node() @@ -426,7 +427,7 @@ ''' def __init__(self, opener, path): super(kwfilelog, self).__init__(opener, path) - self.kwt = kwx['templater'] + self.kwt = kwtools['templater'] self.path = path def read(self, node): @@ -459,7 +460,7 @@ def _kwfwrite(ui, repo, expand, *pats, **opts): '''Selects files and passes them to kwtemplater.overwrite.''' - kwt = kwx['templater'] + kwt = kwtools['templater'] status = _status(ui, repo, kwt, *pats, **opts) modified, added, removed, deleted, unknown, ignored, clean = status if modified or added or removed or deleted: @@ -570,7 +571,7 @@ keyword expansion. That is, files matched by [keyword] config patterns but not symlinks. ''' - kwt = kwx['templater'] + kwt = kwtools['templater'] status = _status(ui, repo, kwt, *pats, **opts) modified, added, removed, deleted, unknown, ignored, clean = status files = modified + added + clean @@ -615,7 +616,7 @@ files configured at all for keyword substitution.''' try: - if (not repo.local() or kwx['hgcmd'] in nokwcommands.split() + if (not repo.local() or kwtools['hgcmd'] in nokwcommands.split() or '.hg' in repo.root.split(os.sep) or repo._url.startswith('bundle:')): return @@ -631,7 +632,7 @@ if not inc: return - kwx['templater'] = kwt = kwtemplater(ui, repo, inc, exc) + kwtools['templater'] = kwt = kwtemplater(ui, repo, inc, exc) class kwrepo(repo.__class__): def file(self, f):