##// END OF EJS Templates
largefiles: remove pasted code...
Levi Bard -
r15811:b9886dde default
parent child Browse files
Show More
@@ -117,22 +117,10 b' def lfconvert(ui, src, dest, *pats, **op'
117 117
118 118 def _addchangeset(ui, rsrc, rdst, ctx, revmap):
119 119 # Convert src parents to dst parents
120 parents = []
121 for p in ctx.parents():
122 parents.append(revmap[p.node()])
123 while len(parents) < 2:
124 parents.append(node.nullid)
120 parents = _convertparents(ctx, revmap)
125 121
126 122 # Generate list of changed files
127 files = set(ctx.files())
128 if node.nullid not in parents:
129 mc = ctx.manifest()
130 mp1 = ctx.parents()[0].manifest()
131 mp2 = ctx.parents()[1].manifest()
132 files |= (set(mp1) | set(mp2)) - set(mc)
133 for f in mc:
134 if mc[f] != mp1.get(f, None) or mc[f] != mp2.get(f, None):
135 files.add(f)
123 files = _getchangedfiles(ctx, parents)
136 124
137 125 def getfilectx(repo, memctx, f):
138 126 if lfutil.standin(f) in files:
@@ -160,23 +148,7 b' def _addchangeset(ui, rsrc, rdst, ctx, r'
160 148 return context.memfilectx(f, data, 'l' in fctx.flags(),
161 149 'x' in fctx.flags(), renamed)
162 150 else:
163 try:
164 fctx = ctx.filectx(f)
165 except error.LookupError:
166 raise IOError()
167 renamed = fctx.renamed()
168 if renamed:
169 renamed = renamed[0]
170 data = fctx.data()
171 if f == '.hgtags':
172 newdata = []
173 for line in data.splitlines():
174 id, name = line.split(' ', 1)
175 newdata.append('%s %s\n' % (node.hex(revmap[node.bin(id)]),
176 name))
177 data = ''.join(newdata)
178 return context.memfilectx(f, data, 'l' in fctx.flags(),
179 'x' in fctx.flags(), renamed)
151 return _getnormalcontext(repo.ui, ctx, f, revmap)
180 152
181 153 dstfiles = []
182 154 for file in files:
@@ -185,31 +157,15 b' def _addchangeset(ui, rsrc, rdst, ctx, r'
185 157 else:
186 158 dstfiles.append(file)
187 159 # Commit
188 mctx = context.memctx(rdst, parents, ctx.description(), dstfiles,
189 getfilectx, ctx.user(), ctx.date(), ctx.extra())
190 ret = rdst.commitctx(mctx)
191 rdst.dirstate.setparents(ret)
192 revmap[ctx.node()] = rdst.changelog.tip()
160 _commitcontext(rdst, parents, ctx, dstfiles, getfilectx, revmap)
193 161
194 162 def _lfconvert_addchangeset(rsrc, rdst, ctx, revmap, lfiles, normalfiles,
195 163 matcher, size, lfiletohash):
196 164 # Convert src parents to dst parents
197 parents = []
198 for p in ctx.parents():
199 parents.append(revmap[p.node()])
200 while len(parents) < 2:
201 parents.append(node.nullid)
165 parents = _convertparents(ctx, revmap)
202 166
203 167 # Generate list of changed files
204 files = set(ctx.files())
205 if node.nullid not in parents:
206 mc = ctx.manifest()
207 mp1 = ctx.parents()[0].manifest()
208 mp2 = ctx.parents()[1].manifest()
209 files |= (set(mp1) | set(mp2)) - set(mc)
210 for f in mc:
211 if mc[f] != mp1.get(f, None) or mc[f] != mp2.get(f, None):
212 files.add(f)
168 files = _getchangedfiles(ctx, parents)
213 169
214 170 dstfiles = []
215 171 for f in files:
@@ -283,47 +239,80 b' def _lfconvert_addchangeset(rsrc, rdst, '
283 239 return context.memfilectx(f, lfiletohash[srcfname] + '\n', 'l' in
284 240 fctx.flags(), 'x' in fctx.flags(), renamed)
285 241 else:
286 try:
287 fctx = ctx.filectx(f)
288 except error.LookupError:
289 raise IOError()
290 renamed = fctx.renamed()
291 if renamed:
292 renamed = renamed[0]
293
294 data = fctx.data()
295 if f == '.hgtags':
296 newdata = []
297 for line in data.splitlines():
298 try:
299 id, name = line.split(' ', 1)
300 except ValueError:
301 repo.ui.warn(_('skipping incorrectly formatted tag %s\n'
302 % line))
303 continue
304 try:
305 newid = node.bin(id)
306 except TypeError:
307 repo.ui.warn(_('skipping incorrectly formatted id %s\n'
308 % id))
309 continue
310 try:
311 newdata.append('%s %s\n' % (node.hex(revmap[newid]),
312 name))
313 except KeyError:
314 repo.ui.warn(_('no mapping for id %s\n' % id))
315 continue
316 data = ''.join(newdata)
317 return context.memfilectx(f, data, 'l' in fctx.flags(),
318 'x' in fctx.flags(), renamed)
242 return _getnormalcontext(repo.ui, ctx, f, revmap)
319 243
320 244 # Commit
245 _commitcontext(rdst, parents, ctx, dstfiles, getfilectx, revmap)
246
247 def _commitcontext(rdst, parents, ctx, dstfiles, getfilectx, revmap):
321 248 mctx = context.memctx(rdst, parents, ctx.description(), dstfiles,
322 249 getfilectx, ctx.user(), ctx.date(), ctx.extra())
323 250 ret = rdst.commitctx(mctx)
324 251 rdst.dirstate.setparents(ret)
325 252 revmap[ctx.node()] = rdst.changelog.tip()
326 253
254 # Generate list of changed files
255 def _getchangedfiles(ctx, parents):
256 files = set(ctx.files())
257 if node.nullid not in parents:
258 mc = ctx.manifest()
259 mp1 = ctx.parents()[0].manifest()
260 mp2 = ctx.parents()[1].manifest()
261 files |= (set(mp1) | set(mp2)) - set(mc)
262 for f in mc:
263 if mc[f] != mp1.get(f, None) or mc[f] != mp2.get(f, None):
264 files.add(f)
265 return files
266
267 # Convert src parents to dst parents
268 def _convertparents(ctx, revmap):
269 parents = []
270 for p in ctx.parents():
271 parents.append(revmap[p.node()])
272 while len(parents) < 2:
273 parents.append(node.nullid)
274 return parents
275
276 # Get memfilectx for a normal file
277 def _getnormalcontext(ui, ctx, f, revmap):
278 try:
279 fctx = ctx.filectx(f)
280 except error.LookupError:
281 raise IOError()
282 renamed = fctx.renamed()
283 if renamed:
284 renamed = renamed[0]
285
286 data = fctx.data()
287 if f == '.hgtags':
288 data = _converttags (ui, revmap, data)
289 return context.memfilectx(f, data, 'l' in fctx.flags(),
290 'x' in fctx.flags(), renamed)
291
292 # Remap tag data using a revision map
293 def _converttags(ui, revmap, data):
294 newdata = []
295 for line in data.splitlines():
296 try:
297 id, name = line.split(' ', 1)
298 except ValueError:
299 ui.warn(_('skipping incorrectly formatted tag %s\n'
300 % line))
301 continue
302 try:
303 newid = node.bin(id)
304 except TypeError:
305 ui.warn(_('skipping incorrectly formatted id %s\n'
306 % id))
307 continue
308 try:
309 newdata.append('%s %s\n' % (node.hex(revmap[newid]),
310 name))
311 except KeyError:
312 ui.warn(_('no mapping for id %s\n' % id))
313 continue
314 return ''.join(newdata)
315
327 316 def _islfile(file, ctx, matcher, size):
328 317 '''Return true if file should be considered a largefile, i.e.
329 318 matcher matches it or it is larger than size.'''
General Comments 0
You need to be logged in to leave comments. Login now