diff -r 231b408b1f6b -r cb2b11e63906 hgkw/keyword.py --- a/hgkw/keyword.py Wed Oct 17 17:06:08 2007 +0200 +++ b/hgkw/keyword.py Wed Oct 17 17:51:36 2007 +0200 @@ -318,8 +318,15 @@ def _iskwfile(ui, man, f): return not man.linkf(f) and ui.kwfmatcher(f) -def _overwrite(ui, repo, expand, *pats, **opts): - '''Expands/shrinks keywords in working directory.''' +def _overwrite(ui, repo, files, node, man, expand, commit): + '''Passes given files to kwtemplater for overwriting.''' + if files: + files.sort() + kwt = kwtemplater(ui, repo, expand, node=node) + kwt.overwrite(files, man, commit) + +def _kwfwrite(ui, repo, expand, *pats, **opts): + '''Selects files and passes them to _overwrite.''' _bail_if_nokwconf(ui) bail_if_changed(repo) wlock = lock = None @@ -343,11 +350,8 @@ break if not f in files and match(f) and _iskwfile(ui, man, f): files.append(f) - if files: - files.sort() - kwt = kwtemplater(ui, repo, expand, node=ctx.node()) - # 3rd argument sets commit to False - kwt.overwrite(files, man, False) + # 7th argument sets commit to False + _overwrite(ui, repo, files, ctx.node(), man, expand, False) finally: del wlock, lock @@ -359,7 +363,7 @@ or if you experience problems with "hg import" or "hg merge". ''' # 3rd argument sets expansion to False - _overwrite(ui, repo, False, *pats, **opts) + _kwfwrite(ui, repo, False, *pats, **opts) def expand(ui, repo, *pats, **opts): '''expand keywords in working directory @@ -367,7 +371,7 @@ Run after (re)enabling keyword expansion. ''' # 3rd argument sets expansion to True - _overwrite(ui, repo, True, *pats, **opts) + _kwfwrite(ui, repo, True, *pats, **opts) def files(ui, repo, *pats, **opts): '''print files currently configured for keyword expansion @@ -553,12 +557,8 @@ mn = self.manifest.read(cl[0]) candidates = [f for f in cl[3] if mn.has_key(f) and _iskwfile(ui, mn, f)] - if candidates: - candidates.sort() - # 3rd argument sets expansion to True - kwt = kwtemplater(ui, self, True, node=node) - # 3rd argument sets commit to True - kwt.overwrite(candidates, mn, True) + # 6th, 7th arguments set expansion, commit to True + _overwrite(ui, self, candidates, node, mn, True, True) return node finally: del _wlock, _lock