hgext/largefiles/overrides.py
branchstable
changeset 44015 7ca8aa8840c0
parent 43296 2cb787b65cf2
child 44129 84a0102c05c7
--- a/hgext/largefiles/overrides.py	Mon Jan 06 14:58:32 2020 -0500
+++ b/hgext/largefiles/overrides.py	Tue Dec 24 01:38:02 2019 -0500
@@ -1208,7 +1208,16 @@
             sub = ctx.workingsub(subpath)
             submatch = matchmod.subdirmatcher(subpath, match)
             subprefix = prefix + subpath + b'/'
-            with lfstatus(sub._repo):
+
+            # TODO: Only hgsubrepo instances have `_repo`, so figure out how to
+            # infer and possibly set lfstatus in hgsubrepoarchive.  That would
+            # allow only hgsubrepos to set this, instead of the current scheme
+            # where the parent sets this for the child.
+            with (
+                util.safehasattr(sub, '_repo')
+                and lfstatus(sub._repo)
+                or util.nullcontextmanager()
+            ):
                 sub.archive(archiver, subprefix, submatch)
 
     archiver.done()
@@ -1266,7 +1275,15 @@
         sub = ctx.workingsub(subpath)
         submatch = matchmod.subdirmatcher(subpath, match)
         subprefix = prefix + subpath + b'/'
-        with lfstatus(sub._repo):
+        # TODO: Only hgsubrepo instances have `_repo`, so figure out how to
+        # infer and possibly set lfstatus at the top of this function.  That
+        # would allow only hgsubrepos to set this, instead of the current scheme
+        # where the parent sets this for the child.
+        with (
+            util.safehasattr(sub, '_repo')
+            and lfstatus(sub._repo)
+            or util.nullcontextmanager()
+        ):
             sub.archive(archiver, subprefix, submatch, decode)