##// END OF EJS Templates
patch: fix corner case with update + copy patch handling (issue 937)...
Patrick Mezard -
r6295:bace1990 default
parent child Browse files
Show More
@@ -800,13 +800,13 b' def selectfile(afile_orig, bfile_orig, h'
800 800 while i < pathlen - 1 and path[i] == '/':
801 801 i += 1
802 802 count -= 1
803 return path[i:].rstrip()
803 return path[:i].lstrip(), path[i:].rstrip()
804 804
805 805 nulla = afile_orig == "/dev/null"
806 806 nullb = bfile_orig == "/dev/null"
807 afile = pathstrip(afile_orig, strip)
807 abase, afile = pathstrip(afile_orig, strip)
808 808 gooda = not nulla and os.path.exists(afile)
809 bfile = pathstrip(bfile_orig, strip)
809 bbase, bfile = pathstrip(bfile_orig, strip)
810 810 if afile == bfile:
811 811 goodb = gooda
812 812 else:
@@ -815,16 +815,20 b' def selectfile(afile_orig, bfile_orig, h'
815 815 if reverse:
816 816 createfunc = hunk.rmfile
817 817 missing = not goodb and not gooda and not createfunc()
818 # If afile is "a/b/foo" and bfile is "a/b/foo.orig" we assume the
819 # diff is between a file and its backup. In this case, the original
820 # file should be patched (see original mpatch code).
821 isbackup = (abase == bbase and bfile.startswith(afile))
818 822 fname = None
819 823 if not missing:
820 824 if gooda and goodb:
821 fname = (afile in bfile) and afile or bfile
825 fname = isbackup and afile or bfile
822 826 elif gooda:
823 827 fname = afile
824 828
825 829 if not fname:
826 830 if not nullb:
827 fname = (afile in bfile) and afile or bfile
831 fname = isbackup and afile or bfile
828 832 elif not nulla:
829 833 fname = afile
830 834 else:
@@ -225,3 +225,22 b' hg import remove.diff'
225 225 hg manifest
226 226 cd ..
227 227
228 echo % 'test update+rename with common name (issue 927)'
229 hg init t
230 cd t
231 touch a
232 hg ci -Am t
233 echo a > a
234 # Here, bfile.startswith(afile)
235 hg copy a a2
236 hg ci -m copya
237 hg export --git tip > copy.diff
238 hg up -C 0
239 hg import copy.diff
240 echo % view a
241 # a should contain an 'a'
242 cat a
243 echo % view a2
244 # and a2 should have duplicated it
245 cat a2
246 cd ..
@@ -232,3 +232,11 b' diff --git a/a b/a'
232 232 diff --git a/b b/b
233 233 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
234 234 applying remove.diff
235 % test update+rename with common name (issue 927)
236 adding a
237 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
238 applying copy.diff
239 % view a
240 a
241 % view a2
242 a
General Comments 0
You need to be logged in to leave comments. Login now