comparison hgext/largefiles/overrides.py @ 25811:7699d3212994

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.
author Matt Harbison <matt_harbison@yahoo.com>
date Sat, 11 Jul 2015 23:26:33 -0400
parents 328739ea70c3
children ec2662b9629d 9a466b9f9792
comparison
equal deleted inserted replaced
25810:82d6a35cf432 25811:7699d3212994
876 return orig(ui, repo, **opts) 876 return orig(ui, repo, **opts)
877 finally: 877 finally:
878 repo._lfstatuswriters.pop() 878 repo._lfstatuswriters.pop()
879 repo._lfcommithooks.pop() 879 repo._lfcommithooks.pop()
880 880
881 def overridearchivecmd(orig, ui, repo, dest, **opts):
882 repo.unfiltered().lfstatus = True
883
884 try:
885 return orig(ui, repo.unfiltered(), dest, **opts)
886 finally:
887 repo.unfiltered().lfstatus = False
888
881 def overridearchive(orig, repo, dest, node, kind, decode=True, matchfn=None, 889 def overridearchive(orig, repo, dest, node, kind, decode=True, matchfn=None,
882 prefix='', mtime=None, subrepos=None): 890 prefix='', mtime=None, subrepos=None):
891 if not repo.lfstatus:
892 return orig(repo, dest, node, kind, decode, matchfn, prefix, mtime,
893 subrepos)
894
883 # No need to lock because we are only reading history and 895 # No need to lock because we are only reading history and
884 # largefile caches, neither of which are modified. 896 # largefile caches, neither of which are modified.
885 if node is not None: 897 if node is not None:
886 lfcommands.cachelfiles(repo.ui, repo, node) 898 lfcommands.cachelfiles(repo.ui, repo, node)
887 899
941 953
942 if subrepos: 954 if subrepos:
943 for subpath in sorted(ctx.substate): 955 for subpath in sorted(ctx.substate):
944 sub = ctx.workingsub(subpath) 956 sub = ctx.workingsub(subpath)
945 submatch = match_.narrowmatcher(subpath, matchfn) 957 submatch = match_.narrowmatcher(subpath, matchfn)
958 sub._repo.lfstatus = True
946 sub.archive(archiver, prefix, submatch) 959 sub.archive(archiver, prefix, submatch)
947 960
948 archiver.done() 961 archiver.done()
949 962
950 def hgsubrepoarchive(orig, repo, archiver, prefix, match=None): 963 def hgsubrepoarchive(orig, repo, archiver, prefix, match=None):
964 if not repo._repo.lfstatus:
965 return orig(repo, archiver, prefix, match)
966
951 repo._get(repo._state + ('hg',)) 967 repo._get(repo._state + ('hg',))
952 rev = repo._state[1] 968 rev = repo._state[1]
953 ctx = repo._repo[rev] 969 ctx = repo._repo[rev]
954 970
955 if ctx.node() is not None: 971 if ctx.node() is not None:
994 write(f, 'x' in ff and 0o755 or 0o644, 'l' in ff, getdata) 1010 write(f, 'x' in ff and 0o755 or 0o644, 'l' in ff, getdata)
995 1011
996 for subpath in sorted(ctx.substate): 1012 for subpath in sorted(ctx.substate):
997 sub = ctx.workingsub(subpath) 1013 sub = ctx.workingsub(subpath)
998 submatch = match_.narrowmatcher(subpath, match) 1014 submatch = match_.narrowmatcher(subpath, match)
1015 sub._repo.lfstatus = True
999 sub.archive(archiver, prefix + repo._path + '/', submatch) 1016 sub.archive(archiver, prefix + repo._path + '/', submatch)
1000 1017
1001 # If a largefile is modified, the change is not reflected in its 1018 # If a largefile is modified, the change is not reflected in its
1002 # standin until a commit. cmdutil.bailifchanged() raises an exception 1019 # standin until a commit. cmdutil.bailifchanged() raises an exception
1003 # if the repo has uncommitted changes. Wrap it to also check if 1020 # if the repo has uncommitted changes. Wrap it to also check if