How to make `hg diff` show whitespace changes?

Matt Harbison mharbison72 at gmail.com
Thu Jan 14 19:03:35 CST 2016


On Thu, 14 Jan 2016 13:22:06 -0500, Matt Mackall <mpm at selenic.com> wrote:

> On Thu, 2016-01-14 at 11:04 -0500, Matt Harbison wrote:
>> (cc: list)
>>
>> On Thu, 14 Jan 2016 10:26:05 -0500, Noemi Millman  
>> <noemi.millman at backstage.com> wrote:
>>
>> >
>> > Thanks, Matt!
>> >
>> > Great call about the resource forks (and a facepalm moment for me!)   
>> I > can confirm that that's the problem, since changing the default app  
>> to > open a file without editing the file itself adds it to the list of  
>> > mysteriously changed-yet-unchanged files.
>> >
>> > I wonder why Mercurial recognizes resource fork changes but git  
>> doesn't?
>>
>> It's been a few months since I looked into it, but IIRC, the python  
>> call used to determine the file size sees both the data and resource  
>> forks.
>
> First, let's all agree that BeyondCompare devs should not fare well in  
> the
> afterlife for adding resource forks to read-only files on Unix in 2015.

It seemed more like the OS was creating a nonempty fork on first access,  
since the exact same app bundle didn't exhibit the behavior on a later OS.

I didn't run the test suite like Sean, but the patch below avoids the  
issue, and status still seemed to work detecting data fork modifications.   
I'll have to double check, but it seems like revert without this patch  
wipes out the resource fork, but update -C doesn't.  I'm not sure that we  
care since this patch means it will no longer be reported as modified  
after update -C, but I wonder if it would cause any surprises.

> Everything I can find suggests that stat(2) and os.stat ignore the  
> resource fork
> for st_size (but include it in st_blocks, which we ignore). But we're  
> actually
> using the special getdirentriesattr interface:
>
> https://www.selenic.com/hg/file/tip/mercurial/osutil.c#l483
>
> And it's complicated. But it looks like instead of ATTR_FILE_TOTALSIZE,  
> we
> should be using ATTR_FILE_DATALENGTH:
> https://developer.apple.com/library/ios/documentation/System/Conceptual/ManPages
> _iPhoneOS/man2/getattrlist.2.html#//apple_ref/doc/man/2/getattrlist
>
> Please test this patch:
>
> diff -r 443848eece18 mercurial/osutil.c
> --- a/mercurial/osutil.c	Wed Jan 13 15:47:37 2016 -0600
> +++ b/mercurial/osutil.c	Thu Jan 14 12:20:28 2016 -0600
> @@ -458,7 +458,7 @@
>  	requested_attr.bitmapcount = ATTR_BIT_MAP_COUNT;
>  	requested_attr.commonattr = (ATTR_CMN_NAME | ATTR_CMN_OBJTYPE |
>  				     ATTR_CMN_MODTIME | ATTR_CMN_ACCESSMASK);
> -	requested_attr.fileattr = ATTR_FILE_TOTALSIZE;
> +	requested_attr.fileattr = ATTR_FILE_DATALENGTH;
>   	*fallback = false;
>  --Mathematics is the supreme nostalgia of our time.


More information about the Mercurial mailing list