equal
deleted
inserted
replaced
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 |