comparison mercurial/changelog.py @ 42553:e3df1e15bee9

changelog: fix handling of empty copy entries in changeset Before this patch, when an empty value was found in the changeset, we would get a ValueError, which would result in None being returned for addedfiles/removedfiles and p1copies/p2copies. That made 278dcb24e535 (copies: write empty entries in changeset when also writing to filelog, 2019-04-23) ineffective at helping the read path not look for copies in the filelogs. Differential Revision: https://phab.mercurial-scm.org/D6595
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 01 Jul 2019 16:25:51 -0700
parents 055c3e2c44f0
children 57ea0a81a65c
comparison
equal deleted inserted replaced
42552:4cafbd3b50c6 42553:e3df1e15bee9
90 return "\n".join(items) 90 return "\n".join(items)
91 91
92 def decodecopies(files, data): 92 def decodecopies(files, data):
93 try: 93 try:
94 copies = {} 94 copies = {}
95 if not data:
96 return copies
95 for l in data.split('\n'): 97 for l in data.split('\n'):
96 strindex, src = l.split('\0') 98 strindex, src = l.split('\0')
97 i = int(strindex) 99 i = int(strindex)
98 dst = files[i] 100 dst = files[i]
99 copies[dst] = src 101 copies[dst] = src
112 return '\n'.join(indices) 114 return '\n'.join(indices)
113 115
114 def decodefileindices(files, data): 116 def decodefileindices(files, data):
115 try: 117 try:
116 subset = [] 118 subset = []
119 if not data:
120 return subset
117 for strindex in data.split('\n'): 121 for strindex in data.split('\n'):
118 i = int(strindex) 122 i = int(strindex)
119 if i < 0 or i >= len(files): 123 if i < 0 or i >= len(files):
120 return None 124 return None
121 subset.append(files[i]) 125 subset.append(files[i])