--- a/hgkw/keyword.py Sun Jul 15 17:28:17 2007 +0200
+++ b/hgkw/keyword.py Sun Jul 15 17:34:34 2007 +0200
@@ -94,47 +94,6 @@
'''Returns hgdate in cvs-like UTC format.'''
return time.strftime('%Y/%m/%d %H:%M:%S', time.gmtime(date[0]))
-def kwdemo(ui, repo, **opts):
- '''print [keywordmaps] configuration and an expansion example
- '''
- log = 'hg keyword config and expansion example'
- fn = 'demo.txt'
- tmpdir = tempfile.mkdtemp('', 'kwdemo.')
- if ui.verbose:
- ui.status(_('creating temporary repo at %s\n') % tmpdir)
- _repo = localrepo.localrepository(ui, path=tmpdir, create=True)
- _repo.ui.setconfig('keyword', fn, '')
- if opts['default']:
- kwstatus = 'default'
- kwmaps = deftemplates
- else:
- kwstatus = 'current'
- kwmaps = dict(ui.configitems('keywordmaps')) or deftemplates
- if ui.configitems('keywordmaps'):
- for k, v in kwmaps.items():
- _repo.ui.setconfig('keywordmaps', k, v)
- reposetup(_repo.ui, _repo)
- ui.status(_('config with %s keyword maps:\n') % kwstatus)
- ui.write('[keyword]\n%s =\n[keywordmaps]\n' % fn)
- for k, v in kwmaps.items():
- ui.write('%s = %s\n' % (k, v))
- path = _repo.wjoin(fn)
- keywords = '$' + '$\n$'.join(kwmaps.keys()) + '$\n'
- _repo.wfile(fn, 'w').write(keywords)
- _repo.add([fn])
- if ui.verbose:
- ui.status(_('\n%s keywords written to %s:\n') % (kwstatus, path))
- ui.write(keywords)
- ui.status(_("\nhg --repository '%s' commit\n") % tmpdir)
- _repo.commit(text=log)
- if ui.verbose:
- ui.status(_('\n%s keywords expanded in %s:\n') % (kwstatus, path))
- else:
- ui.status(_('\n%s keywords expanded:\n') % kwstatus)
- ui.write(_repo.wread(fn))
- ui.debug(_('\nremoving temporary repo\n'))
- shutil.rmtree(tmpdir)
-
def getcmd(ui):
'''Returns current hg command.'''
# commands.parse(ui, sys.argv[1:])[0] breaks "hg diff -r"
@@ -241,6 +200,47 @@
return super(kwfilelog, self).cmp(node, text)
+def demo(ui, repo, **opts):
+ '''print [keywordmaps] configuration and an expansion example
+ '''
+ log = 'hg keyword config and expansion example'
+ fn = 'demo.txt'
+ tmpdir = tempfile.mkdtemp('', 'kwdemo.')
+ if ui.verbose:
+ ui.status(_('creating temporary repo at %s\n') % tmpdir)
+ _repo = localrepo.localrepository(ui, path=tmpdir, create=True)
+ _repo.ui.setconfig('keyword', fn, '')
+ if opts['default']:
+ kwstatus = 'default'
+ kwmaps = deftemplates
+ else:
+ kwstatus = 'current'
+ kwmaps = dict(ui.configitems('keywordmaps')) or deftemplates
+ if ui.configitems('keywordmaps'):
+ for k, v in kwmaps.items():
+ _repo.ui.setconfig('keywordmaps', k, v)
+ reposetup(_repo.ui, _repo)
+ ui.status(_('config with %s keyword maps:\n') % kwstatus)
+ ui.write('[keyword]\n%s =\n[keywordmaps]\n' % fn)
+ for k, v in kwmaps.items():
+ ui.write('%s = %s\n' % (k, v))
+ path = _repo.wjoin(fn)
+ keywords = '$' + '$\n$'.join(kwmaps.keys()) + '$\n'
+ _repo.wfile(fn, 'w').write(keywords)
+ _repo.add([fn])
+ if ui.verbose:
+ ui.status(_('\n%s keywords written to %s:\n') % (kwstatus, path))
+ ui.write(keywords)
+ ui.status(_("\nhg --repository '%s' commit\n") % tmpdir)
+ _repo.commit(text=log)
+ if ui.verbose:
+ ui.status(_('\n%s keywords expanded in %s:\n') % (kwstatus, path))
+ else:
+ ui.status(_('\n%s keywords expanded:\n') % kwstatus)
+ ui.write(_repo.wread(fn))
+ ui.debug(_('\nremoving temporary repo\n'))
+ shutil.rmtree(tmpdir)
+
def reposetup(ui, repo):
'''Sets up repo as kwrepo for keyword substitution.
Overrides file method to return kwfilelog instead of filelog
@@ -266,12 +266,7 @@
ui = repo.ui
class kwrepo(repo.__class__):
- '''
- Subclass of repo's class attribute to wrap its file and commit methods.
- '''
-
def file(self, f):
- '''Opens kwfilelog instead of filelog if needed.'''
if f[0] == '/':
f = f[1:]
if kwfmatcher(f):
@@ -283,8 +278,6 @@
def commit(self, files=None, text='', user=None, date=None,
match=util.always, force=False, lock=None, wlock=None,
force_editor=False, p1=None, p2=None, extra={}):
- '''Wraps commit, expanding keywords of committed and
- configured files in working directory.'''
wrelease = False
if not wlock:
wlock = self.wlock()
@@ -320,7 +313,7 @@
cmdtable = {
'kwdemo':
- (kwdemo,
+ (demo,
[('d', 'default', None, _('use default keyword maps'))],
_('hg kwdemo [-d]')),
}