largefiles: allow the archiving of largefiles to be disabled
authorMatt Harbison <matt_harbison@yahoo.com>
Sat, 11 Jul 2015 23:26:33 -0400
changeset 25811 7699d3212994
parent 25810 82d6a35cf432
child 25812 68822b7cdd01
largefiles: allow the archiving of largefiles to be disabled There are currently no users of this, but it is a necessary step before converting extdiff to use archive. It may be useful to add an argument to extdiff in the future and allow largefiles to be diffed, but archiving largefiles can have significant overhead and may not be very diffable, so archiving them by default seems wrong. It is a mystery to me why the lfstatus attribute needs to be set on the unfiltered repo. However if it is set on the filtered repo instead (and the filtered repo is passed to the original command), the lfstatus attribute is False in the overrides for archival.archive() and hgsubrepo.archive() when invoking the archive command. This smells like the buggy status behavior (see 67d63ec85eb7, which was reverted in df463ca0adef). Neither the status nor summary commands have this weird behavior in their respective overrides.
hgext/largefiles/overrides.py
hgext/largefiles/uisetup.py
--- a/hgext/largefiles/overrides.py	Thu Jul 16 23:36:08 2015 +0900
+++ b/hgext/largefiles/overrides.py	Sat Jul 11 23:26:33 2015 -0400
@@ -878,8 +878,20 @@
         repo._lfstatuswriters.pop()
         repo._lfcommithooks.pop()
 
+def overridearchivecmd(orig, ui, repo, dest, **opts):
+    repo.unfiltered().lfstatus = True
+
+    try:
+        return orig(ui, repo.unfiltered(), dest, **opts)
+    finally:
+        repo.unfiltered().lfstatus = False
+
 def overridearchive(orig, repo, dest, node, kind, decode=True, matchfn=None,
             prefix='', mtime=None, subrepos=None):
+    if not repo.lfstatus:
+        return orig(repo, dest, node, kind, decode, matchfn, prefix, mtime,
+                    subrepos)
+
     # No need to lock because we are only reading history and
     # largefile caches, neither of which are modified.
     if node is not None:
@@ -943,11 +955,15 @@
         for subpath in sorted(ctx.substate):
             sub = ctx.workingsub(subpath)
             submatch = match_.narrowmatcher(subpath, matchfn)
+            sub._repo.lfstatus = True
             sub.archive(archiver, prefix, submatch)
 
     archiver.done()
 
 def hgsubrepoarchive(orig, repo, archiver, prefix, match=None):
+    if not repo._repo.lfstatus:
+        return orig(repo, archiver, prefix, match)
+
     repo._get(repo._state + ('hg',))
     rev = repo._state[1]
     ctx = repo._repo[rev]
@@ -996,6 +1012,7 @@
     for subpath in sorted(ctx.substate):
         sub = ctx.workingsub(subpath)
         submatch = match_.narrowmatcher(subpath, match)
+        sub._repo.lfstatus = True
         sub.archive(archiver, prefix + repo._path + '/', submatch)
 
 # If a largefile is modified, the change is not reflected in its
--- a/hgext/largefiles/uisetup.py	Thu Jul 16 23:36:08 2015 +0900
+++ b/hgext/largefiles/uisetup.py	Sat Jul 11 23:26:33 2015 -0400
@@ -114,6 +114,8 @@
     entry = extensions.wrapfunction(cmdutil, 'revert',
                                     overrides.overriderevert)
 
+    extensions.wrapcommand(commands.table, 'archive',
+                           overrides.overridearchivecmd)
     extensions.wrapfunction(archival, 'archive', overrides.overridearchive)
     extensions.wrapfunction(subrepo.hgsubrepo, 'archive',
                             overrides.hgsubrepoarchive)