853 continue |
854 continue |
854 if dst in wctx: |
855 if dst in wctx: |
855 wctx[dst].markcopied(src) |
856 wctx[dst].markcopied(src) |
856 |
857 |
857 |
858 |
|
859 def computechangesetfilesadded(ctx): |
|
860 """return the list of files added in a changeset |
|
861 """ |
|
862 added = [] |
|
863 for f in ctx.files(): |
|
864 if not any(f in p for p in ctx.parents()): |
|
865 added.append(f) |
|
866 return added |
|
867 |
|
868 |
|
869 def computechangesetfilesremoved(ctx): |
|
870 """return the list of files removed in a changeset |
|
871 """ |
|
872 removed = [] |
|
873 for f in ctx.files(): |
|
874 if f not in ctx: |
|
875 removed.append(f) |
|
876 return removed |
|
877 |
|
878 |
858 def computechangesetcopies(ctx): |
879 def computechangesetcopies(ctx): |
859 """return the copies data for a changeset |
880 """return the copies data for a changeset |
860 |
881 |
861 The copies data are returned as a pair of dictionnary (p1copies, p2copies). |
882 The copies data are returned as a pair of dictionnary (p1copies, p2copies). |
862 |
883 |
877 if src in p1 and p1[src].filenode() == srcnode: |
898 if src in p1 and p1[src].filenode() == srcnode: |
878 p1copies[dst] = src |
899 p1copies[dst] = src |
879 elif src in p2 and p2[src].filenode() == srcnode: |
900 elif src in p2 and p2[src].filenode() == srcnode: |
880 p2copies[dst] = src |
901 p2copies[dst] = src |
881 return p1copies, p2copies |
902 return p1copies, p2copies |
|
903 |
|
904 |
|
905 def encodecopies(files, copies): |
|
906 items = [] |
|
907 for i, dst in enumerate(files): |
|
908 if dst in copies: |
|
909 items.append(b'%d\0%s' % (i, copies[dst])) |
|
910 if len(items) != len(copies): |
|
911 raise error.ProgrammingError( |
|
912 b'some copy targets missing from file list' |
|
913 ) |
|
914 return b"\n".join(items) |
|
915 |
|
916 |
|
917 def decodecopies(files, data): |
|
918 try: |
|
919 copies = {} |
|
920 if not data: |
|
921 return copies |
|
922 for l in data.split(b'\n'): |
|
923 strindex, src = l.split(b'\0') |
|
924 i = int(strindex) |
|
925 dst = files[i] |
|
926 copies[dst] = src |
|
927 return copies |
|
928 except (ValueError, IndexError): |
|
929 # Perhaps someone had chosen the same key name (e.g. "p1copies") and |
|
930 # used different syntax for the value. |
|
931 return None |
|
932 |
|
933 |
|
934 def encodefileindices(files, subset): |
|
935 subset = set(subset) |
|
936 indices = [] |
|
937 for i, f in enumerate(files): |
|
938 if f in subset: |
|
939 indices.append(b'%d' % i) |
|
940 return b'\n'.join(indices) |
|
941 |
|
942 |
|
943 def decodefileindices(files, data): |
|
944 try: |
|
945 subset = [] |
|
946 if not data: |
|
947 return subset |
|
948 for strindex in data.split(b'\n'): |
|
949 i = int(strindex) |
|
950 if i < 0 or i >= len(files): |
|
951 return None |
|
952 subset.append(files[i]) |
|
953 return subset |
|
954 except (ValueError, IndexError): |
|
955 # Perhaps someone had chosen the same key name (e.g. "added") and |
|
956 # used different syntax for the value. |
|
957 return None |