comparison mercurial/patch.py @ 11019:4fe28bdc27be

patch: make "unable to strip away" message less confusing
author Mads Kiilerich <mads@kiilerich.com>
date Mon, 26 Apr 2010 13:21:02 +0200
parents 17cf756ba25d
children dd157720a8ee
comparison
equal deleted inserted replaced
11018:17cf756ba25d 11019:4fe28bdc27be
908 if i < 0: 908 if i < 0:
909 return s 909 return s
910 return s[:i] 910 return s[:i]
911 911
912 def selectfile(afile_orig, bfile_orig, hunk, strip): 912 def selectfile(afile_orig, bfile_orig, hunk, strip):
913 def pathstrip(path, count=1): 913 def pathstrip(path, strip):
914 pathlen = len(path) 914 pathlen = len(path)
915 i = 0 915 i = 0
916 if count == 0: 916 if strip == 0:
917 return '', path.rstrip() 917 return '', path.rstrip()
918 count = strip
918 while count > 0: 919 while count > 0:
919 i = path.find('/', i) 920 i = path.find('/', i)
920 if i == -1: 921 if i == -1:
921 raise PatchError(_("unable to strip away %d dirs from %s") % 922 raise PatchError(_("unable to strip away %d of %d dirs from %s") %
922 (count, path)) 923 (count, strip, path))
923 i += 1 924 i += 1
924 # consume '//' in the path 925 # consume '//' in the path
925 while i < pathlen - 1 and path[i] == '/': 926 while i < pathlen - 1 and path[i] == '/':
926 i += 1 927 i += 1
927 count -= 1 928 count -= 1