Show More
@@ -296,29 +296,26 def copy(ui, repo, pats, opts): | |||||
296 | copied = [] |
|
296 | copied = [] | |
297 | targets = {} |
|
297 | targets = {} | |
298 |
|
298 | |||
|
299 | def walkpat(pat): | |||
|
300 | srcs = [] | |||
|
301 | for tag, abs, rel, exact in walk(repo, [pat], opts, globbed=True): | |||
|
302 | state = repo.dirstate[abs] | |||
|
303 | if state in '?r': | |||
|
304 | if exact and state == '?': | |||
|
305 | ui.warn(_('%s: not copying - file is not managed\n') % rel) | |||
|
306 | if exact and state == 'r': | |||
|
307 | ui.warn(_('%s: not copying - file has been marked for' | |||
|
308 | ' remove\n') % rel) | |||
|
309 | continue | |||
299 | # abs: hgsep |
|
310 | # abs: hgsep | |
300 | # rel: ossep |
|
311 | # rel: ossep | |
301 | # return: hgsep |
|
312 | srcs.append((abs, rel, exact)) | |
302 | def okaytocopy(abs, rel, exact): |
|
313 | return srcs | |
303 | reasons = {'?': _('is not managed'), |
|
|||
304 | 'r': _('has been marked for remove')} |
|
|||
305 | state = repo.dirstate[abs] |
|
|||
306 | reason = reasons.get(state) |
|
|||
307 | if reason: |
|
|||
308 | if exact: |
|
|||
309 | ui.warn(_('%s: not copying - file %s\n') % (rel, reason)) |
|
|||
310 | else: |
|
|||
311 | if state == 'a': |
|
|||
312 | origsrc = repo.dirstate.copied(abs) |
|
|||
313 | if origsrc is not None: |
|
|||
314 | return origsrc |
|
|||
315 | return abs |
|
|||
316 |
|
314 | |||
317 | # origsrc: hgsep |
|
|||
318 | # abssrc: hgsep |
|
315 | # abssrc: hgsep | |
319 | # relsrc: ossep |
|
316 | # relsrc: ossep | |
320 | # otarget: ossep |
|
317 | # otarget: ossep | |
321 |
def copy( |
|
318 | def copyfile(abssrc, relsrc, otarget, exact): | |
322 | abstarget = util.canonpath(repo.root, cwd, otarget) |
|
319 | abstarget = util.canonpath(repo.root, cwd, otarget) | |
323 | reltarget = repo.pathto(abstarget, cwd) |
|
320 | reltarget = repo.pathto(abstarget, cwd) | |
324 | prevsrc = targets.get(abstarget) |
|
321 | prevsrc = targets.get(abstarget) | |
@@ -366,6 +363,7 def copy(ui, repo, pats, opts): | |||||
366 | if ui.verbose or not exact: |
|
363 | if ui.verbose or not exact: | |
367 | ui.status(_('copying %s to %s\n') % (relsrc, reltarget)) |
|
364 | ui.status(_('copying %s to %s\n') % (relsrc, reltarget)) | |
368 | targets[abstarget] = abssrc |
|
365 | targets[abstarget] = abssrc | |
|
366 | origsrc = repo.dirstate.copied(abssrc) or abssrc | |||
369 | if abstarget == origsrc: # copying back a copy? |
|
367 | if abstarget == origsrc: # copying back a copy? | |
370 | if repo.dirstate[abstarget] not in 'mn': |
|
368 | if repo.dirstate[abstarget] not in 'mn': | |
371 | if not opts.get('dry_run'): |
|
369 | if not opts.get('dry_run'): | |
@@ -468,12 +466,7 def copy(ui, repo, pats, opts): | |||||
468 | tfn = targetpathfn |
|
466 | tfn = targetpathfn | |
469 | copylist = [] |
|
467 | copylist = [] | |
470 | for pat in pats: |
|
468 | for pat in pats: | |
471 |
srcs = |
|
469 | srcs = walkpat(pat) | |
472 | for tag, abssrc, relsrc, exact in walk(repo, [pat], opts, |
|
|||
473 | globbed=True): |
|
|||
474 | origsrc = okaytocopy(abssrc, relsrc, exact) |
|
|||
475 | if origsrc: |
|
|||
476 | srcs.append((origsrc, abssrc, relsrc, exact)) |
|
|||
477 | if not srcs: |
|
470 | if not srcs: | |
478 | continue |
|
471 | continue | |
479 | copylist.append((tfn(pat, dest, srcs), srcs)) |
|
472 | copylist.append((tfn(pat, dest, srcs), srcs)) | |
@@ -481,8 +474,8 def copy(ui, repo, pats, opts): | |||||
481 | raise util.Abort(_('no files to copy')) |
|
474 | raise util.Abort(_('no files to copy')) | |
482 |
|
475 | |||
483 | for targetpath, srcs in copylist: |
|
476 | for targetpath, srcs in copylist: | |
484 |
for |
|
477 | for abssrc, relsrc, exact in srcs: | |
485 |
copy( |
|
478 | copyfile(abssrc, relsrc, targetpath(abssrc), exact) | |
486 |
|
479 | |||
487 | if errors: |
|
480 | if errors: | |
488 | ui.warn(_('(consider using --after)\n')) |
|
481 | ui.warn(_('(consider using --after)\n')) |
General Comments 0
You need to be logged in to leave comments.
Login now