[Bug 6965] New: hg diff -p is confused by function names that start with an underscore
mercurial-bugs at mercurial-scm.org
mercurial-bugs at mercurial-scm.org
Fri Apr 18 02:43:01 UTC 2025
https://bz.mercurial-scm.org/show_bug.cgi?id=6965
Bug ID: 6965
Summary: hg diff -p is confused by function names that start
with an underscore
Product: Mercurial
Version: 6.8.1
Hardware: PC
OS: NetBSD
Status: UNCONFIRMED
Severity: feature
Priority: wish
Component: Mercurial
Assignee: bugzilla at mercurial-scm.org
Reporter: mercurial-bugzilla at campbell.mumble.net
CC: mercurial-devel at mercurial-scm.org
Python Version: ---
For example:
Elf_Addr
_rtld(...)
{
`hg diff -p' shows `Elf_Addr' as the context, but it should show `_rtld(...)'
as the context. If I change the name from `_rtld' to `rtld' it works as
expected.
Test case (currently fails):
#!/usr/bin/env cram
$ export HGRCPATH="$(pwd)/.hgrc"
$ cat <<EOF >$HGRCPATH
> [ui]
> username = foo at example.com
> interactive = no
> quiet = yes
> verbose = no
> EOF
Create a repository and add a file:
$ hg init repo
$ cat <<EOF >repo/foo.c
> #include <stdio.h>
>
> /*
> * comment
> */
> Elf_Addr
> _rtld(void)
> {
> EOF
$ for i in 0 1 2 3; do for j in 0 1 2 3; do printf '\tprintf("foo %d
%d\\n");\n' $i $j; done; done >>repo/foo.c
$ printf '\treturn 0;\n' >>repo/foo.c
$ cat <<EOF >>repo/foo.c
> }
> EOF
$ hg -R repo add repo/foo.c
$ hg -R repo commit -d '0 1' -m 'initial tree' repo/foo.c
Change a line in the file and view the diff with function context --
should show the function name, but actually shows the return type, as
the context:
$ sed -i -e 's/foo 2 2/bar 2 2/' repo/foo.c
$ hg diff -p --nodates repo/foo.c
diff -r 689a7b2c7d0a foo.c
--- a/foo.c
+++ b/foo.c
@@ -16,7 +16,7 @@ _rtld(void)
\tprintf("foo 1 3\\n"); (esc)
\tprintf("foo 2 0\\n"); (esc)
\tprintf("foo 2 1\\n"); (esc)
-\tprintf("foo 2 2\\n"); (esc)
+\tprintf("bar 2 2\\n"); (esc)
\tprintf("foo 2 3\\n"); (esc)
\tprintf("foo 3 0\\n"); (esc)
\tprintf("foo 3 1\\n"); (esc)
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Mercurial-devel
mailing list