# HG changeset patch # User Matt Harbison # Date 2015-07-12 03:26:33 # Node ID 7699d3212994c9c9a038802503fa9ee26ff74d5f # Parent 82d6a35cf432b66c4c7bdcbdc111a6eceb84b66f 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. diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py --- a/hgext/largefiles/overrides.py +++ b/hgext/largefiles/overrides.py @@ -878,8 +878,20 @@ def overriderebase(orig, ui, repo, **opt 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 @@ def overridearchive(orig, repo, dest, no 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 @@ def hgsubrepoarchive(orig, repo, archive 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 diff --git a/hgext/largefiles/uisetup.py b/hgext/largefiles/uisetup.py --- a/hgext/largefiles/uisetup.py +++ b/hgext/largefiles/uisetup.py @@ -114,6 +114,8 @@ def uisetup(ui): 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)