[PATCH 2 of 3] keyword: mimic cmdutil.bail_if_changed even more

Christian Ebert blacktrash at gmx.net
Wed Jun 11 20:28:21 CDT 2008

# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1213230426 -7200
# Node ID 6e7c0324316554ed604e8c6d93c9db7bc1198569
# Parent  a6c4ede8048dd4caa03f524e810fe28f21b4b679
keyword: mimic cmdutil.bail_if_changed even more

At the check before overwriting with kwexpand, kwshrink:
- abort when in middle of merge
- give terser abort message

diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -263,11 +263,13 @@
 def _kwfwrite(ui, repo, expand, *pats, **opts):
     '''Selects files and passes them to kwtemplater.overwrite.'''
+    if repo.dirstate.parents()[1] != nullid:
+        raise util.Abort(_('outstanding uncommitted merge'))
     kwt = kwtools['templater']
     status = _status(ui, repo, kwt, *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'))
+        raise util.Abort(_('outstanding uncommitted changes'))
     wlock = lock = None
         wlock = repo.wlock()
diff --git a/tests/test-keyword.out b/tests/test-keyword.out
--- a/tests/test-keyword.out
+++ b/tests/test-keyword.out
@@ -345,7 +345,7 @@
 % kwexpand a
 overwriting a expanding keywords
 % kwexpand x/a should abort
-abort: outstanding uncommitted changes in given files
+abort: outstanding uncommitted changes
  x/a: copy a:779c764182ce5d43e2b1eb66ce06d7b47bfe342e
 overwriting x/a expanding keywords

More information about the Mercurial-devel mailing list