patch: make "unable to strip away" message less confusing
authorMads Kiilerich <mads@kiilerich.com>
Mon, 26 Apr 2010 13:21:02 +0200
changeset 11019 4fe28bdc27be
parent 11018 17cf756ba25d
child 11020 dd157720a8ee
patch: make "unable to strip away" message less confusing
mercurial/patch.py
--- a/mercurial/patch.py	Mon Apr 26 13:21:02 2010 +0200
+++ b/mercurial/patch.py	Mon Apr 26 13:21:02 2010 +0200
@@ -910,16 +910,17 @@
     return s[:i]
 
 def selectfile(afile_orig, bfile_orig, hunk, strip):
-    def pathstrip(path, count=1):
+    def pathstrip(path, strip):
         pathlen = len(path)
         i = 0
-        if count == 0:
+        if strip == 0:
             return '', path.rstrip()
+        count = strip
         while count > 0:
             i = path.find('/', i)
             if i == -1:
-                raise PatchError(_("unable to strip away %d dirs from %s") %
-                                 (count, path))
+                raise PatchError(_("unable to strip away %d of %d dirs from %s") %
+                                 (count, strip, path))
             i += 1
             # consume '//' in the path
             while i < pathlen - 1 and path[i] == '/':