copy: propagate errors properly
authorMatt Mackall <mpm@selenic.com>
Thu, 06 Dec 2007 15:15:47 -0600
changeset 5606 447ea621e50e
parent 5605 e7a9ad999308
child 5607 e9bae5c80ab4
copy: propagate errors properly
mercurial/cmdutil.py
--- 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'))