835 copies_sidedata_computer, |
834 copies_sidedata_computer, |
836 sidedataflag.REVIDX_HASCOPIESINFO, |
835 sidedataflag.REVIDX_HASCOPIESINFO, |
837 ) |
836 ) |
838 |
837 |
839 |
838 |
840 def getsidedataadder(srcrepo, destrepo): |
|
841 use_w = srcrepo.ui.configbool(b'experimental', b'worker.repository-upgrade') |
|
842 if pycompat.iswindows or not use_w: |
|
843 return _get_simple_sidedata_adder(srcrepo, destrepo) |
|
844 else: |
|
845 return _get_worker_sidedata_adder(srcrepo, destrepo) |
|
846 |
|
847 |
|
848 def _sidedata_worker(srcrepo, revs_queue, sidedata_queue, tokens): |
839 def _sidedata_worker(srcrepo, revs_queue, sidedata_queue, tokens): |
849 """The function used by worker precomputing sidedata |
840 """The function used by worker precomputing sidedata |
850 |
841 |
851 It read an input queue containing revision numbers |
842 It read an input queue containing revision numbers |
852 It write in an output queue containing (rev, <sidedata-map>) |
843 It write in an output queue containing (rev, <sidedata-map>) |
909 # dictionnary to store results for revision higher than we one we are |
900 # dictionnary to store results for revision higher than we one we are |
910 # looking for. For example, if we need the sidedatamap for 42, and 43 is |
901 # looking for. For example, if we need the sidedatamap for 42, and 43 is |
911 # received, when shelve 43 for later use. |
902 # received, when shelve 43 for later use. |
912 staging = {} |
903 staging = {} |
913 |
904 |
914 def sidedata_companion(revlog, rev): |
905 def sidedata_companion(repo, revlog, rev, old_sidedata): |
915 data = {}, False |
906 # Is the data previously shelved ? |
916 if util.safehasattr(revlog, b'filteredrevs'): # this is a changelog |
907 data = staging.pop(rev, None) |
917 # Is the data previously shelved ? |
908 if data is None: |
918 data = staging.pop(rev, None) |
909 # look at the queued result until we find the one we are lookig |
919 if data is None: |
910 # for (shelve the other ones) |
920 # look at the queued result until we find the one we are lookig |
911 r, data = sidedataq.get() |
921 # for (shelve the other ones) |
912 while r != rev: |
|
913 staging[r] = data |
922 r, data = sidedataq.get() |
914 r, data = sidedataq.get() |
923 while r != rev: |
915 tokens.release() |
924 staging[r] = data |
|
925 r, data = sidedataq.get() |
|
926 tokens.release() |
|
927 sidedata, has_copies_info = data |
916 sidedata, has_copies_info = data |
928 new_flag = 0 |
917 new_flag = 0 |
929 if has_copies_info: |
918 if has_copies_info: |
930 new_flag = sidedataflag.REVIDX_HASCOPIESINFO |
919 new_flag = sidedataflag.REVIDX_HASCOPIESINFO |
931 return False, (), sidedata, new_flag, 0 |
920 return sidedata, (new_flag, 0) |
932 |
921 |
933 return sidedata_companion |
922 return sidedata_companion |
934 |
|
935 |
|
936 def _get_simple_sidedata_adder(srcrepo, destrepo): |
|
937 """The simple version of the sidedata computation |
|
938 |
|
939 It just compute it in the same thread on request""" |
|
940 |
|
941 def sidedatacompanion(revlog, rev): |
|
942 sidedata, has_copies_info = {}, False |
|
943 if util.safehasattr(revlog, 'filteredrevs'): # this is a changelog |
|
944 sidedata, has_copies_info = _getsidedata(srcrepo, rev) |
|
945 new_flag = 0 |
|
946 if has_copies_info: |
|
947 new_flag = sidedataflag.REVIDX_HASCOPIESINFO |
|
948 |
|
949 return False, (), sidedata, new_flag, 0 |
|
950 |
|
951 return sidedatacompanion |
|
952 |
|
953 |
|
954 def getsidedataremover(srcrepo, destrepo): |
|
955 def sidedatacompanion(revlog, rev): |
|
956 f = () |
|
957 if util.safehasattr(revlog, 'filteredrevs'): # this is a changelog |
|
958 if revlog.flags(rev) & sidedataflag.REVIDX_SIDEDATA: |
|
959 f = ( |
|
960 sidedatamod.SD_P1COPIES, |
|
961 sidedatamod.SD_P2COPIES, |
|
962 sidedatamod.SD_FILESADDED, |
|
963 sidedatamod.SD_FILESREMOVED, |
|
964 ) |
|
965 return False, f, {}, 0, sidedataflag.REVIDX_HASCOPIESINFO |
|
966 |
|
967 return sidedatacompanion |
|