Show More
@@ -321,6 +321,7 b' def copy(ui, repo, pats, opts):' | |||||
321 | reltarget = repo.pathto(abstarget, cwd) |
|
321 | reltarget = repo.pathto(abstarget, cwd) | |
322 | target = repo.wjoin(abstarget) |
|
322 | target = repo.wjoin(abstarget) | |
323 | src = repo.wjoin(abssrc) |
|
323 | src = repo.wjoin(abssrc) | |
|
324 | state = repo.dirstate[abstarget] | |||
324 |
|
325 | |||
325 | # check for collisions |
|
326 | # check for collisions | |
326 | prevsrc = targets.get(abstarget) |
|
327 | prevsrc = targets.get(abstarget) | |
@@ -331,33 +332,24 b' def copy(ui, repo, pats, opts):' | |||||
331 | return |
|
332 | return | |
332 |
|
333 | |||
333 | # check for overwrites |
|
334 | # check for overwrites | |
334 |
|
|
335 | exists = os.path.exists(target) | |
335 |
|
|
336 | if (not after and exists or after and state in 'mn'): | |
336 | if not opts['force']: |
|
337 | if not opts['force']: | |
337 | ui.warn(_('%s: not overwriting - file exists\n') % |
|
338 | ui.warn(_('%s: not overwriting - file exists\n') % | |
338 | reltarget) |
|
339 | reltarget) | |
339 | return |
|
340 | return | |
340 | if not after and not dryrun: |
|
|||
341 | os.unlink(target) |
|
|||
342 |
|
341 | |||
343 | if after: |
|
342 | if after: | |
344 |
if not |
|
343 | if not exists: | |
345 | return |
|
344 | return | |
346 | else: |
|
345 | elif not dryrun: | |
347 | targetdir = os.path.dirname(target) or '.' |
|
|||
348 | if not os.path.isdir(targetdir) and not dryrun: |
|
|||
349 | os.makedirs(targetdir) |
|
|||
350 | try: |
|
346 | try: | |
351 | restore = repo.dirstate[abstarget] == 'r' |
|
347 | if exists: | |
352 | if restore and not dryrun: |
|
348 | os.unlink(target) | |
353 | repo.undelete([abstarget]) |
|
349 | targetdir = os.path.dirname(target) or '.' | |
354 | try: |
|
350 | if not os.path.isdir(targetdir): | |
355 |
|
|
351 | os.makedirs(targetdir) | |
356 |
|
|
352 | util.copyfile(src, target) | |
357 | restore = False |
|
|||
358 | finally: |
|
|||
359 | if restore: |
|
|||
360 | repo.remove([abstarget]) |
|
|||
361 | except IOError, inst: |
|
353 | except IOError, inst: | |
362 | if inst.errno == errno.ENOENT: |
|
354 | if inst.errno == errno.ENOENT: | |
363 | ui.warn(_('%s: deleted in working copy\n') % relsrc) |
|
355 | ui.warn(_('%s: deleted in working copy\n') % relsrc) | |
@@ -368,14 +360,14 b' def copy(ui, repo, pats, opts):' | |||||
368 |
|
360 | |||
369 | if ui.verbose or not exact: |
|
361 | if ui.verbose or not exact: | |
370 | ui.status(_('copying %s to %s\n') % (relsrc, reltarget)) |
|
362 | ui.status(_('copying %s to %s\n') % (relsrc, reltarget)) | |
|
363 | ||||
371 | targets[abstarget] = abssrc |
|
364 | targets[abstarget] = abssrc | |
372 |
|
365 | |||
373 | # fix up dirstate |
|
366 | # fix up dirstate | |
374 | origsrc = repo.dirstate.copied(abssrc) or abssrc |
|
367 | origsrc = repo.dirstate.copied(abssrc) or abssrc | |
375 | if abstarget == origsrc: # copying back a copy? |
|
368 | if abstarget == origsrc: # copying back a copy? | |
376 |
if |
|
369 | if state not in 'mn' and not dryrun: | |
377 | if not dryrun: |
|
370 | repo.dirstate.normallookup(abstarget) | |
378 | repo.add([abstarget]) |
|
|||
379 | else: |
|
371 | else: | |
380 | if repo.dirstate[origsrc] == 'a': |
|
372 | if repo.dirstate[origsrc] == 'a': | |
381 | if not ui.quiet: |
|
373 | if not ui.quiet: |
@@ -24,6 +24,7 b' hg ci -m a2' | |||||
24 | echo % merge repositories |
|
24 | echo % merge repositories | |
25 | hg pull ../t2 |
|
25 | hg pull ../t2 | |
26 | hg merge |
|
26 | hg merge | |
|
27 | hg st | |||
27 |
|
28 | |||
28 | echo % rename b as c |
|
29 | echo % rename b as c | |
29 | hg mv b c |
|
30 | hg mv b c |
@@ -14,7 +14,9 b' added 1 changesets with 1 changes to 1 f' | |||||
14 | (run 'hg heads' to see heads, 'hg merge' to merge) |
|
14 | (run 'hg heads' to see heads, 'hg merge' to merge) | |
15 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
15 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
16 | (branch merge, don't forget to commit) |
|
16 | (branch merge, don't forget to commit) | |
|
17 | M b | |||
17 | % rename b as c |
|
18 | % rename b as c | |
18 | A c |
|
19 | A c | |
19 | R b |
|
20 | R b | |
20 | % rename back c as b |
|
21 | % rename back c as b | |
|
22 | M b |
General Comments 0
You need to be logged in to leave comments.
Login now