changeset 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
files mercurial/cmdutil.py
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Thu Dec 06 14:58:57 2007 -0600
+++ b/mercurial/cmdutil.py	Thu Dec 06 15:15:47 2007 -0600
@@ -292,7 +292,6 @@
     # hgsep => pathname that uses "/" to separate directories
     # ossep => pathname that uses os.sep to separate directories
     cwd = repo.getcwd()
-    errors = 0
     copied = []
     targets = {}
 
@@ -358,8 +357,7 @@
                 else:
                     ui.warn(_('%s: cannot copy - %s\n') %
                             (relsrc, inst.strerror))
-                    errors += 1
-                    return
+                    return True # report a failure
         if ui.verbose or not exact:
             ui.status(_('copying %s to %s\n') % (relsrc, reltarget))
         targets[abstarget] = abssrc
@@ -473,9 +471,11 @@
     if not copylist:
         raise util.Abort(_('no files to copy'))
 
+    errors = 0
     for targetpath, srcs in copylist:
         for abssrc, relsrc, exact in srcs:
-            copyfile(abssrc, relsrc, targetpath(abssrc), exact)
+            if copyfile(abssrc, relsrc, targetpath(abssrc), exact):
+                errors += 1
 
     if errors:
         ui.warn(_('(consider using --after)\n'))