Mercurial > public > mercurial-scm > hg-stable
diff hgext/largefiles/lfutil.py @ 15252:6e809bb4f969
largefiles: improve comments, internal docstrings
- fix some ungrammatical/unclear/incorrect comments/docstrings
- rewrite some really unclear comments/docstrings
- make formatting/style more consistent with the rest of Mercurial
(lowercase without period unless it's really multiple sentences)
- wrap to 75 columns
- always say "largefile(s)", not "lfile(s)" (or "big files")
- one space between sentences, not two
author | Greg Ward <greg@gerg.ca> |
---|---|
date | Wed, 12 Oct 2011 20:59:27 -0400 |
parents | ee625de3541e |
children | 67d010779907 |
line wrap: on
line diff
--- a/hgext/largefiles/lfutil.py Thu Oct 13 15:15:32 2011 +0200 +++ b/hgext/largefiles/lfutil.py Wed Oct 12 20:59:27 2011 -0400 @@ -76,7 +76,7 @@ try: util.oslink(src, dest) except OSError: - # If hardlinks fail fall back on copy + # if hardlinks fail, fallback on copy shutil.copyfile(src, dest) os.chmod(dest, os.stat(src).st_mode) @@ -122,8 +122,8 @@ def openlfdirstate(ui, repo): ''' - Return a dirstate object that tracks big files: i.e. its root is the - repo root, but it is saved in .hg/largefiles/dirstate. + Return a dirstate object that tracks largefiles: i.e. its root is + the repo root, but it is saved in .hg/largefiles/dirstate. ''' admin = repo.join(longname) opener = scmutil.opener(admin) @@ -133,10 +133,10 @@ else: lfdirstate = largefiles_dirstate(opener, ui, repo.root) - # If the largefiles dirstate does not exist, populate and create it. This - # ensures that we create it on the first meaningful largefiles operation in - # a new clone. It also gives us an easy way to forcibly rebuild largefiles - # state: + # If the largefiles dirstate does not exist, populate and create + # it. This ensures that we create it on the first meaningful + # largefiles operation in a new clone. It also gives us an easy + # way to forcibly rebuild largefiles state: # rm .hg/largefiles/dirstate && hg status # Or even, if things are really messed up: # rm -rf .hg/largefiles && hg status @@ -177,7 +177,8 @@ return (modified, added, removed, missing, unknown, ignored, clean) def listlfiles(repo, rev=None, matcher=None): - '''list largefiles in the working copy or specified changeset''' + '''return a list of largefiles in the working copy or the + specified changeset''' if matcher is None: matcher = getstandinmatcher(repo) @@ -197,10 +198,11 @@ return repo.join(os.path.join(longname, hash)) def copyfromcache(repo, hash, filename): - '''copyfromcache copies the specified largefile from the repo or system - cache to the specified location in the repository. It will not throw an - exception on failure, as it is meant to be called only after ensuring that - the needed largefile exists in the cache.''' + '''Copy the specified largefile from the repo or system cache to + filename in the repository. Return true on success or false if the + file was not found in either cache (which should not happened: + this is meant to be called only after ensuring that the needed + largefile exists in the cache).''' path = findfile(repo, hash) if path is None: return False @@ -249,9 +251,9 @@ return getmatcher(repo, pats, opts, showbad=False) def getmatcher(repo, pats=[], opts={}, showbad=True): - '''Wrapper around scmutil.match() that adds showbad: if false, neuter - the match object\'s bad() method so it does not print any warnings - about missing files or directories.''' + '''Wrapper around scmutil.match() that adds showbad: if false, + neuter the match object's bad() method so it does not print any + warnings about missing files or directories.''' match = scmutil.match(repo[None], pats, opts) if not showbad: @@ -259,9 +261,9 @@ return match def composestandinmatcher(repo, rmatcher): - '''Return a matcher that accepts standins corresponding to the files - accepted by rmatcher. Pass the list of files in the matcher as the - paths specified by the user.''' + '''Return a matcher that accepts standins corresponding to the + files accepted by rmatcher. Pass the list of files in the matcher + as the paths specified by the user.''' smatcher = getstandinmatcher(repo, rmatcher.files()) isstandin = smatcher.matchfn def composed_matchfn(f): @@ -283,8 +285,8 @@ return shortname + '/' + filename.replace(os.sep, '/') def isstandin(filename): - '''Return true if filename is a big file standin. filename must - be in Mercurial\'s internal form (slash-separated).''' + '''Return true if filename is a big file standin. filename must be + in Mercurial's internal form (slash-separated).''' return filename.startswith(shortname + '/') def splitstandin(filename): @@ -310,7 +312,7 @@ return repo[node][standin(filename)].data().strip() def writestandin(repo, standin, hash, executable): - '''write hhash to <repo.root>/<standin>''' + '''write hash to <repo.root>/<standin>''' writehash(hash, repo.wjoin(standin), executable) def copyandhash(instream, outfile): @@ -323,7 +325,7 @@ outfile.write(data) # Blecch: closing a file that somebody else opened is rude and - # wrong. But it's so darn convenient and practical! After all, + # wrong. But it's so darn convenient and practical! After all, # outfile was opened just to copy and hash. outfile.close() @@ -364,7 +366,7 @@ if not data: break yield data - # Same blecch as above. + # same blecch as copyandhash() above infile.close() def readhash(filename): @@ -425,9 +427,8 @@ def httpsendfile(ui, filename): return httpconnection.httpsendfile(ui, filename, 'rb') -# Convert a path to a unix style path. This is used to give a -# canonical path to the lfdirstate. def unixpath(path): + '''Return a version of path normalized for use with the lfdirstate.''' return os.path.normpath(path).replace(os.sep, '/') def islfilesrepo(repo):