Remove all hgkwencode, kwexpander.py and updatekw.py
This scheme should work just with:
extension keyword.py
pretxncommit-hook pretxnkw.pretxnkw
--- a/hgkw/hgkwencode.py Tue Dec 19 15:57:03 2006 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-# $Hg$
-
-import re, sys
-
-def kwencode():
- '''Truncates hg keywords in IO stream
- from
- <Dollar>Hg: <filename> <cset id> <stuff> <Dollar>
- to
- <Dollar>Hg<Dollar>.'''
- kwrepl = r'%sHg$' % '$'
- re_kwtrunc = re.compile(r'[$]Hg: .+?,v [a-z0-9]{12} [^$]+? \$')
- sys.stdout.write(re_kwtrunc.sub(kwrepl, sys.stdin.read()))
--- a/hgkw/kwexpander.py Tue Dec 19 15:57:03 2006 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-from mercurial.i18n import _
-from mercurial import util
-import os.path, re
-
-def expandkw(ui, repo, rev, cid, candidates, update=False):
- '''Expands logged <Dollar>Hg<Dollar> in working directory.'''
-
- # name of keyword encode filter:
- kwencodefilter = 'hgkwencode'
-
- # update only needs string search for encoded keyword
- # as hgkwencode always runs before
- kwstr = '$Hg$'
-
- # pretxncommit looks for both encoded and decoded keywords
- re_kw = re.compile(r'\$Hg[^$]*?\$')
-
- def wwritekw(ui, repo, f, text):
- '''Writes text with kwupdates keywords to f in working directory.'''
- ui.note(_('expanding keywords in %s\n' % f))
- # backup file, at least when commiting (?)
- repo.wfile(f, 'w').write(text)
-
- # only check files that have hgkwencode assigned as encode filter
-# files = []
- # python2.4: files = set()
-# for pat, cmd in repo.ui.configitems('encode'):
-# if cmd.endswith(kwencodefilter):
-# mf = util.matcher(repo.root, '', [pat], [], [])[1]
-# for candidate in candidates:
-# if mf(candidate) and candidate not in files:
-# files.append(candidate)
- # python2.4:
- # if mf(candidate): files.add(candidate)
-
-# if not files: # nothing to do
-# return False
- files = candidates
-
- user, date = repo.changelog.read(rev)[1:3]
- user = util.shortuser(user)
- date = util.datestr(date=date, format=util.defaultdateformats[0])
- # %Y-%m-%d %H:%M:%S
-
- # collect filenames that were changed by hg update
- kwupdates = []
-
- for f in files:
-
- text = repo.wfile(f).read()
- if not util.binary(text):
-
- # TODO for update:
- # walk back through file history onto last add/modify
- # like "hg log -l1 f"
- kw = '$Hg: %s,v %s %s %s $' % (
- os.path.basename(f), cid, date, user)
-
- if update and text.find(kwstr) > -1:
- text = text.replace(kwstr, kw)
- wwritekw(ui, repo, f, text)
- kwupdates.append(f)
-
- elif not update:
- text, kwct = re_kw.subn(kw, text)
- if kwct:
- wwritekw(ui, repo, f, text)
-
- if kwupdates:
- # cheat hg to believe that updated files were not modified
- repo.dirstate.update(kwupdates, 'n')
--- a/hgkw/updatekw.py Tue Dec 19 15:57:03 2006 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-# $Hg$
-
-import kwexpander
-
-def updatekw(ui, repo, hooktype, **args):
- '''Collects candidates for keyword expansion on update
- and passes them to kwexpander.'''
-
- if hooktype != 'update':
- # bail out with error
- return True
-
- n1, n2 = args['parent1'], args['parent2']
- r1 = repo.changelog.lookup(n1)
- if n2:
- r2 = repo.changelog.lookup(n2)
- # next line for debugging only (check merges)
- ui.warn('parent2: %s\n' % n2)
- else:
- r2 = None
-
- (modified, added, removed, deleted,
- unknown, ignored, clean) = repo.status(node1=r1, node2=r2)
- candidates = modified + added + clean
-
- if candidates:
- return kwexpander.expandkw(ui, repo, r1, n1, candidates, update=True)
--- a/hgkwencode Tue Dec 19 15:57:03 2006 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-#!/usr/bin/env python
-# $Hg$
-
-from hgkw import hgkwencode
-hgkwencode.kwencode()