[PATCH 2 of 3] largefiles: more work on cleaning up comments

Greg Ward greg at gerg.ca
Thu Oct 13 20:48:40 CDT 2011


# HG changeset patch
# User Greg Ward <greg at gerg.ca>
# Date 1318553149 14400
# Node ID 9094db68746ff19b97de04286bcbe647b32f5085
# Parent  f984c9e433a6632c1da83206c709846f306ea10e
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)

diff --git a/hgext/largefiles/lfcommands.py b/hgext/largefiles/lfcommands.py
--- a/hgext/largefiles/lfcommands.py
+++ b/hgext/largefiles/lfcommands.py
@@ -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])
 
diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -310,10 +310,11 @@
     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
+    # 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 +419,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 +464,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 +490,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 +527,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 +573,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 +646,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 +773,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 +794,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
diff --git a/hgext/largefiles/reposetup.py b/hgext/largefiles/reposetup.py
--- a/hgext/largefiles/reposetup.py
+++ b/hgext/largefiles/reposetup.py
@@ -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 everything.
@@ -254,8 +254,8 @@
                         match.files()):
                     lfiles = lfutil.listlfiles(self)
                     lfdirstate = lfutil.openlfdirstate(ui, self)
-                    # this only loops through lfiles that exist (not
-                    # removed/renamed)
+                    # this only loops through largefiles that exist
+                    # (not removed/renamed)
                     for lfile in lfiles:
                         if os.path.exists(self.wjoin(lfutil.standin(lfile))):
                             # this handles the case where a rebase is being
@@ -315,9 +315,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 = []
diff --git a/hgext/largefiles/uisetup.py b/hgext/largefiles/uisetup.py
--- a/hgext/largefiles/uisetup.py
+++ b/hgext/largefiles/uisetup.py
@@ -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'


More information about the Mercurial-devel mailing list