How does "hg status" look at symlinks?

Nikolaus Rath Nikolaus at rath.org
Sun May 1 22:02:37 UTC 2011


On 04/29/2011 07:50 PM, Mads Kiilerich wrote:
> Nikolaus Rath wrote, On 04/29/2011 10:00 PM:
>> Hello,
>>
>> Consider this:
>>
>> $ rm -r test2 mnt/test/
>> $ cp -a test/ test2
>> $ cp -a test/ mnt/
>> $ (cd test2; hg status)
>> $ (cd mnt/test/; hg status)
>> M b
>>
>> So there were no uncommited changes in the original, but one of the
>> copies now appears to have a change. However, when looking at the
>> affected symlink:
>>
>> $ stat test/b
>>    File: `test/b' ->  `a'
>>    Size: 1             Blocks: 0          IO Block: 4096   symbolic link
>> Device: fe05h/65029d    Inode: 1311221     Links: 1
>> Access: (0777/lrwxrwxrwx)  Uid: ( 1000/nikratio)   Gid: ( 1000/nikratio)
>> Access: 2011-04-29 15:17:49.275140899 -0400
>> Modify: 2011-04-29 15:17:48.867140898 -0400
>> Change: 2011-04-29 15:17:48.867140898 -0400
>>
>> $ stat test2/b
>>    File: `test2/b' ->  `a'
>>    Size: 1             Blocks: 0          IO Block: 4096   symbolic link
>> Device: fe05h/65029d    Inode: 1312535     Links: 1
>> Access: (0777/lrwxrwxrwx)  Uid: ( 1000/nikratio)   Gid: ( 1000/nikratio)
>> Access: 2011-04-29 15:45:29.975140254 -0400
>> Modify: 2011-04-29 15:17:48.867140898 -0400
>> Change: 2011-04-29 15:45:12.403140260 -0400
>>
>> $ stat mnt/test/b
>>    File: `mnt/test/b' ->  `a'
>>    Size: 0             Blocks: 0          IO Block: 131072 symbolic link
>> Device: 16h/22d    Inode: 1679117926  Links: 1
>> Access: (0777/lrwxrwxrwx)  Uid: ( 1000/nikratio)   Gid: ( 1000/nikratio)
>> Access: 2011-04-29 15:45:33.859647035 -0400
>> Modify: 2011-04-29 15:17:48.867141008 -0400
>> Change: 2011-04-29 15:45:14.912662029 -0400
>>
>>
>> I can't see any reason why Mercurial would detect a change in one of the
>> copies, but not the other.
>>
>> I suspect that this is a bug in the file system mounted at mnt/, but
>> it's hard to say without knowing *why* hg things that the file has
>> changed.
>>
>> I tried to run hg --debug status, but that didn't provide any additional
>> output at all.
>>
>>
>> Can someone tell me how to figure out what makes hg think that the file
>> has changed?
> 
> 'hg debugstate' will tell you that Mercurial expects 'b' to be a symlink
> with a 'content' of length 1. I guess 'hg status' does the same as your
> 'stat' and sees that the length of the 'content' of the symlink is
> reported as 0, so it concludes that the symlink has changed. It seems
> strange and wrong that the size is reported as 0.


Ah, that's it. And lstat(2) indeed says that st_size should be the
target length for a symlink. Thanks!


Best,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C



More information about the Mercurial mailing list