merge with stable
authorMatt Mackall <mpm@selenic.com>
Mon, 15 Jun 2015 13:31:22 -0500
changeset 25580 a69983942fb4
parent 25579 b76410eed482 (current diff)
parent 25562 9452112c8eb0 (diff)
child 25581 79c75459321e
merge with stable
mercurial/parsers.c
mercurial/templater.py
tests/test-command-template.t
--- a/mercurial/parsers.c	Wed May 27 13:22:48 2015 -0700
+++ b/mercurial/parsers.c	Mon Jun 15 13:31:22 2015 -0500
@@ -1480,41 +1480,34 @@
 	return -2;
 }
 
-static PyObject *raise_revlog_error(void)
+static void raise_revlog_error(void)
 {
-	static PyObject *errclass;
-	PyObject *mod = NULL, *errobj;
-
-	if (errclass == NULL) {
-		PyObject *dict;
-
-		mod = PyImport_ImportModule("mercurial.error");
-		if (mod == NULL)
-			goto classfail;
+	PyObject *mod = NULL, *dict = NULL, *errclass = NULL;
 
-		dict = PyModule_GetDict(mod);
-		if (dict == NULL)
-			goto classfail;
-
-		errclass = PyDict_GetItemString(dict, "RevlogError");
-		if (errclass == NULL) {
-			PyErr_SetString(PyExc_SystemError,
-					"could not find RevlogError");
-			goto classfail;
-		}
-		Py_INCREF(errclass);
-		Py_DECREF(mod);
+	mod = PyImport_ImportModule("mercurial.error");
+	if (mod == NULL) {
+		goto cleanup;
 	}
 
-	errobj = PyObject_CallFunction(errclass, NULL);
-	if (errobj == NULL)
-		return NULL;
-	PyErr_SetObject(errclass, errobj);
-	return errobj;
+	dict = PyModule_GetDict(mod);
+	if (dict == NULL) {
+		goto cleanup;
+	}
+	Py_INCREF(dict);
 
-classfail:
+	errclass = PyDict_GetItemString(dict, "RevlogError");
+	if (errclass == NULL) {
+		PyErr_SetString(PyExc_SystemError,
+				"could not find RevlogError");
+		goto cleanup;
+	}
+
+	/* value of exception is ignored by callers */
+	PyErr_SetString(errclass, "RevlogError");
+
+cleanup:
+	Py_XDECREF(dict);
 	Py_XDECREF(mod);
-	return NULL;
 }
 
 static PyObject *index_getitem(indexObject *self, PyObject *value)
--- a/mercurial/templater.py	Wed May 27 13:22:48 2015 -0700
+++ b/mercurial/templater.py	Mon Jun 15 13:31:22 2015 -0500
@@ -266,7 +266,7 @@
 
     def getpatterns(i):
         if i < len(args):
-            s = args[i][1].strip()
+            s = stringify(args[i][0](context, mapping, args[i][1])).strip()
             if s:
                 return [s]
         return []
--- a/tests/test-command-template.t	Wed May 27 13:22:48 2015 -0700
+++ b/tests/test-command-template.t	Mon Jun 15 13:31:22 2015 -0500
@@ -2571,6 +2571,13 @@
   @@ -0,0 +1,1 @@
   +third
 
+  $ hg log -r 8 -T "{diff('FOURTH'|lower)}"
+  diff -r 29114dbae42b -r 95c24699272e fourth
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/fourth	Wed Jan 01 10:01:00 2020 +0000
+  @@ -0,0 +1,1 @@
+  +second
+
   $ cd ..