Reduce verbosity of kwexpand/kwshrink
authorChristian Ebert <blacktrash@gmx.net>
Sun, 23 Sep 2007 12:22:13 +0100
changeset 250 b28a2832cba4
parent 249 8df281c5ca8b
child 251 b37f2f065a9c
Reduce verbosity of kwexpand/kwshrink
hgkw/keyword.py
tests/test-keyword
tests/test-keyword.out
--- a/hgkw/keyword.py	Fri Sep 21 20:22:21 2007 +0100
+++ b/hgkw/keyword.py	Sun Sep 23 12:22:13 2007 +0100
@@ -80,8 +80,8 @@
         Or, better, use bundle/unbundle to share changes.
 '''
 
-from mercurial import commands, cmdutil, context, fancyopts, filelog
-from mercurial import localrepo, revlog, templater, util, hg
+from mercurial import commands, cmdutil, context, fancyopts
+from mercurial import filelog, localrepo, revlog, templater, util
 from mercurial.i18n import gettext as _
 import getopt, re, shutil, sys, tempfile, time
 
@@ -326,8 +326,6 @@
         lock = repo.lock()
         bail_if_changed(repo)
         ctx = repo.changectx()
-        if not ctx:
-            raise hg.RepoError(_('no revision checked out'))
         kwfmatcher = _keywordmatcher(ui, repo)
         if kwfmatcher is None:
             ui.warn(_('no files configured for keyword expansion\n'))
@@ -337,12 +335,10 @@
             cwd = repo.getcwd()
             files = [util.canonpath(repo.root, cwd, f) for f in files]
         files = _weedcandidates(man, kwfmatcher, files)
-        if not files:
-            ui.warn(_('files not configured for expansion or untracked\n'))
-            return
-        kwt = kwtemplater(ui, repo, expand, node=ctx.node())
-        # 3rd argument sets commit to False
-        kwt.overwrite(files, man, False)
+        if files:
+            kwt = kwtemplater(ui, repo, expand, node=ctx.node())
+            # 3rd argument sets commit to False
+            kwt.overwrite(files, man, False)
     finally:
         del wlock, lock
 
--- a/tests/test-keyword	Fri Sep 21 20:22:21 2007 +0100
+++ b/tests/test-keyword	Sun Sep 23 12:22:13 2007 +0100
@@ -25,7 +25,7 @@
 hg init Test
 cd Test
 
-echo % kwshrink should abort in empty/invalid repo
+echo % kwshrink should exit silently in empty/invalid repo
 hg kwshrink
 
 echo 'expand $Id$' > a
--- a/tests/test-keyword.out	Fri Sep 21 20:22:21 2007 +0100
+++ b/tests/test-keyword.out	Sun Sep 23 12:22:13 2007 +0100
@@ -65,8 +65,7 @@
 [keywordmaps]
 Branch = {branches}
 $Branch: demobranch $
-% kwshrink should abort in empty/invalid repo
-abort: no revision checked out!
+% kwshrink should exit silently in empty/invalid repo
 % cat
 expand $Id$
 do not process $Id: