# HG changeset patch # User Christian Ebert # Date 1192802996 -7200 # Node ID 2088e409d3607f5542bb341621ab29a995d793b2 # Parent 1f00dce8de12a5c3bf8043d9aa5f92a4a1e855f1 Revert to using status for kw-commands cmdutil.bail_if_changed has to call status stat'ing working dir. This renders the whole walk experiment mute, duh. On the upside kwexpand/kwshrink can be applied to selected clean files, while there are local changes in other files. bail_if_changed compatibility wrapper not needed anymore. diff -r 1f00dce8de12 -r 2088e409d360 hgkw/keyword.py --- a/hgkw/keyword.py Fri Oct 19 12:36:32 2007 +0200 +++ b/hgkw/keyword.py Fri Oct 19 16:09:56 2007 +0200 @@ -98,12 +98,6 @@ except AttributeError: _parse = commands.parse -try: - # bail_if_changed moves from commands to cmdutil in 0c61124ad877 - bail_if_changed = cmdutil.bail_if_changed -except AttributeError: - bail_if_changed = commands.bail_if_changed - def _pathto(repo, f, cwd=None): '''kwfiles behaves similar to status, using pathto since 78b6add1f966.''' try: @@ -310,9 +304,10 @@ return t2 != text return revlog.revlog.cmp(self, node, text) -def _bail_if_nokwconf(ui): +def _status(ui, repo, *pats, **opts): if hasattr(ui, 'kwfmatcher'): - return + files, match, anypats = cmdutil.matchpats(repo, pats, opts) + return repo.status(files=files, match=match, list_clean=True) if ui.configitems('keyword'): raise util.Abort(_('[keyword] patterns cannot match')) raise util.Abort(_('no [keyword] patterns configured')) @@ -329,35 +324,19 @@ def _kwfwrite(ui, repo, expand, *pats, **opts): '''Selects files and passes them to _overwrite.''' - _bail_if_nokwconf(ui) - bail_if_changed(repo) + status = _status(ui, repo, *pats, **opts) + modified, added, removed, deleted, unknown, ignored, clean = status + if modified or added or removed or deleted: + raise util.Abort(_('outstanding uncommitted changes in given files')) wlock = lock = None try: wlock = repo.wlock() lock = repo.lock() - files, match, anypats = cmdutil.matchpats(repo, pats, opts) - fdict = dict.fromkeys(files) - fdict.pop('.', None) ctx = repo.changectx() man = ctx.manifest() - mfiles = man.keys() - mfiles.sort() - files = [] - for f in mfiles: - for ff in fdict: - if ff == f or ff.startswith('%s/' % f): - if _iskwfile(ui, man, ff): - files.append(ff) - del fdict[ff] - break - if not f in files and match(f) and _iskwfile(ui, man, f): - files.append(f) - ffiles = fdict.keys() - ffiles.sort() - for f in ffiles: - ui.warn(_('%s: No such file in working copy\n') % _pathto(repo, f)) + candidates = [f for f in clean if _iskwfile(ui, man, f)] # 7th argument sets commit to False - _overwrite(ui, repo, files, ctx.node(), man, expand, False) + _overwrite(ui, repo, candidates, ctx.node(), man, expand, False) finally: del wlock, lock @@ -386,9 +365,7 @@ keyword expansion. That is, files matched by [keyword] config patterns but not symlinks. ''' - _bail_if_nokwconf(ui) - files, match, anypats = cmdutil.matchpats(repo, pats, opts) - status = repo.status(files=files, match=match, list_clean=True) + status = _status(ui, repo, *pats, **opts) modified, added, removed, deleted, unknown, ignored, clean = status if opts['untracked']: files = modified + added + unknown + clean diff -r 1f00dce8de12 -r 2088e409d360 tests/test-keyword.out --- a/tests/test-keyword.out Fri Oct 19 12:36:32 2007 +0200 +++ b/tests/test-keyword.out Fri Oct 19 16:09:56 2007 +0200 @@ -225,7 +225,7 @@ xxx $ $Xinfo$ % kwexpand nonexistent -nonexistent: No such file in working copy +nonexistent: No such file or directory % switch off expansion % kwshrink with unknown file u overwriting a shrinking keywords