pullbundle: add a config option for the cache directory
authorPierre-Yves David <pierre-yves.david@octobus.net>
Mon, 24 Sep 2018 00:28:10 +0200
changeset 4134 ab77f37fedf3
parent 4133 1293625d274d
child 4135 47f1d7b4305d
pullbundle: add a config option for the cache directory
hgext3rd/pullbundle.py
tests/test-pullbundle.t
--- a/hgext3rd/pullbundle.py	Sun Sep 23 22:58:11 2018 +0200
+++ b/hgext3rd/pullbundle.py	Mon Sep 24 00:28:10 2018 +0200
@@ -39,6 +39,14 @@
     [experimental]
     evolution.exchange=no
 
+Extra Configuration
+===================
+
+  [pullbundle]
+  # By default bundles are stored `.hg/cache/pullbundles/.
+  # This can be changed with the following config:
+  cache-directory=/absolute/path
+
 Implementation status
 =====================
 
@@ -69,11 +77,19 @@
     exchange,
     narrowspec,
     node as nodemod,
+    registrar,
     util,
 )
 
 from mercurial.i18n import _
 
+configtable = {}
+configitem = registrar.configitem(configtable)
+
+configitem('pullbundle', 'cache-directory',
+           default=None,
+)
+
 # generic wrapping
 
 def uisetup(ui):
@@ -310,6 +326,9 @@
 # cache management
 
 def cachedir(repo):
+    cachedir = repo.ui.config('pullbundle', 'cache-directory')
+    if cachedir is not None:
+        return cachedir
     return repo.cachevfs.join('pullbundles')
 
 def getcache(repo, bundlename):
--- a/tests/test-pullbundle.t	Sun Sep 23 22:58:11 2018 +0200
+++ b/tests/test-pullbundle.t	Mon Sep 24 00:28:10 2018 +0200
@@ -2127,3 +2127,99 @@
    02-e74670ea99533967c5d90da3ddbc0318cc1fd502-0000001528skip-0000000008size.hg
    02-ee2deecf044fa5583f66188c9177b0f13332adc2-0000001024skip-0000000128size.hg
   [1]
+
+Test cache setting
+==================
+
+cache directory
+---------------
+
+  $ mkdir bundle-cache
+  $ cat << EOF >> $HGRCPATH
+  > [pullbundle]
+  > cache-directory=$TESTTMP/bundle-cache
+  > EOF
+
+  $ hg clone --pull server client5
+  requesting all changes
+  pullbundle-cache: "missing" set sliced into 15 subranges in *.* seconds (glob)
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1024 changesets with 0 changes to 0 files
+  adding changesets
+  adding manifests
+  adding file changes
+  added 512 changesets with 0 changes to 0 files
+  adding changesets
+  adding manifests
+  adding file changes
+  added 256 changesets with 0 changes to 0 files
+  adding changesets
+  adding manifests
+  adding file changes
+  added 64 changesets with 0 changes to 0 files
+  adding changesets
+  adding manifests
+  adding file changes
+  added 8 changesets with 0 changes to 0 files
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 0 changes to 0 files (+1 heads)
+  adding changesets
+  adding manifests
+  adding file changes
+  added 4 changesets with 0 changes to 0 files
+  adding changesets
+  adding manifests
+  adding file changes
+  added 8 changesets with 0 changes to 0 files
+  adding changesets
+  adding manifests
+  adding file changes
+  added 16 changesets with 0 changes to 0 files
+  adding changesets
+  adding manifests
+  adding file changes
+  added 128 changesets with 0 changes to 0 files
+  adding changesets
+  adding manifests
+  adding file changes
+  added 64 changesets with 0 changes to 0 files
+  adding changesets
+  adding manifests
+  adding file changes
+  added 32 changesets with 0 changes to 0 files
+  adding changesets
+  adding manifests
+  adding file changes
+  added 8 changesets with 0 changes to 0 files
+  adding changesets
+  adding manifests
+  adding file changes
+  added 4 changesets with 0 changes to 0 files
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 0 changes to 0 files
+  new changesets 1ea73414a91b:1dded5aafa0f
+  updating to branch default
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+  $ ls -1 bundle-cache
+  02-0f376356904fc8c1c6ceaac27990f2fd79b1f8c1-0000001856skip-0000000008size.hg
+  02-1dded5aafa0f8d548f6357cc2f8882dcc4489fbf-0000001516skip-0000000002size.hg
+  02-2dc4f1ab9029719714b8e0dde8e3725a5bb28472-0000001408skip-0000000064size.hg
+  02-2f0e261a08964bc1c607c0eda4978364c22a9b94-0000001504skip-0000000008size.hg
+  02-4a6d0f7d07d060b026d9fc690cd89cd26af96e42-0000001264skip-0000000016size.hg
+  02-540f762640ee62ca597ece26af725e6357e82805-0000000000skip-0000001024size.hg
+  02-5eaa75df73c454c1afff722301a4c73e897de94d-0000001256skip-0000000008size.hg
+  02-b2d350c94c26edbb783aaa21fc24f1fc65c30e74-0000001536skip-0000000256size.hg
+  02-bbd293bd171fd5b711d428db46940a72eca7a40f-0000001280skip-0000000128size.hg
+  02-ca970a853ea24846035ccb324cc8de49ef768748-0000001252skip-0000000004size.hg
+  02-d1807e3513890ac71c2e8d10e9dc9a5b58b15d4b-0000001251skip-0000000001size.hg
+  02-da87a81c5310760f414a933e6550b7e8e60cf241-0000001792skip-0000000064size.hg
+  02-dba2fddbf3c28198659046674a512afd616a1519-0000001472skip-0000000032size.hg
+  02-e74670ea99533967c5d90da3ddbc0318cc1fd502-0000001024skip-0000000512size.hg
+  02-fb6c210a224903e81e5a8d2ee099cb0c9526ba8c-0000001512skip-0000000004size.hg