changeset 15254:dd03d3a9f888

largefiles: more work on cleaning up comments - always say "largefile", not "lfile" - cleanup mangled syntax, hopefully correctly (punctuation: it's your friend!) - wrap to 75 columns (where feasible)
author Greg Ward <greg@gerg.ca>
date Thu, 13 Oct 2011 20:45:49 -0400
parents 67d010779907
children 7ab05d752405
files hgext/largefiles/lfcommands.py hgext/largefiles/overrides.py hgext/largefiles/reposetup.py hgext/largefiles/uisetup.py
diffstat 4 files changed, 60 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/largefiles/lfcommands.py	Thu Oct 13 20:24:29 2011 -0400
+++ b/hgext/largefiles/lfcommands.py	Thu Oct 13 20:45:49 2011 -0400
@@ -243,13 +243,13 @@
 
         if f in lfiles:
             dstfiles.append(lfutil.standin(f))
-            # lfile in manifest if it has not been removed/renamed
+            # largefile in manifest if it has not been removed/renamed
             if f in ctx.manifest():
                 if 'l' in ctx.filectx(f).flags():
                     if renamed and renamed[0] in lfiles:
                         raise util.Abort(_('largefile %s becomes symlink') % f)
 
-                # lfile was modified, update standins
+                # largefile was modified, update standins
                 fullpath = rdst.wjoin(f)
                 lfutil.createdir(os.path.dirname(fullpath))
                 m = util.sha1('')
@@ -282,7 +282,7 @@
                 raise IOError()
             renamed = fctx.renamed()
             if renamed:
-                # standin is always a lfile because lfileness
+                # standin is always a largefile because largefile-ness
                 # doesn't change after rename or copy
                 renamed = lfutil.standin(renamed[0])
 
--- a/hgext/largefiles/overrides.py	Thu Oct 13 20:24:29 2011 -0400
+++ b/hgext/largefiles/overrides.py	Thu Oct 13 20:45:49 2011 -0400
@@ -310,10 +310,10 @@
     if os.path.isdir(dest):
         if not os.path.isdir(makestandin(dest)):
             os.makedirs(makestandin(dest))
-    # This could copy both largefiles and normal files in one command,
-    # but we don't want to do that first replace their matcher to only
-    # match normal files and run it then replace it to just match
-    # lfiles and run it again
+    # This could copy both lfiles and normal files in one command,
+    # but we don't want to do that. First replace their matcher to
+    # only match normal files and run it, then replace it to just
+    # match largefiles and run it again.
     nonormalfiles = False
     nolfiles = False
     try:
@@ -418,18 +418,20 @@
 
     return result
 
-# When the user calls revert, we have to be careful to not revert any changes
-# to other lfiles accidentally.  This means we have to keep track of the lfiles
-# that are being reverted so we only pull down the necessary lfiles.
+# When the user calls revert, we have to be careful to not revert any
+# changes to other largefiles accidentally. This means we have to keep
+# track of the largefiles that are being reverted so we only pull down
+# the necessary largefiles.
 #
-# Standins are only updated (to match the hash of lfiles) before commits.
-# Update the standins then run the original revert (changing the matcher to hit
-# standins instead of lfiles). Based on the resulting standins update the
-# lfiles. Then return the standins to their proper state
+# Standins are only updated (to match the hash of largefiles) before
+# commits. Update the standins then run the original revert, changing
+# the matcher to hit standins instead of largefiles. Based on the
+# resulting standins update the largefiles. Then return the standins
+# to their proper state
 def override_revert(orig, ui, repo, *pats, **opts):
-    # Because we put the standins in a bad state (by updating them) and then
-    # return them to a correct state we need to lock to prevent others from
-    # changing them in their incorrect state.
+    # Because we put the standins in a bad state (by updating them)
+    # and then return them to a correct state we need to lock to
+    # prevent others from changing them in their incorrect state.
     wlock = repo.wlock()
     try:
         lfdirstate = lfutil.openlfdirstate(ui, repo)
@@ -461,11 +463,11 @@
                 orig_matchfn = m.matchfn
                 def matchfn(f):
                     if lfutil.isstandin(f):
-                        # We need to keep track of what lfiles are being
-                        # matched so we know which ones to update later
-                        # (otherwise we revert changes to other lfiles
-                        # accidentally).  This is repo specific, so duckpunch
-                        # the repo object to keep the list of lfiles for us
+                        # We need to keep track of what largefiles are being
+                        # matched so we know which ones to update later --
+                        # otherwise we accidentally revert changes to other
+                        # largefiles. This is repo-specific, so duckpunch the
+                        # repo object to keep the list of largefiles for us
                         # later.
                         if orig_matchfn(lfutil.splitstandin(f)) and \
                                 (f in repo[None] or f in ctx):
@@ -487,7 +489,8 @@
         lfileslist = getattr(repo, '_lfilestoupdate', [])
         lfcommands.updatelfiles(ui, repo, filelist=lfileslist,
                                 printmessage=False)
-        # Empty out the lfiles list so we start fresh next time
+
+        # empty out the largefiles list so we start fresh next time
         repo._lfilestoupdate = []
         for lfile in modified:
             if lfile in lfileslist:
@@ -523,9 +526,9 @@
     lfcommands.updatelfiles(repo.ui, repo)
     return result
 
-# When we rebase a repository with remotely changed lfiles, we need
-# to take some extra care so that the lfiles are correctly updated
-# in the working copy
+# When we rebase a repository with remotely changed largefiles, we need to
+# take some extra care so that the largefiles are correctly updated in the
+# working copy
 def override_pull(orig, ui, repo, source=None, **opts):
     if opts.get('rebase', False):
         repo._isrebasing = True
@@ -569,9 +572,8 @@
 
 def override_archive(orig, repo, dest, node, kind, decode=True, matchfn=None,
             prefix=None, mtime=None, subrepos=None):
-    # No need to lock because we are only reading history and lfile caches
-    # neither of which are modified
-
+    # No need to lock because we are only reading history and
+    # largefile caches, neither of which are modified.
     lfcommands.cachelfiles(repo.ui, repo, node)
 
     if kind not in archival.archivers:
@@ -643,10 +645,10 @@
 
     archiver.done()
 
-# If a lfile is modified the change is not reflected in its standin until a
-# commit.  cmdutil.bailifchanged raises an exception if the repo has
-# uncommitted changes.  Wrap it to also check if lfiles were changed. This is
-# used by bisect and backout.
+# If a largefile is modified, the change is not reflected in its
+# standin until a commit. cmdutil.bailifchanged() raises an exception
+# if the repo has uncommitted changes. Wrap it to also check if
+# largefiles were changed. This is used by bisect and backout.
 def override_bailifchanged(orig, repo):
     orig(repo)
     repo.lfstatus = True
@@ -770,10 +772,10 @@
             ui.status(_('largefiles: %d to upload\n') % len(toupload))
 
 def override_addremove(orig, ui, repo, *pats, **opts):
-    # Check if the parent or child has lfiles if they do don't allow it.  If
-    # there is a symlink in the manifest then getting the manifest throws an
-    # exception catch it and let addremove deal with it. This happens in
-    # Mercurial's test test-addremove-symlink
+    # Check if the parent or child has largefiles; if so, disallow
+    # addremove. If there is a symlink in the manifest then getting
+    # the manifest throws an exception: catch it and let addremove
+    # deal with it.
     try:
         manifesttip = set(repo['tip'].manifest())
     except util.Abort:
@@ -791,7 +793,7 @@
 
     return orig(ui, repo, *pats, **opts)
 
-# Calling purge with --all will cause the lfiles to be deleted.
+# Calling purge with --all will cause the largefiles to be deleted.
 # Override repo.status to prevent this from happening.
 def override_purge(orig, ui, repo, *dirs, **opts):
     oldstatus = repo.status
--- a/hgext/largefiles/reposetup.py	Thu Oct 13 20:24:29 2011 -0400
+++ b/hgext/largefiles/reposetup.py	Thu Oct 13 20:45:49 2011 -0400
@@ -118,12 +118,11 @@
                     except KeyError:
                         return False
 
-                # create a copy of match that matches standins instead of
-                # lfiles if matcher not set then it is the always matcher so
-                # overwrite that
                 if match is None:
                     match = match_.always(self.root, self.getcwd())
 
+                # Create a copy of match that matches standins instead
+                # of largefiles.
                 def tostandin(file):
                     if inctx(lfutil.standin(file), ctx2):
                         return lfutil.standin(file)
@@ -199,7 +198,7 @@
                     # Ignored files must be ignored by both the dirstate and
                     # lfdirstate
                     result[5] = set(ignored).intersection(set(result[5]))
-                    # combine normal files and lfiles
+                    # combine normal files and largefiles
                     normals = [[fn for fn in filelist if not \
                         lfutil.isstandin(fn)] for filelist in result]
                     result = [sorted(list1 + list2) for (list1, list2) in \
@@ -220,8 +219,8 @@
                 self.lfstatus = True
                 return result
 
-        # This call happens after a commit has occurred. Copy all of the lfiles
-        # into the cache
+        # As part of committing, copy all of the largefiles into the
+        # cache.
         def commitctx(self, *args, **kwargs):
             node = super(lfiles_repo, self).commitctx(*args, **kwargs)
             ctx = self[node]
@@ -232,9 +231,9 @@
 
             return node
 
-        # This call happens before a commit has occurred. The lfile standins
-        # have not had their contents updated (to reflect the hash of their
-        # lfile).  Do that here.
+        # Before commit, largefile standins have not had their
+        # contents updated to reflect the hash of their largefile.
+        # Do that here.
         def commit(self, text="", user=None, date=None, match=None,
                 force=False, editor=False, extra={}):
             orig = super(lfiles_repo, self).commit
@@ -242,11 +241,12 @@
             wlock = repo.wlock()
             try:
                 if getattr(repo, "_isrebasing", False):
-                    # We have to take the time to pull down the new lfiles now.
-                    # Otherwise if we are rebasing, any lfiles that were
-                    # modified in the changesets we are rebasing on top of get
-                    # overwritten either by the rebase or in the first commit
-                    # after the rebase.
+                    # We have to take the time to pull down the new
+                    # largefiles now. Otherwise if we are rebasing,
+                    # any largefiles that were modified in the
+                    # destination changesets get overwritten, either
+                    # by the rebase or in the first commit after the
+                    # rebase.
                     lfcommands.updatelfiles(repo.ui, repo)
                 # Case 1: user calls commit with no specific files or
                 # include/exclude patterns: refresh and commit all files that
@@ -265,7 +265,7 @@
                     for i in s:
                         modifiedfiles.extend(i)
                     lfiles = lfutil.listlfiles(self)
-                    # this only loops through lfiles that exist (not
+                    # this only loops through largefiles that exist (not
                     # removed/renamed)
                     for lfile in lfiles:
                         if lfile in modifiedfiles:
@@ -327,9 +327,9 @@
                 match = copy.copy(match)
                 orig_matchfn = match.matchfn
 
-                # Check both the list of lfiles and the list of standins
-                # because if a lfile was removed, it won't be in the list of
-                # lfiles at this point
+                # Check both the list of largefiles and the list of
+                # standins because if a largefile was removed, it
+                # won't be in the list of largefiles at this point
                 match._files += sorted(standins)
 
                 actualfiles = []
--- a/hgext/largefiles/uisetup.py	Thu Oct 13 20:24:29 2011 -0400
+++ b/hgext/largefiles/uisetup.py	Thu Oct 13 20:45:49 2011 -0400
@@ -99,8 +99,8 @@
     wireproto.commands['heads'] = (proto.heads, '')
     wireproto.commands['lheads'] = (wireproto.heads, '')
 
-    # make putlfile behave the same as push and {get,stat}lfile behave the same
-    # as pull w.r.t. permissions checks
+    # make putlfile behave the same as push and {get,stat}lfile behave
+    # the same as pull w.r.t. permissions checks
     hgweb_mod.perms['putlfile'] = 'push'
     hgweb_mod.perms['getlfile'] = 'pull'
     hgweb_mod.perms['statlfile'] = 'pull'