Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/cmdutil.py @ 5606:447ea621e50e
copy: propagate errors properly
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 06 Dec 2007 15:15:47 -0600 |
parents | e7a9ad999308 |
children | e9bae5c80ab4 |
comparison
equal
deleted
inserted
replaced
5605:e7a9ad999308 | 5606:447ea621e50e |
---|---|
290 # called with the repo lock held | 290 # called with the repo lock held |
291 # | 291 # |
292 # hgsep => pathname that uses "/" to separate directories | 292 # hgsep => pathname that uses "/" to separate directories |
293 # ossep => pathname that uses os.sep to separate directories | 293 # ossep => pathname that uses os.sep to separate directories |
294 cwd = repo.getcwd() | 294 cwd = repo.getcwd() |
295 errors = 0 | |
296 copied = [] | 295 copied = [] |
297 targets = {} | 296 targets = {} |
298 | 297 |
299 def walkpat(pat): | 298 def walkpat(pat): |
300 srcs = [] | 299 srcs = [] |
356 if inst.errno == errno.ENOENT: | 355 if inst.errno == errno.ENOENT: |
357 ui.warn(_('%s: deleted in working copy\n') % relsrc) | 356 ui.warn(_('%s: deleted in working copy\n') % relsrc) |
358 else: | 357 else: |
359 ui.warn(_('%s: cannot copy - %s\n') % | 358 ui.warn(_('%s: cannot copy - %s\n') % |
360 (relsrc, inst.strerror)) | 359 (relsrc, inst.strerror)) |
361 errors += 1 | 360 return True # report a failure |
362 return | |
363 if ui.verbose or not exact: | 361 if ui.verbose or not exact: |
364 ui.status(_('copying %s to %s\n') % (relsrc, reltarget)) | 362 ui.status(_('copying %s to %s\n') % (relsrc, reltarget)) |
365 targets[abstarget] = abssrc | 363 targets[abstarget] = abssrc |
366 origsrc = repo.dirstate.copied(abssrc) or abssrc | 364 origsrc = repo.dirstate.copied(abssrc) or abssrc |
367 if abstarget == origsrc: # copying back a copy? | 365 if abstarget == origsrc: # copying back a copy? |
471 continue | 469 continue |
472 copylist.append((tfn(pat, dest, srcs), srcs)) | 470 copylist.append((tfn(pat, dest, srcs), srcs)) |
473 if not copylist: | 471 if not copylist: |
474 raise util.Abort(_('no files to copy')) | 472 raise util.Abort(_('no files to copy')) |
475 | 473 |
474 errors = 0 | |
476 for targetpath, srcs in copylist: | 475 for targetpath, srcs in copylist: |
477 for abssrc, relsrc, exact in srcs: | 476 for abssrc, relsrc, exact in srcs: |
478 copyfile(abssrc, relsrc, targetpath(abssrc), exact) | 477 if copyfile(abssrc, relsrc, targetpath(abssrc), exact): |
478 errors += 1 | |
479 | 479 |
480 if errors: | 480 if errors: |
481 ui.warn(_('(consider using --after)\n')) | 481 ui.warn(_('(consider using --after)\n')) |
482 return errors, copied | 482 return errors, copied |
483 | 483 |