Patchwork [STABLE] largefiles: restore archiving largefiles with hgweb (issue4859)

login
register
mail settings
Submitter Matt Harbison
Date Sept. 30, 2015, 4:06 a.m.
Message ID <a80c438b5f00f107cd86.1443585996@Envy>
Download mbox | patch
Permalink /patch/10698/
State Accepted
Headers show

Comments

Matt Harbison - Sept. 30, 2015, 4:06 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1443583784 14400
#      Tue Sep 29 23:29:44 2015 -0400
# Branch stable
# Node ID a80c438b5f00f107cd866e7320a466a102c4bffd
# Parent  c15d8f84343e83c03ee11523ee1f00359ae94477
largefiles: restore archiving largefiles with hgweb (issue4859)

This regressed in 7699d3212994, when trying to conditionally disable archiving
of largefiles.

I'm not sure if wrapfunction() is the right way to do this, but it seems to
work.  The mysterious issue with lfstatus getting out of sync in the proxy and
the unfiltered view crops up again here.  See the referenced cset for more info.
Yuya Nishihara - Sept. 30, 2015, 3:52 p.m.
On Wed, 30 Sep 2015 00:06:36 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1443583784 14400
> #      Tue Sep 29 23:29:44 2015 -0400
> # Branch stable
> # Node ID a80c438b5f00f107cd866e7320a466a102c4bffd
> # Parent  c15d8f84343e83c03ee11523ee1f00359ae94477
> largefiles: restore archiving largefiles with hgweb (issue4859)
> 
> This regressed in 7699d3212994, when trying to conditionally disable archiving
> of largefiles.
> 
> I'm not sure if wrapfunction() is the right way to do this, but it seems to
> work.  The mysterious issue with lfstatus getting out of sync in the proxy and
> the unfiltered view crops up again here.  See the referenced cset for more info.

I think wrapfunction() is good. It is working because webcommands.commands
table isn't used except for generating help messages.

If someone try to replace getattr(webcommands, cmd) by webcommands.commands[cmd],
he will be blamed by the test.
Augie Fackler - Sept. 30, 2015, 4:09 p.m.
On Wed, Sep 30, 2015 at 12:06:36AM -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1443583784 14400
> #      Tue Sep 29 23:29:44 2015 -0400
> # Branch stable
> # Node ID a80c438b5f00f107cd866e7320a466a102c4bffd
> # Parent  c15d8f84343e83c03ee11523ee1f00359ae94477
> largefiles: restore archiving largefiles with hgweb (issue4859)

Looks good here, queued for stable. Thanks!

>
> This regressed in 7699d3212994, when trying to conditionally disable archiving
> of largefiles.
>
> I'm not sure if wrapfunction() is the right way to do this, but it seems to
> work.  The mysterious issue with lfstatus getting out of sync in the proxy and
> the unfiltered view crops up again here.  See the referenced cset for more info.
>
> diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
> --- a/hgext/largefiles/overrides.py
> +++ b/hgext/largefiles/overrides.py
> @@ -886,9 +886,19 @@
>      finally:
>          repo.unfiltered().lfstatus = False
>
> +def hgwebarchive(orig, web, req, tmpl):
> +    web.repo.lfstatus = True
> +
> +    try:
> +        return orig(web, req, tmpl)
> +    finally:
> +        web.repo.lfstatus = False
> +
>  def overridearchive(orig, repo, dest, node, kind, decode=True, matchfn=None,
>              prefix='', mtime=None, subrepos=None):
> -    if not repo.lfstatus:
> +    # For some reason setting repo.lfstatus in hgwebarchive only changes the
> +    # unfiltered repo's attr, so check that as well.
> +    if not repo.lfstatus and not repo.unfiltered().lfstatus:
>          return orig(repo, dest, node, kind, decode, matchfn, prefix, mtime,
>                      subrepos)
>
> diff --git a/hgext/largefiles/uisetup.py b/hgext/largefiles/uisetup.py
> --- a/hgext/largefiles/uisetup.py
> +++ b/hgext/largefiles/uisetup.py
> @@ -119,6 +119,8 @@
>      extensions.wrapfunction(archival, 'archive', overrides.overridearchive)
>      extensions.wrapfunction(subrepo.hgsubrepo, 'archive',
>                              overrides.hgsubrepoarchive)
> +    extensions.wrapfunction(webcommands, 'archive',
> +                            overrides.hgwebarchive)
>      extensions.wrapfunction(cmdutil, 'bailifchanged',
>                              overrides.overridebailifchanged)
>
> diff --git a/tests/test-largefiles-wireproto.t b/tests/test-largefiles-wireproto.t
> --- a/tests/test-largefiles-wireproto.t
> +++ b/tests/test-largefiles-wireproto.t
> @@ -15,6 +15,8 @@
>    > minsize=2
>    > patterns=glob:**.dat
>    > usercache=${USERCACHE}
> +  > [web]
> +  > allow_archive = zip
>    > [hooks]
>    > precommit=sh -c "echo \\"Invoking status precommit hook\\"; hg status"
>    > EOF
> @@ -215,6 +217,17 @@
>    adding file changes
>    added 1 changesets with 1 changes to 1 files
>
> +Archive contains largefiles
> +  >>> import urllib2, os
> +  >>> u = 'http://localhost:%s/archive/default.zip' % os.environ['HGPORT2']
> +  >>> with open('archive.zip', 'w') as f:
> +  ...     f.write(urllib2.urlopen(u).read())
> +  $ unzip -t archive.zip
> +  Archive:  archive.zip
> +      testing: empty-default/.hg_archival.txt   OK
> +      testing: empty-default/f1         OK
> +  No errors detected in compressed data of archive.zip.
> +
>  test 'verify' with remotestore:
>
>    $ rm "${USERCACHE}"/02a439e5c31c526465ab1a0ca1f431f76b827b90
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -886,9 +886,19 @@ 
     finally:
         repo.unfiltered().lfstatus = False
 
+def hgwebarchive(orig, web, req, tmpl):
+    web.repo.lfstatus = True
+
+    try:
+        return orig(web, req, tmpl)
+    finally:
+        web.repo.lfstatus = False
+
 def overridearchive(orig, repo, dest, node, kind, decode=True, matchfn=None,
             prefix='', mtime=None, subrepos=None):
-    if not repo.lfstatus:
+    # For some reason setting repo.lfstatus in hgwebarchive only changes the
+    # unfiltered repo's attr, so check that as well.
+    if not repo.lfstatus and not repo.unfiltered().lfstatus:
         return orig(repo, dest, node, kind, decode, matchfn, prefix, mtime,
                     subrepos)
 
diff --git a/hgext/largefiles/uisetup.py b/hgext/largefiles/uisetup.py
--- a/hgext/largefiles/uisetup.py
+++ b/hgext/largefiles/uisetup.py
@@ -119,6 +119,8 @@ 
     extensions.wrapfunction(archival, 'archive', overrides.overridearchive)
     extensions.wrapfunction(subrepo.hgsubrepo, 'archive',
                             overrides.hgsubrepoarchive)
+    extensions.wrapfunction(webcommands, 'archive',
+                            overrides.hgwebarchive)
     extensions.wrapfunction(cmdutil, 'bailifchanged',
                             overrides.overridebailifchanged)
 
diff --git a/tests/test-largefiles-wireproto.t b/tests/test-largefiles-wireproto.t
--- a/tests/test-largefiles-wireproto.t
+++ b/tests/test-largefiles-wireproto.t
@@ -15,6 +15,8 @@ 
   > minsize=2
   > patterns=glob:**.dat
   > usercache=${USERCACHE}
+  > [web]
+  > allow_archive = zip
   > [hooks]
   > precommit=sh -c "echo \\"Invoking status precommit hook\\"; hg status"
   > EOF
@@ -215,6 +217,17 @@ 
   adding file changes
   added 1 changesets with 1 changes to 1 files
 
+Archive contains largefiles
+  >>> import urllib2, os
+  >>> u = 'http://localhost:%s/archive/default.zip' % os.environ['HGPORT2']
+  >>> with open('archive.zip', 'w') as f:
+  ...     f.write(urllib2.urlopen(u).read())
+  $ unzip -t archive.zip
+  Archive:  archive.zip
+      testing: empty-default/.hg_archival.txt   OK
+      testing: empty-default/f1         OK
+  No errors detected in compressed data of archive.zip.
+
 test 'verify' with remotestore:
 
   $ rm "${USERCACHE}"/02a439e5c31c526465ab1a0ca1f431f76b827b90