diff tests/test-share-safe.t @ 46235:0babe12ef35d

sharesafe: introduce functionality to automatically upgrade shares In past few months, we have developed a `share-safe` mode for sharing repository in which share source requirements and config values are shared with the shares. To get it rolling, an important task is to get these shares automatically upgraded. We are focusing on an installation where shares are created by scripts and test jobs. It will be difficult to manually upgrade these and we need some functionality to do so automatically. This patch introduces a config option to deal with it. If all of the following conditions are met, we upgrade the share repository automatically: * If the config option is enabled * Share source repository is share-safe enabled * Share is not share-safe enabled * Any command is run in the share Upgrading the share is pretty easy as it involves only editing the requirements file. Differential Revision: https://phab.mercurial-scm.org/D9679
author Pulkit Goyal <7895pulkit@gmail.com>
date Wed, 06 Jan 2021 16:18:06 +0530
parents 6c960b708ac4
children eec47efe219d
line wrap: on
line diff
--- a/tests/test-share-safe.t	Wed Jan 06 16:01:19 2021 +0530
+++ b/tests/test-share-safe.t	Wed Jan 06 16:18:06 2021 +0530
@@ -479,8 +479,63 @@
   |
   o  f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo
   
-  $ hg unshare -R ../nss-share
 
   $ hg log -GT "{node}: {desc}\n" -R ../ss-share
   abort: share source does not support exp-sharesafe requirement
   [255]
+
+
+Testing automatic upgrade of shares when config is set
+
+  $ hg debugupgraderepo -q --run --config format.exp-share-safe=True
+  upgrade will perform the following actions:
+  
+  requirements
+     preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store
+     added: exp-sharesafe
+  
+  processed revlogs:
+    - all-filelogs
+    - changelog
+    - manifest
+  
+  repository upgraded to share safe mode, existing shares will still work in old non-safe mode. Re-share existing shares to use them in safe mode New shares will be created in safe mode.
+  $ hg debugrequirements
+  dotencode
+  exp-sharesafe
+  fncache
+  generaldelta
+  revlogv1
+  sparserevlog
+  store
+  $ hg log -GT "{node}: {desc}\n" -R ../nss-share
+  warning: source repository supports share-safe functionality. Reshare to upgrade.
+  @  f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar
+  |
+  o  f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo
+  
+
+Check that if lock is taken, upgrade fails but read operation are successful
+  $ touch ../nss-share/.hg/wlock
+  $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config experimental.sharesafe-auto-upgrade-shares=true
+  failed to upgrade share, got error: Lock held
+  @  f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar
+  |
+  o  f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo
+  
+  $ rm ../nss-share/.hg/wlock
+  $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config experimental.sharesafe-auto-upgrade-shares=true
+  repository upgraded to use share-safe mode
+  @  f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar
+  |
+  o  f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo
+  
+
+Test that unshare works
+
+  $ hg unshare -R ../nss-share
+  $ hg log -GT "{node}: {desc}\n" -R ../nss-share
+  @  f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar
+  |
+  o  f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo
+