[MERGE] make sha1_provider a parameter to DirState()

John Arbash Meinel john at arbash-meinel.com
Wed Mar 18 14:57:20 GMT 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Martin Pool wrote:
> 2009/3/18 Ian Clatworthy <ian.clatworthy at internode.on.net>:
>> Martin Pool wrote:
>>> Martin Pool has voted tweak.
>>> Status is now: Conditionally approved
>>> Comment:
>>> Could you change it to SHA (in uppercase) which is consistent with other
>>> APIs?
>>>
>>> +class DefaultSha1Provider(Sha1Provider):
>>> +    """A Sha1Provider that reads directly from the filesystem."""
>>> +
>>> +    def sha1(self, abspath):
>>> +        """Return the sha1 of a file given it's absolute path."""
>>> +        return osutils.sha_file_by_name(abspath)
>>> +
>>> +    def stat_and_sha1(self, abspath):
>> Which bit did you want changed? The class name? The methods? Both?
>> I'm pretty sure the functions in osutils use 'sha' - all in lowercase.
> 
> The classname, see
> 
> 
> mbp at grace% grep SHA **/*py -n
> bzrlib/dirstate.py:106:    SHA1
> bzrlib/errors.py:1429:class SHA1KnitCorrupt(KnitCorrupt):
> bzrlib/foreign.py:232:         the SHA1.
> bzrlib/hashcache.py:47:    """Cache for looking up file SHA-1.
> bzrlib/hashcache.py:67:        Indexed by path, points to a two-tuple
> of the SHA-1 of the file.
> bzrlib/hashcache.py:202:        """Calculate the SHA1 of a file by
> reading the full text"""
> 
> OK, so there's only actually one class with that name, but I think the
> general convention is that we don't squash acronyms into title case.
> 

I think we try to use CAPS for class names, though I believe we fail
from time to time. The classic cases are the transport objects:

class FtpTransport(ConnectedTransport):
class HttpTransport_urllib(http.HttpTransportBase):
class HttpTransportBase(ConnectedTransport):
class FakeNFSTransportDecorator(TransportDecorator):
class FakeVFATTransportDecorator(TransportDecorator):

class GSSAPIFtpTransport(FtpTransport):
class HTTPS_pycurl_transport(PyCurlTransport):
class RemoteTCPTransport(RemoteTransport):
class RemoteTCPTransportV2Only(RemoteTransport):
class RemoteSSHTransport(RemoteTransport):
class RemoteHTTPTransport(RemoteTransport):
class HintingSSHTransport(transport.Transport):
class SFTPTransport(ConnectedTransport):


So we have Ftp and Http, though SFTP and HTTPS. I think it primarily
came down to who wrote what. I *believe* we wanted to standardize on all
CAPS and just didn't remember that at the right time.

Anyway, +1 on making it SHA1Provider, -1 on making it def SHA1().

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAknBC9AACgkQJdeBCYSNAAMxLgCfcJwFzoNVKRUJ4eszGxOLToM4
Sj4AoLVGLM6ZEjbnDMB4UcNLajT8y0AU
=CSSZ
-----END PGP SIGNATURE-----



More information about the bazaar mailing list