comparison mercurial/copies.py @ 43148:843da18386d5

sidedatacopies: deal with upgrading and downgrading to that format This is quite useful to test this on real life data. Differential Revision: https://phab.mercurial-scm.org/D6955
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 06 Oct 2019 23:36:52 -0400
parents 54e943b28101
children c16fe77e340a
comparison
equal deleted inserted replaced
43147:54e943b28101 43148:843da18386d5
10 import collections 10 import collections
11 import heapq 11 import heapq
12 import os 12 import os
13 13
14 from .i18n import _ 14 from .i18n import _
15
16
17 from .revlogutils.flagutil import REVIDX_SIDEDATA
15 18
16 from . import ( 19 from . import (
17 error, 20 error,
18 match as matchmod, 21 match as matchmod,
19 node, 22 node,
20 pathutil, 23 pathutil,
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
27 def _findlimit(repo, ctxa, ctxb): 33 def _findlimit(repo, ctxa, ctxb):
28 """ 34 """
953 return subset 959 return subset
954 except (ValueError, IndexError): 960 except (ValueError, IndexError):
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