tests/test-lfs-serve.t
changeset 48657 68b7faeb6ef3
parent 47077 119790e1c67c
child 48879 9987d14ad63f
equal deleted inserted replaced
48656:100481195114 48657:68b7faeb6ef3
    32 #endif
    32 #endif
    33   $ export PYTHONPATH
    33   $ export PYTHONPATH
    34 
    34 
    35   $ hg init server
    35   $ hg init server
    36   $ SERVER_REQUIRES="$TESTTMP/server/.hg/requires"
    36   $ SERVER_REQUIRES="$TESTTMP/server/.hg/requires"
       
    37   $ SERVER_PATH="$TESTTMP/server/"
    37 
    38 
    38   $ cat > $TESTTMP/debugprocessors.py <<EOF
    39   $ cat > $TESTTMP/debugprocessors.py <<EOF
    39   > from mercurial import (
    40   > from mercurial import (
    40   >     cmdutil,
    41   >     cmdutil,
    41   >     commands,
    42   >     commands,
    83   >    serve -p $HGPORT -d --pid-file=hg.pid --errorlog=$TESTTMP/errors.log
    84   >    serve -p $HGPORT -d --pid-file=hg.pid --errorlog=$TESTTMP/errors.log
    84 #endif
    85 #endif
    85 
    86 
    86   $ cat hg.pid >> $DAEMON_PIDS
    87   $ cat hg.pid >> $DAEMON_PIDS
    87   $ hg clone -q http://localhost:$HGPORT client
    88   $ hg clone -q http://localhost:$HGPORT client
    88   $ grep 'lfs' client/.hg/requires $SERVER_REQUIRES
    89   $ hg debugrequires -R client | grep 'lfs'
       
    90   [1]
       
    91   $ hg debugrequires -R $SERVER_PATH | grep 'lfs'
    89   [1]
    92   [1]
    90 
    93 
    91 This trivial repo will force commandserver to load the extension, but not call
    94 This trivial repo will force commandserver to load the extension, but not call
    92 reposetup() on another repo actually being operated on.  This gives coverage
    95 reposetup() on another repo actually being operated on.  This gives coverage
    93 that wrapper functions are not assuming reposetup() was called.
    96 that wrapper functions are not assuming reposetup() was called.
   127   +++ b/nonlfs.txt	Thu Jan 01 00:00:00 1970 +0000
   130   +++ b/nonlfs.txt	Thu Jan 01 00:00:00 1970 +0000
   128   @@ -0,0 +1,1 @@
   131   @@ -0,0 +1,1 @@
   129   +non-lfs
   132   +non-lfs
   130   *** runcommand debugupgraderepo -q --run
   133   *** runcommand debugupgraderepo -q --run
   131 
   134 
   132   $ grep 'lfs' .hg/requires $SERVER_REQUIRES
   135   $ hg debugrequires -R $SERVER_PATH | grep 'lfs'
   133   [1]
   136   [1]
   134 
   137 
   135 #if lfsremote-on
   138 #if lfsremote-on
   136 
   139 
   137   $ hg push -q
   140   $ hg push -q
   138   $ grep 'lfs' .hg/requires $SERVER_REQUIRES
   141   $ hg debugrequires -R $SERVER_PATH | grep 'lfs'
   139   [1]
   142   [1]
   140 
   143 
   141   $ hg clone -q http://localhost:$HGPORT $TESTTMP/client1_clone
   144   $ hg clone -q http://localhost:$HGPORT $TESTTMP/client1_clone
   142   $ grep 'lfs' $TESTTMP/client1_clone/.hg/requires $SERVER_REQUIRES
   145   $ hg debugrequires -R $TESTTMP/client1_clone/ | grep 'lfs'
       
   146   [1]
       
   147   $ hg debugrequires -R $SERVER_PATH | grep 'lfs'
   143   [1]
   148   [1]
   144 
   149 
   145   $ hg init $TESTTMP/client1_pull
   150   $ hg init $TESTTMP/client1_pull
   146   $ hg -R $TESTTMP/client1_pull pull -q http://localhost:$HGPORT
   151   $ hg -R $TESTTMP/client1_pull pull -q http://localhost:$HGPORT
   147   $ grep 'lfs' $TESTTMP/client1_pull/.hg/requires $SERVER_REQUIRES
   152   $ hg debugrequires -R $TESTTMP/client1_pull/ | grep 'lfs'
   148   [1]
   153   [1]
   149 
   154   $ hg debugrequires -R $SERVER_PATH | grep 'lfs'
       
   155   [1]
   150   $ hg identify http://localhost:$HGPORT
   156   $ hg identify http://localhost:$HGPORT
   151   d437e1d24fbd
   157   d437e1d24fbd
   152 
   158 
   153 #endif
   159 #endif
   154 
   160 
   165 
   171 
   166 Since no lfs content has been added yet, the push is allowed, even when the
   172 Since no lfs content has been added yet, the push is allowed, even when the
   167 extension is not enabled remotely.
   173 extension is not enabled remotely.
   168 
   174 
   169   $ hg push -q
   175   $ hg push -q
   170   $ grep 'lfs' .hg/requires $SERVER_REQUIRES
   176   $ hg debugrequires | grep 'lfs'
       
   177   [1]
       
   178   $ hg debugrequires -R $SERVER_PATH | grep 'lfs'
   171   [1]
   179   [1]
   172 
   180 
   173   $ hg clone -q http://localhost:$HGPORT $TESTTMP/client2_clone
   181   $ hg clone -q http://localhost:$HGPORT $TESTTMP/client2_clone
   174   $ grep 'lfs' $TESTTMP/client2_clone/.hg/requires $SERVER_REQUIRES
   182   $ hg debugrequires -R $TESTTMP/client2_clone/ | grep 'lfs'
       
   183   [1]
       
   184   $ hg debugrequires -R $SERVER_PATH | grep 'lfs'
   175   [1]
   185   [1]
   176 
   186 
   177   $ hg init $TESTTMP/client2_pull
   187   $ hg init $TESTTMP/client2_pull
   178   $ hg -R $TESTTMP/client2_pull pull -q http://localhost:$HGPORT
   188   $ hg -R $TESTTMP/client2_pull pull -q http://localhost:$HGPORT
   179   $ grep 'lfs' $TESTTMP/client2_pull/.hg/requires $SERVER_REQUIRES
   189   $ hg debugrequires -R $TESTTMP/client2_pull/ | grep 'lfs'
       
   190   [1]
       
   191   $ hg debugrequires -R $SERVER_PATH | grep 'lfs'
   180   [1]
   192   [1]
   181 
   193 
   182   $ hg identify http://localhost:$HGPORT
   194   $ hg identify http://localhost:$HGPORT
   183   1477875038c6
   195   1477875038c6
   184 
   196 
   187 non-lfs content, and the extension state controlled by #testcases.  The server
   199 non-lfs content, and the extension state controlled by #testcases.  The server
   188 should have an 'lfs' requirement after it picks up its first commit with a blob.
   200 should have an 'lfs' requirement after it picks up its first commit with a blob.
   189 
   201 
   190   $ echo 'this is a big lfs file' > lfs.bin
   202   $ echo 'this is a big lfs file' > lfs.bin
   191   $ hg ci -Aqm 'lfs'
   203   $ hg ci -Aqm 'lfs'
   192   $ grep 'lfs' .hg/requires $SERVER_REQUIRES
   204   $ hg debugrequires | grep 'lfs'
   193   .hg/requires:lfs
   205   lfs
       
   206   $ hg debugrequires -R $SERVER_PATH | grep 'lfs'
       
   207   [1]
   194 
   208 
   195 #if lfsremote-off
   209 #if lfsremote-off
   196   $ hg push -q
   210   $ hg push -q
   197   abort: required features are not supported in the destination: lfs
   211   abort: required features are not supported in the destination: lfs
   198   (enable the lfs extension on the server)
   212   (enable the lfs extension on the server)
   199   [255]
   213   [255]
   200 #else
   214 #else
   201   $ hg push -q
   215   $ hg push -q
   202 #endif
   216 #endif
   203   $ grep 'lfs' .hg/requires $SERVER_REQUIRES
   217   $ hg debugrequires | grep 'lfs'
   204   .hg/requires:lfs
   218   lfs
   205   $TESTTMP/server/.hg/requires:lfs (lfsremote-on !)
   219   $ hg debugrequires -R $SERVER_PATH | grep 'lfs' || true
       
   220   lfs (lfsremote-on !)
   206 
   221 
   207   $ hg clone -q http://localhost:$HGPORT $TESTTMP/client3_clone
   222   $ hg clone -q http://localhost:$HGPORT $TESTTMP/client3_clone
   208   $ grep 'lfs' $TESTTMP/client3_clone/.hg/requires $SERVER_REQUIRES || true
   223 
   209   $TESTTMP/client3_clone/.hg/requires:lfs (lfsremote-on !)
   224   $ hg debugrequires -R $TESTTMP/client3_clone/ | grep 'lfs' || true
   210   $TESTTMP/server/.hg/requires:lfs (lfsremote-on !)
   225   lfs (lfsremote-on !)
       
   226   $ hg debugrequires -R $SERVER_PATH | grep 'lfs' || true
       
   227   lfs (lfsremote-on !)
   211 
   228 
   212   $ hg init $TESTTMP/client3_pull
   229   $ hg init $TESTTMP/client3_pull
   213   $ hg -R $TESTTMP/client3_pull pull -q http://localhost:$HGPORT
   230   $ hg -R $TESTTMP/client3_pull pull -q http://localhost:$HGPORT
   214   $ grep 'lfs' $TESTTMP/client3_pull/.hg/requires $SERVER_REQUIRES || true
   231   $ hg debugrequires -R $TESTTMP/client3_pull/ | grep 'lfs' || true
   215   $TESTTMP/client3_pull/.hg/requires:lfs (lfsremote-on !)
   232   lfs (lfsremote-on !)
   216   $TESTTMP/server/.hg/requires:lfs (lfsremote-on !)
   233   $ hg debugrequires -R $SERVER_PATH | grep 'lfs' || true
       
   234   lfs (lfsremote-on !)
   217 
   235 
   218 Test that the commit/changegroup requirement check hook can be run multiple
   236 Test that the commit/changegroup requirement check hook can be run multiple
   219 times.
   237 times.
   220 
   238 
   221   $ hg clone -qr 0 http://localhost:$HGPORT $TESTTMP/cmdserve_client3
   239   $ hg clone -qr 0 http://localhost:$HGPORT $TESTTMP/cmdserve_client3
   265   > [paths]
   283   > [paths]
   266   > default = http://localhost:$HGPORT
   284   > default = http://localhost:$HGPORT
   267   > EOF
   285   > EOF
   268   $ echo 'non-lfs' > nonlfs2.txt
   286   $ echo 'non-lfs' > nonlfs2.txt
   269   $ hg ci -Aqm 'non-lfs'
   287   $ hg ci -Aqm 'non-lfs'
   270   $ grep 'lfs' .hg/requires $SERVER_REQUIRES
   288   $ hg debugrequires -R $SERVER_PATH --config extensions.lfs= | grep 'lfs'
   271   $TESTTMP/server/.hg/requires:lfs
   289   lfs
   272 
   290 
   273   $ hg push -q --force
   291   $ hg push -q --force
   274   warning: repository is unrelated
   292   warning: repository is unrelated
   275   $ grep 'lfs' .hg/requires $SERVER_REQUIRES
   293   $ hg debugrequires -R $SERVER_PATH --config extensions.lfs= | grep 'lfs'
   276   $TESTTMP/server/.hg/requires:lfs
   294   lfs
   277 
   295 
   278   $ hg clone http://localhost:$HGPORT $TESTTMP/client4_clone
   296   $ hg clone http://localhost:$HGPORT $TESTTMP/client4_clone
   279   (remote is using large file support (lfs), but it is explicitly disabled in the local configuration)
   297   (remote is using large file support (lfs), but it is explicitly disabled in the local configuration)
   280   abort: repository requires features unknown to this Mercurial: lfs
   298   abort: repository requires features unknown to this Mercurial: lfs
   281   (see https://mercurial-scm.org/wiki/MissingRequirement for more information)
   299   (see https://mercurial-scm.org/wiki/MissingRequirement for more information)
   282   [255]
   300   [255]
   283   $ grep 'lfs' $TESTTMP/client4_clone/.hg/requires $SERVER_REQUIRES
   301   $ hg debugrequires -R $TESTTMP/client4_clone/ | grep 'lfs'
   284   grep: $TESTTMP/client4_clone/.hg/requires: $ENOENT$
   302   abort: repository $TESTTMP/client4_clone/ not found
   285   $TESTTMP/server/.hg/requires:lfs
   303   [1]
   286   [2]
   304   $ hg debugrequires -R $SERVER_PATH --config extensions.lfs= | grep 'lfs'
       
   305   lfs
   287 
   306 
   288 TODO: fail more gracefully.
   307 TODO: fail more gracefully.
   289 
   308 
   290   $ hg init $TESTTMP/client4_pull
   309   $ hg init $TESTTMP/client4_pull
   291   $ hg -R $TESTTMP/client4_pull pull http://localhost:$HGPORT
   310   $ hg -R $TESTTMP/client4_pull pull http://localhost:$HGPORT
   292   pulling from http://localhost:$HGPORT/
   311   pulling from http://localhost:$HGPORT/
   293   requesting all changes
   312   requesting all changes
   294   remote: abort: no common changegroup version
   313   remote: abort: no common changegroup version
   295   abort: pull failed on remote
   314   abort: pull failed on remote
   296   [100]
   315   [100]
   297   $ grep 'lfs' $TESTTMP/client4_pull/.hg/requires $SERVER_REQUIRES
   316   $ hg debugrequires -R $TESTTMP/client4_pull/ | grep 'lfs'
   298   $TESTTMP/server/.hg/requires:lfs
   317   [1]
       
   318   $ hg debugrequires -R $SERVER_PATH --config extensions.lfs= | grep 'lfs'
       
   319   lfs
   299 
   320 
   300   $ hg identify http://localhost:$HGPORT
   321   $ hg identify http://localhost:$HGPORT
   301   03b080fa9d93
   322   03b080fa9d93
   302 
   323 
   303 --------------------------------------------------------------------------------
   324 --------------------------------------------------------------------------------
   310   > EOF
   331   > EOF
   311   $ echo 'non-lfs' > nonlfs3.txt
   332   $ echo 'non-lfs' > nonlfs3.txt
   312   $ hg ci -Aqm 'non-lfs file with lfs client'
   333   $ hg ci -Aqm 'non-lfs file with lfs client'
   313 
   334 
   314   $ hg push -q
   335   $ hg push -q
   315   $ grep 'lfs' .hg/requires $SERVER_REQUIRES
   336   $ hg debugrequires -R $SERVER_PATH | grep 'lfs'
   316   $TESTTMP/server/.hg/requires:lfs
   337   lfs
   317 
   338 
   318   $ hg clone -q http://localhost:$HGPORT $TESTTMP/client5_clone
   339   $ hg clone -q http://localhost:$HGPORT $TESTTMP/client5_clone
   319   $ grep 'lfs' $TESTTMP/client5_clone/.hg/requires $SERVER_REQUIRES
   340   $ hg debugrequires -R $TESTTMP/client5_clone/ | grep 'lfs'
   320   $TESTTMP/client5_clone/.hg/requires:lfs
   341   lfs
   321   $TESTTMP/server/.hg/requires:lfs
   342   $ hg debugrequires -R $SERVER_PATH | grep 'lfs'
       
   343   lfs
   322 
   344 
   323   $ hg init $TESTTMP/client5_pull
   345   $ hg init $TESTTMP/client5_pull
   324   $ hg -R $TESTTMP/client5_pull pull -q http://localhost:$HGPORT
   346   $ hg -R $TESTTMP/client5_pull pull -q http://localhost:$HGPORT
   325   $ grep 'lfs' $TESTTMP/client5_pull/.hg/requires $SERVER_REQUIRES
   347   $ hg debugrequires -R $TESTTMP/client5_pull/ | grep 'lfs'
   326   $TESTTMP/client5_pull/.hg/requires:lfs
   348   lfs
   327   $TESTTMP/server/.hg/requires:lfs
   349   $ hg debugrequires -R $SERVER_PATH | grep 'lfs'
       
   350   lfs
   328 
   351 
   329   $ hg identify http://localhost:$HGPORT
   352   $ hg identify http://localhost:$HGPORT
   330   c729025cc5e3
   353   c729025cc5e3
   331 
   354 
   332   $ mv $HGRCPATH $HGRCPATH.tmp
   355   $ mv $HGRCPATH $HGRCPATH.tmp
   461   remote: adding changesets
   484   remote: adding changesets
   462   remote: adding manifests
   485   remote: adding manifests
   463   remote: adding file changes
   486   remote: adding file changes
   464   remote: added 1 changesets with 1 changes to 1 files
   487   remote: added 1 changesets with 1 changes to 1 files
   465   (sent 8 HTTP requests and * bytes; received * bytes in responses) (glob) (?)
   488   (sent 8 HTTP requests and * bytes; received * bytes in responses) (glob) (?)
   466   $ grep 'lfs' .hg/requires $SERVER_REQUIRES
   489   $ hg debugrequires | grep lfs
   467   .hg/requires:lfs
   490   lfs
   468   $TESTTMP/server/.hg/requires:lfs
   491   $ hg debugrequires -R $SERVER_PATH | grep lfs
       
   492   lfs
   469 
   493 
   470   $ hg clone -q http://localhost:$HGPORT $TESTTMP/client6_clone
   494   $ hg clone -q http://localhost:$HGPORT $TESTTMP/client6_clone
   471   $ grep 'lfs' $TESTTMP/client6_clone/.hg/requires $SERVER_REQUIRES
   495   $ hg debugrequires -R $TESTTMP/client6_clone/ | grep lfs
   472   $TESTTMP/client6_clone/.hg/requires:lfs
   496   lfs
   473   $TESTTMP/server/.hg/requires:lfs
   497   $ hg debugrequires -R $SERVER_PATH | grep lfs
       
   498   lfs
   474 
   499 
   475   $ hg init $TESTTMP/client6_pull
   500   $ hg init $TESTTMP/client6_pull
   476   $ hg -R $TESTTMP/client6_pull pull -u -v http://localhost:$HGPORT
   501   $ hg -R $TESTTMP/client6_pull pull -u -v http://localhost:$HGPORT
   477   pulling from http://localhost:$HGPORT/
   502   pulling from http://localhost:$HGPORT/
   478   requesting all changes
   503   requesting all changes
   493   getting nonlfs3.txt
   518   getting nonlfs3.txt
   494   3 files updated, 0 files merged, 0 files removed, 0 files unresolved
   519   3 files updated, 0 files merged, 0 files removed, 0 files unresolved
   495   updated to "d3b84d50eacb: lfs file with lfs client"
   520   updated to "d3b84d50eacb: lfs file with lfs client"
   496   1 other heads for branch "default"
   521   1 other heads for branch "default"
   497   (sent 3 HTTP requests and * bytes; received * bytes in responses) (glob)
   522   (sent 3 HTTP requests and * bytes; received * bytes in responses) (glob)
   498   $ grep 'lfs' $TESTTMP/client6_pull/.hg/requires $SERVER_REQUIRES
   523   $ hg debugrequires -R $TESTTMP/client6_pull/ | grep lfs
   499   $TESTTMP/client6_pull/.hg/requires:lfs
   524   lfs
   500   $TESTTMP/server/.hg/requires:lfs
   525   $ hg debugrequires -R $SERVER_PATH | grep lfs
       
   526   lfs
   501 
   527 
   502   $ hg identify http://localhost:$HGPORT
   528   $ hg identify http://localhost:$HGPORT
   503   d3b84d50eacb
   529   d3b84d50eacb
   504 
   530 
   505 --------------------------------------------------------------------------------
   531 --------------------------------------------------------------------------------