D7714: subrepo: fix a crash when archiving an svn or git subrepo

mharbison72 (Matt Harbison) phabricator at mercurial-scm.org
Wed Jan 8 14:43:47 EST 2020


Closed by commit rHG7ca8aa8840c0: subrepo: fix a crash when archiving an svn or git subrepo (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7714?vs=18922&id=19089

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7714/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7714

AFFECTED FILES
  hgext/largefiles/overrides.py
  tests/test-subrepo-git.t

CHANGE DETAILS

diff --git a/tests/test-subrepo-git.t b/tests/test-subrepo-git.t
--- a/tests/test-subrepo-git.t
+++ b/tests/test-subrepo-git.t
@@ -376,6 +376,15 @@
   a
   s/g
 
+  $ hg -R ../tc archive -S ../lf_archive.tgz --prefix '.' \
+  >       --config extensions.largefiles= 2>/dev/null
+  $ tar -tzf ../lf_archive.tgz | sort | grep -v pax_global_header
+  .hg_archival.txt
+  .hgsub
+  .hgsubstate
+  a
+  s/g
+
 create nested repo
 
   $ cd ..
diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -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)
 
 



To: mharbison72, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list