339 def updatedir(ui, repo, patches, wlock=None): |
339 def updatedir(ui, repo, patches, wlock=None): |
340 '''Update dirstate after patch application according to metadata''' |
340 '''Update dirstate after patch application according to metadata''' |
341 if not patches: |
341 if not patches: |
342 return |
342 return |
343 copies = [] |
343 copies = [] |
344 removes = [] |
344 removes = {} |
345 cfiles = patches.keys() |
345 cfiles = patches.keys() |
346 cwd = repo.getcwd() |
346 cwd = repo.getcwd() |
347 if cwd: |
347 if cwd: |
348 cfiles = [util.pathto(cwd, f) for f in patches.keys()] |
348 cfiles = [util.pathto(cwd, f) for f in patches.keys()] |
349 for f in patches: |
349 for f in patches: |
350 ctype, gp = patches[f] |
350 ctype, gp = patches[f] |
351 if ctype == 'RENAME': |
351 if ctype == 'RENAME': |
352 copies.append((gp.oldpath, gp.path, gp.copymod)) |
352 copies.append((gp.oldpath, gp.path, gp.copymod)) |
353 removes.append(gp.oldpath) |
353 removes[gp.oldpath] = 1 |
354 elif ctype == 'COPY': |
354 elif ctype == 'COPY': |
355 copies.append((gp.oldpath, gp.path, gp.copymod)) |
355 copies.append((gp.oldpath, gp.path, gp.copymod)) |
356 elif ctype == 'DELETE': |
356 elif ctype == 'DELETE': |
357 removes.append(gp.path) |
357 removes[gp.path] = 1 |
358 for src, dst, after in copies: |
358 for src, dst, after in copies: |
359 if not after: |
359 if not after: |
360 copyfile(src, dst, repo.root) |
360 copyfile(src, dst, repo.root) |
361 repo.copy(src, dst, wlock=wlock) |
361 repo.copy(src, dst, wlock=wlock) |
|
362 removes = removes.keys() |
362 if removes: |
363 if removes: |
|
364 removes.sort() |
363 repo.remove(removes, True, wlock=wlock) |
365 repo.remove(removes, True, wlock=wlock) |
364 for f in patches: |
366 for f in patches: |
365 ctype, gp = patches[f] |
367 ctype, gp = patches[f] |
366 if gp and gp.mode: |
368 if gp and gp.mode: |
367 x = gp.mode & 0100 != 0 |
369 x = gp.mode & 0100 != 0 |