Patchwork D9358: upgrade: add support do downgrade share safe mode

login
register
mail settings
Submitter phabricator
Date Nov. 21, 2020, 1:07 p.m.
Message ID <differential-rev-PHID-DREV-lpd3ulocqkk5iqstmzpe-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47636/
State Superseded
Headers show

Comments

phabricator - Nov. 21, 2020, 1:07 p.m.
pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  In previous patch we added support to upgrade current repository to use share
  safe mode. This patch adds support to downgrade to remove share-safe mode.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9358

AFFECTED FILES
  mercurial/upgrade.py
  tests/test-share-safe.t

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-share-safe.t b/tests/test-share-safe.t
--- a/tests/test-share-safe.t
+++ b/tests/test-share-safe.t
@@ -377,4 +377,61 @@ 
   |
   o  f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo
   
+Test that downgrading works too
+
+  $ cat >> $HGRCPATH <<EOF
+  > [extensions]
+  > share =
+  > [format]
+  > exp-share-safe = False
+  > EOF
+
+  $ hg debugupgraderepo -q
+  requirements
+     preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store
+     removed: exp-sharesafe
+  
+  $ hg debugupgraderepo -q --run
+  upgrade will perform the following actions:
+  
+  requirements
+     preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store
+     removed: exp-sharesafe
+  
+  repository downgraded to not use share safe mode, existing shares will still work in old safe mode. Re-share existing shares. New shares will be created in non-safe mode (no-eol)
+
+  $ hg debugrequirements
+  dotencode
+  fncache
+  generaldelta
+  revlogv1
+  sparserevlog
+  store
+
+  $ cat .hg/requires
+  dotencode
+  fncache
+  generaldelta
+  revlogv1
+  sparserevlog
+  store
+
+  $ test -f .hg/store/requires
+  [1]
+
+  $ hg log -GT "{node}: {desc}\n"
+  @  f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar
+  |
+  o  f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo
+  
+
+Make sure existing shares still works
+
+  $ hg log -GT "{node}: {desc}\n" -R ../nss-share
+  @  f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar
+  |
+  o  f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo
+  
+
+
   $ hg unshare -R ../nss-share
diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -80,6 +80,7 @@ 
         requirements.SIDEDATA_REQUIREMENT,
         requirements.COPIESSDC_REQUIREMENT,
         requirements.NODEMAP_REQUIREMENT,
+        requirements.SHARESAFE_REQUIREMENT,
     }
     for name in compression.compengines:
         engine = compression.compengines[name]
@@ -1465,3 +1466,12 @@ 
                         b' New shares will be created in safe mode.\n'
                     )
                 )
+            if sharedsafe.name in removedreqs:
+                ui.warn(
+                    _(
+                        b'repository downgraded to not use share safe mode, '
+                        b'existing shares will still work in old safe mode. '
+                        b'Re-share existing shares. New shares will be '
+                        b'created in non-safe mode'
+                    )
+                )