Patchwork [STABLE] largefiles: avoid a crash when archiving a subrepo with largefiles disabled

login
register
mail settings
Submitter Matt Harbison
Date June 14, 2017, 4:29 a.m.
Message ID <ae904143fdc12bd46cac.1497414555@Envy>
Download mbox | patch
Permalink /patch/21367/
State Accepted
Headers show

Comments

Matt Harbison - June 14, 2017, 4:29 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1497407081 14400
#      Tue Jun 13 22:24:41 2017 -0400
# Branch stable
# Node ID ae904143fdc12bd46cac831ee20a666adc879339
# Parent  efebc9f52ecbbbe90fcb83c6a6202f2ec948bbc5
largefiles: avoid a crash when archiving a subrepo with largefiles disabled

This path is also used for extdiff, which is how I crossed paths with it.
Without this, an AttributeError occurs looking for 'lfstatus' on
localrepository.  See also d414c28db84d.

The other archive method is for the archival.py override, so it doesn't need to
be special cased like this.  (It looks like it is only called for the top level
repo.)  Likewise, the transplant override is also for commands.py.  The other
overrides set lfstatus before examining it.
Augie Fackler - June 15, 2017, 3:18 a.m.
On Wed, Jun 14, 2017 at 12:29:15AM -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1497407081 14400
> #      Tue Jun 13 22:24:41 2017 -0400
> # Branch stable
> # Node ID ae904143fdc12bd46cac831ee20a666adc879339
> # Parent  efebc9f52ecbbbe90fcb83c6a6202f2ec948bbc5
> largefiles: avoid a crash when archiving a subrepo with largefiles disabled

queued for stable, thanks

Patch

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -1009,7 +1009,8 @@ 
     archiver.done()
 
 def hgsubrepoarchive(orig, repo, archiver, prefix, match=None, decode=True):
-    if not repo._repo.lfstatus:
+    lfenabled = util.safehasattr(repo._repo, '_largefilesenabled')
+    if not lfenabled or not repo._repo.lfstatus:
         return orig(repo, archiver, prefix, match, decode)
 
     repo._get(repo._state + ('hg',))
diff --git a/tests/test-largefiles-misc.t b/tests/test-largefiles-misc.t
--- a/tests/test-largefiles-misc.t
+++ b/tests/test-largefiles-misc.t
@@ -1075,6 +1075,10 @@ 
   $ hg -R subrepo-root status -S
   M large
   M no-largefiles/normal1
+  $ hg -R subrepo-root extdiff -p echo -S --config extensions.extdiff=
+  "*\\no-largefiles\\normal1" "*\\no-largefiles\\normal1" (glob) (windows !)
+  */no-largefiles/normal1 */no-largefiles/normal1 (glob) (no-windows !)
+  [1]
   $ hg -R subrepo-root revert --all
   reverting subrepo-root/.hglf/large (glob)
   reverting subrepo no-largefiles