Patchwork [V2] revbranchcache: add test for when the cache is not writable

login
register
mail settings
Submitter Durham Goode
Date March 18, 2015, 5:10 p.m.
Message ID <0bd9d2392a53fb6b5b9d.1426698652@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/8145/
State Accepted
Commit 577f65cf1a57a43e58380eb060f356858efe99bf
Headers show

Comments

Durham Goode - March 18, 2015, 5:10 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1426627796 25200
#      Tue Mar 17 14:29:56 2015 -0700
# Node ID 0bd9d2392a53fb6b5b9deac82d6fb29c80c6a572
# Parent  567ae53657544744155897ada91f16f8af61ad8a
revbranchcache: add test for when the cache is not writable

The revbranchecache code already handled the case when the cache file wasn't
writable, but let's add a test as well so future changes don't regress this.
Augie Fackler - April 3, 2015, 2:49 p.m.
On Wed, Mar 18, 2015 at 10:10:52AM -0700, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1426627796 25200
> #      Tue Mar 17 14:29:56 2015 -0700
> # Node ID 0bd9d2392a53fb6b5b9deac82d6fb29c80c6a572
> # Parent  567ae53657544744155897ada91f16f8af61ad8a
> revbranchcache: add test for when the cache is not writable

For my own sanity: v1 of this got queued, but with the #if added.

>
> The revbranchecache code already handled the case when the cache file wasn't
> writable, but let's add a test as well so future changes don't regress this.
>
> diff --git a/tests/test-branches.t b/tests/test-branches.t
> --- a/tests/test-branches.t
> +++ b/tests/test-branches.t
> @@ -547,6 +547,17 @@ revision branch cache is created when bu
>    0050: bf be 84 1b 00 00 00 02 d3 f1 63 45 80 00 00 02 |..........cE....|
>    0060: e3 d4 9c 05 80 00 00 02 e2 3b 55 05 00 00 00 02 |.........;U.....|
>    0070: f8 94 c2 56 80 00 00 03                         |...V....|
> +
> +#if unix-permissions no-root
> +no errors when revbranchcache is not writable
> +  $ echo >> .hg/cache/rbc-revs-v1
> +  $ chmod a-w .hg/cache/rbc-revs-v1
> +  $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug
> +  couldn't write revision branch cache: [Errno 13] Permission denied: '$TESTTMP/a/.hg/cache/rbc-revs-v1'
> +  5
> +  $ chmod a+w .hg/cache/rbc-revs-v1
> +#endif
> +
>  recovery from invalid cache revs file with trailing data
>    $ echo >> .hg/cache/rbc-revs-v1
>    $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/tests/test-branches.t b/tests/test-branches.t
--- a/tests/test-branches.t
+++ b/tests/test-branches.t
@@ -547,6 +547,17 @@  revision branch cache is created when bu
   0050: bf be 84 1b 00 00 00 02 d3 f1 63 45 80 00 00 02 |..........cE....|
   0060: e3 d4 9c 05 80 00 00 02 e2 3b 55 05 00 00 00 02 |.........;U.....|
   0070: f8 94 c2 56 80 00 00 03                         |...V....|
+
+#if unix-permissions no-root
+no errors when revbranchcache is not writable
+  $ echo >> .hg/cache/rbc-revs-v1
+  $ chmod a-w .hg/cache/rbc-revs-v1
+  $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug
+  couldn't write revision branch cache: [Errno 13] Permission denied: '$TESTTMP/a/.hg/cache/rbc-revs-v1'
+  5
+  $ chmod a+w .hg/cache/rbc-revs-v1
+#endif
+
 recovery from invalid cache revs file with trailing data
   $ echo >> .hg/cache/rbc-revs-v1
   $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug