[PATCH 3 of 4] keyword: enforce subn method via boolean switch
Christian Ebert
blacktrash at gmx.net
Sun Oct 10 10:17:31 CDT 2010
# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1286721226 -3600
# Node ID f2d981cda694ea815271f5e4ce6ce18d06ab93a7
# Parent 79fac2c282472239594b336f14e7c124c84aa2ce
keyword: enforce subn method via boolean switch
There are only 2 patterns to choose, and so far only 1 case
where kwtemplater.re_kw.subn is applied on data read from
the working directory: when recording added files.
With this change the code reflects more closely the boolean
character of the switch and underlines the special case.
diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -203,7 +203,7 @@
expansion are not symbolic links.'''
return [f for f in cand if self.match(f) and not 'l' in ctx.flags(f)]
- def overwrite(self, ctx, candidates, lookup, expand, recsubn=None):
+ def overwrite(self, ctx, candidates, lookup, expand, rekw=False):
'''Overwrites selected files expanding/shrinking keywords.'''
if self.restrict or lookup: # exclude kw_copy
candidates = self.iskwfile(candidates, ctx)
@@ -213,8 +213,7 @@
if self.restrict or expand and lookup:
mf = ctx.manifest()
fctx = ctx
- subn = (self.restrict and self.re_kw.subn or
- recsubn or self.re_kwexp.subn)
+ subn = (self.restrict or rekw) and self.re_kw.subn or self.re_kwexp.subn
msg = (expand and _('overwriting %s expanding keywords\n')
or _('overwriting %s shrinking keywords\n'))
for f in candidates:
@@ -583,8 +582,8 @@
if ctx != recctx:
modified, added = _preselect(wstatus, recctx.files())
kwt.restrict = False
- kwt.overwrite(recctx, modified, False, True, kwt.re_kwexp.subn)
- kwt.overwrite(recctx, added, False, True, kwt.re_kw.subn)
+ kwt.overwrite(recctx, modified, False, True)
+ kwt.overwrite(recctx, added, False, True, True)
kwt.restrict = True
return ret
finally:
More information about the Mercurial-devel
mailing list