##// END OF EJS Templates
sidedatacopies: deal with upgrading and downgrading to that format...
marmoute -
r43418:843da183 default
parent child Browse files
Show More
@@ -13,6 +13,9 b' import os'
13
13
14 from .i18n import _
14 from .i18n import _
15
15
16
17 from .revlogutils.flagutil import REVIDX_SIDEDATA
18
16 from . import (
19 from . import (
17 error,
20 error,
18 match as matchmod,
21 match as matchmod,
@@ -21,6 +24,9 b' from . import ('
21 pycompat,
24 pycompat,
22 util,
25 util,
23 )
26 )
27
28 from .revlogutils import sidedata as sidedatamod
29
24 from .utils import stringutil
30 from .utils import stringutil
25
31
26
32
@@ -955,3 +961,49 b' def decodefileindices(files, data):'
955 # Perhaps someone had chosen the same key name (e.g. "added") and
961 # Perhaps someone had chosen the same key name (e.g. "added") and
956 # used different syntax for the value.
962 # used different syntax for the value.
957 return None
963 return None
964
965
966 def _getsidedata(srcrepo, rev):
967 ctx = srcrepo[rev]
968 filescopies = computechangesetcopies(ctx)
969 filesadded = computechangesetfilesadded(ctx)
970 filesremoved = computechangesetfilesremoved(ctx)
971 sidedata = {}
972 if any([filescopies, filesadded, filesremoved]):
973 sortedfiles = sorted(ctx.files())
974 p1copies, p2copies = filescopies
975 p1copies = encodecopies(sortedfiles, p1copies)
976 p2copies = encodecopies(sortedfiles, p2copies)
977 filesadded = encodefileindices(sortedfiles, filesadded)
978 filesremoved = encodefileindices(sortedfiles, filesremoved)
979 sidedata[sidedatamod.SD_P1COPIES] = p1copies
980 sidedata[sidedatamod.SD_P2COPIES] = p2copies
981 sidedata[sidedatamod.SD_FILESADDED] = filesadded
982 sidedata[sidedatamod.SD_FILESREMOVED] = filesremoved
983 return sidedata
984
985
986 def getsidedataadder(srcrepo, destrepo):
987 def sidedatacompanion(revlog, rev):
988 sidedata = {}
989 if util.safehasattr(revlog, 'filteredrevs'): # this is a changelog
990 sidedata = _getsidedata(srcrepo, rev)
991 return False, (), sidedata
992
993 return sidedatacompanion
994
995
996 def getsidedataremover(srcrepo, destrepo):
997 def sidedatacompanion(revlog, rev):
998 f = ()
999 if util.safehasattr(revlog, 'filteredrevs'): # this is a changelog
1000 if revlog.flags(rev) & REVIDX_SIDEDATA:
1001 f = (
1002 sidedatamod.SD_P1COPIES,
1003 sidedatamod.SD_P2COPIES,
1004 sidedatamod.SD_FILESADDED,
1005 sidedatamod.SD_FILESREMOVED,
1006 )
1007 return False, f, {}
1008
1009 return sidedatacompanion
@@ -13,6 +13,7 b' from .i18n import _'
13 from .pycompat import getattr
13 from .pycompat import getattr
14 from . import (
14 from . import (
15 changelog,
15 changelog,
16 copies,
16 error,
17 error,
17 filelog,
18 filelog,
18 hg,
19 hg,
@@ -31,7 +32,6 b' from .utils import compression'
31 RECLONES_REQUIREMENTS = {
32 RECLONES_REQUIREMENTS = {
32 b'generaldelta',
33 b'generaldelta',
33 localrepo.SPARSEREVLOG_REQUIREMENT,
34 localrepo.SPARSEREVLOG_REQUIREMENT,
34 localrepo.SIDEDATA_REQUIREMENT,
35 }
35 }
36
36
37
37
@@ -77,6 +77,7 b' def supportremovedrequirements(repo):'
77 supported = {
77 supported = {
78 localrepo.SPARSEREVLOG_REQUIREMENT,
78 localrepo.SPARSEREVLOG_REQUIREMENT,
79 localrepo.SIDEDATA_REQUIREMENT,
79 localrepo.SIDEDATA_REQUIREMENT,
80 localrepo.COPIESSDC_REQUIREMENT,
80 }
81 }
81 for name in compression.compengines:
82 for name in compression.compengines:
82 engine = compression.compengines[name]
83 engine = compression.compengines[name]
@@ -103,6 +104,7 b' def supporteddestrequirements(repo):'
103 b'store',
104 b'store',
104 localrepo.SPARSEREVLOG_REQUIREMENT,
105 localrepo.SPARSEREVLOG_REQUIREMENT,
105 localrepo.SIDEDATA_REQUIREMENT,
106 localrepo.SIDEDATA_REQUIREMENT,
107 localrepo.COPIESSDC_REQUIREMENT,
106 }
108 }
107 for name in compression.compengines:
109 for name in compression.compengines:
108 engine = compression.compengines[name]
110 engine = compression.compengines[name]
@@ -129,6 +131,7 b' def allowednewrequirements(repo):'
129 b'generaldelta',
131 b'generaldelta',
130 localrepo.SPARSEREVLOG_REQUIREMENT,
132 localrepo.SPARSEREVLOG_REQUIREMENT,
131 localrepo.SIDEDATA_REQUIREMENT,
133 localrepo.SIDEDATA_REQUIREMENT,
134 localrepo.COPIESSDC_REQUIREMENT,
132 }
135 }
133 for name in compression.compengines:
136 for name in compression.compengines:
134 engine = compression.compengines[name]
137 engine = compression.compengines[name]
@@ -698,6 +701,7 b' UPGRADE_ALL_REVLOGS = frozenset('
698 def getsidedatacompanion(srcrepo, dstrepo):
701 def getsidedatacompanion(srcrepo, dstrepo):
699 sidedatacompanion = None
702 sidedatacompanion = None
700 removedreqs = srcrepo.requirements - dstrepo.requirements
703 removedreqs = srcrepo.requirements - dstrepo.requirements
704 addedreqs = dstrepo.requirements - srcrepo.requirements
701 if localrepo.SIDEDATA_REQUIREMENT in removedreqs:
705 if localrepo.SIDEDATA_REQUIREMENT in removedreqs:
702
706
703 def sidedatacompanion(rl, rev):
707 def sidedatacompanion(rl, rev):
@@ -706,6 +710,10 b' def getsidedatacompanion(srcrepo, dstrep'
706 return True, (), {}
710 return True, (), {}
707 return False, (), {}
711 return False, (), {}
708
712
713 elif localrepo.COPIESSDC_REQUIREMENT in addedreqs:
714 sidedatacompanion = copies.getsidedataadder(srcrepo, dstrepo)
715 elif localrepo.COPIESSDC_REQUIREMENT in removedreqs:
716 sidedatacompanion = copies.getsidedataremover(srcrepo, dstrepo)
709 return sidedatacompanion
717 return sidedatacompanion
710
718
711
719
@@ -450,4 +450,91 b' Test committing half a rename'
450 $ hg ci -Aqm 'add a'
450 $ hg ci -Aqm 'add a'
451 $ hg mv a b
451 $ hg mv a b
452 $ hg ci -m 'remove a' a
452 $ hg ci -m 'remove a' a
453
454 #if sidedata
455
456 Test upgrading/downgrading to sidedata storage
457 ==============================================
458
459 downgrading (keeping some sidedata)
460
461 $ hg debugformat -v
462 format-variant repo config default
463 fncache: yes yes yes
464 dotencode: yes yes yes
465 generaldelta: yes yes yes
466 sparserevlog: yes yes yes
467 sidedata: yes yes no
468 copies-sdc: yes yes no
469 plain-cl-delta: yes yes yes
470 compression: zlib zlib zlib
471 compression-level: default default default
472 $ hg debugsidedata -c -- 0
473 4 sidedata entries
474 entry-0010 size 0
475 entry-0011 size 0
476 entry-0012 size 1
477 entry-0013 size 0
478 $ hg debugsidedata -c -- 1
479 4 sidedata entries
480 entry-0010 size 0
481 entry-0011 size 0
482 entry-0012 size 0
483 entry-0013 size 1
484 $ hg debugsidedata -m -- 0
485 $ cat << EOF > .hg/hgrc
486 > [format]
487 > use-side-data = yes
488 > exp-use-copies-side-data-changeset = no
489 > EOF
490 $ hg debugupgraderepo --run --quiet --no-backup > /dev/null
491 $ hg debugformat -v
492 format-variant repo config default
493 fncache: yes yes yes
494 dotencode: yes yes yes
495 generaldelta: yes yes yes
496 sparserevlog: yes yes yes
497 sidedata: yes yes no
498 copies-sdc: no no no
499 plain-cl-delta: yes yes yes
500 compression: zlib zlib zlib
501 compression-level: default default default
502 $ hg debugsidedata -c -- 0
503 $ hg debugsidedata -c -- 1
504 $ hg debugsidedata -m -- 0
505
506 upgrading
507
508 $ cat << EOF > .hg/hgrc
509 > [format]
510 > exp-use-copies-side-data-changeset = yes
511 > EOF
512 $ hg debugupgraderepo --run --quiet --no-backup > /dev/null
513 $ hg debugformat -v
514 format-variant repo config default
515 fncache: yes yes yes
516 dotencode: yes yes yes
517 generaldelta: yes yes yes
518 sparserevlog: yes yes yes
519 sidedata: yes yes no
520 copies-sdc: yes yes no
521 plain-cl-delta: yes yes yes
522 compression: zlib zlib zlib
523 compression-level: default default default
524 $ hg debugsidedata -c -- 0
525 4 sidedata entries
526 entry-0010 size 0
527 entry-0011 size 0
528 entry-0012 size 1
529 entry-0013 size 0
530 $ hg debugsidedata -c -- 1
531 4 sidedata entries
532 entry-0010 size 0
533 entry-0011 size 0
534 entry-0012 size 0
535 entry-0013 size 1
536 $ hg debugsidedata -m -- 0
537
538 #endif
539
453 $ cd ..
540 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now