Functions instead of variables in kwexpand()
Should be slightly faster as filectx is asked only on demand.
--- a/hgkw/keyword.py Thu Jan 11 10:37:50 2007 +0100
+++ b/hgkw/keyword.py Fri Jan 12 01:20:51 2007 +0100
@@ -47,18 +47,25 @@
their expansion if matchobj is equal to string representation.'''
c = context.filectx(repo, path,
changeid=changeid, fileid=fileid, filelog=filelog)
- date = c.date()
- Revision = c.changectx()
- Author = c.user()
- RCSFile = os.path.basename(path)+',v'
- Source = repo.wjoin(path)+',v'
- Date = util.datestr(date=date)
- revdateauth = '%s %s %s' % (Revision,
- util.datestr(date=date, format=util.defaultdateformats[0]),
- util.shortuser(Author))
- Header = '%s %s' % (Source, revdateauth)
- Id = '%s %s' % (RCSFile, revdateauth)
- return '$%s: %s $' % (matchobj.group(1), eval(matchobj.group(1)))
+ def Revision():
+ return c.changectx()
+ def Author():
+ return c.user()
+ def Date():
+ return util.datestr(date=c.date())
+ def RCSFile():
+ return os.path.basename(path)+',v'
+ def Source():
+ return repo.wjoin(path)+',v'
+ def revdateauth():
+ return '%s %s %s' % (c.changectx(),
+ util.datestr(date=c.date(), format=util.defaultdateformats[0]),
+ util.shortuser(c.user()))
+ def Header():
+ return '%s %s' % (Source(), revdateauth())
+ def Id():
+ return '%s %s' % (RCSFile(), revdateauth())
+ return '$%s: %s $' % (matchobj.group(1), eval('%s()' % matchobj.group(1)))
def kwfmatches(ui, repo, files):
'''Selects candidates for keyword substitution