Johan Corveleyn wrote:
> Just thinking out loud here, but could we perhaps log the
> non-canonical value as part of the assertion output?
> [...]
> something like
>
> line 10238: assertion failed
> (svn_dirent_is_absolute(local_abspath='C:ImNotCanonical'))
Yes, Johan, we could do that.
The attached patch demonstrates it working.
Test output:
[[[
$ subversion/tests/libsvn_wc/wc-test 1
...
svn_tests: E235000: In file '.../subversion/libsvn_wc/wc_db.c' line 10238:
assertion failed (svn_dirent_is_absolute(local_abspath='C:ImNotAbsolute'))
...
]]]
--
- Julian
Proof of concept: let 'dirent is absolute' assertion display the offending
path.
Test output:
[[[
$ subversion/tests/libsvn_wc/wc-test 1
...
svn_tests: E235000: In file '.../subversion/libsvn_wc/wc_db.c' line 10238: assertion failed (svn_dirent_is_absolute(local_abspath='C:ImNotAbsolute'))
...
]]]
* subversion/include/svn_error.h,
subversion/libsvn_subr/error.c
(svn_error__malfunction_f): New, varargs version of svn_error__malfunction.
(SVN_ASSERT_DIRENT_IS_ABSOLUTE): New.
* subversion/libsvn_wc/wc_db.c
(svn_wc__db_read_repos_info): Use it.
* subversion/libsvn_wc/node.c
(svn_wc__node_get_repos_info): (destructively) test it.
--This line, and those below, will be ignored--
Index: subversion/include/svn_error.h
===================================================================
--- subversion/include/svn_error.h (revision 1848560)
+++ subversion/include/svn_error.h (working copy)
@@ -620,12 +620,29 @@ svn_error_t *svn_error_purge_tracing(svn
*/
svn_error_t *
svn_error__malfunction(svn_boolean_t can_return,
const char *file,
int line,
const char *expr);
+svn_error_t *
+svn_error__malfunction_f(svn_boolean_t can_return,
+ const char *file, int line,
+ const char *fmt, ...);
+
+/** Assert a given dirent is absolute.
+ *
+ * Shows the offending path in the error message, unlike
+ * assert(svn_dirent_is_absolute(abspath)).
+ */
+#define SVN_ASSERT_DIRENT_IS_ABSOLUTE(abspath) \
+ do { \
+ if (!svn_dirent_is_absolute(abspath)) \
+ SVN_ERR(svn_error__malfunction_f(TRUE, __FILE__, __LINE__, \
+ "svn_dirent_is_absolute(%s='%s')", \
+ #abspath, abspath)); \
+ } while (0)
/** A type of function that handles an assertion failure or other internal
* malfunction detected within the Subversion libraries.
*
* The error occurred in the source file @a file at line @a line, and was an
* assertion failure of the expression @a expr, or, if @a expr is null, an
Index: subversion/libsvn_subr/error.c
===================================================================
--- subversion/libsvn_subr/error.c (revision 1848560)
+++ subversion/libsvn_subr/error.c (working copy)
@@ -880,6 +880,21 @@
return malfunction_handler(can_return, file, line, expr);
}
+svn_error_t *
+svn_error__malfunction_f(svn_boolean_t can_return,
+ const char *file, int line,
+ const char *fmt, ...)
+{
+ apr_pool_t *pool = svn_pool_create(NULL);
+ va_list ap;
+ const char *expr;
+
+ va_start(ap, fmt);
+ expr = apr_pvsprintf(pool, fmt, ap);
+ va_end(ap);
+ return malfunction_handler(can_return, file, line, expr);
+}
+
/* Misc. */
Index: subversion/libsvn_wc/wc_db.c
===================================================================
--- subversion/libsvn_wc/wc_db.c (revision 1848560)
+++ subversion/libsvn_wc/wc_db.c (working copy)
@@ -10235,7 +10235,7 @@
const char *local_relpath;
apr_int64_t repos_id = INVALID_REPOS_ID;
- SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
+ SVN_ASSERT_DIRENT_IS_ABSOLUTE(local_abspath);
SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&wcroot, &local_relpath, db,
local_abspath,
Index: subversion/libsvn_wc/node.c
===================================================================
--- subversion/libsvn_wc/node.c (revision 1848560)
+++ subversion/libsvn_wc/node.c (working copy)
@@ -124,6 +124,7 @@
apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
{
+ local_abspath = "C:ImNotAbsolute";
return svn_error_trace(
svn_wc__db_read_repos_info(revision,
repos_relpath,