Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/patch.py @ 3701:05c8704a3743
handle git patches that rename a file to more than one destination
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Mon, 20 Nov 2006 19:32:45 -0200 |
parents | 562a65635bcb |
children | 70c3ee224c08 |
comparison
equal
deleted
inserted
replaced
3700:4c158de5f245 | 3701:05c8704a3743 |
---|---|
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 |