[PATCH 1 of 1 RFC] scmutil: eliminate util.samestat

Adrian Buehlmann adrian at cadifra.com
Tue Jun 12 17:32:42 CDT 2012


On 2012-06-13 00:04, Matt Mackall wrote:
> On Sat, 2012-06-09 at 11:58 +0200, Adrian Buehlmann wrote:
>> # HG changeset patch
>> # User Adrian Buehlmann <adrian at cadifra.com>
>> # Date 1339182525 -7200
>> # Node ID 48649541c9a2002a148699136cff71865b18dc60
>> # Parent  2255950e1f7663a9faa6b57040cc5c0debe7d4dd
>> scmutil: eliminate util.samestat
>>
>> It's impossible to implement that on Windows.
> 
> First, I don't know why that in itself is an argument for removing it.
> We have plenty of utility functions that are only relevant to one
> platform.
> 
> Second, I don't believe it's impossible to implement and happen to know
> that analogous functions exist. For instance, GetFileInformationByHandle
> has fields that would serve the same purpose (volume serial number and
> file index):
> 
>  http://msdn.microsoft.com/en-us/library/aa363788%28VS.85%29.aspx
> 

That works only for files, for directories, samestat is impossible.

> (We might need to tweak the interface to work on file handles rather
> than stat results, but the use cases remain the same.)
> 
> So while this function might be smack in the middle of some buggy code,
> there is nothing at all conceptually wrong with having a utility
> function that represents the concept: "tell me if two files are the same
> if you can" and using that to short-circuit a longer check.
> 
> In fact, ripping it out is a step back from doing it right eventually,
> because to add a Windows implementation where the Python library is
> lacking, we'll need to add a util method.
> 


More information about the Mercurial-devel mailing list