Show More
@@ -0,0 +1,69 b'' | |||||
|
1 | #!/bin/sh | |||
|
2 | ||||
|
3 | # Test issue835: | |||
|
4 | # qpush fails immediately when patching a missing file, but | |||
|
5 | # remaining added files are still created empty which will | |||
|
6 | # trick a future qrefresh. | |||
|
7 | ||||
|
8 | cat > writelines.py <<EOF | |||
|
9 | import sys | |||
|
10 | path = sys.argv[1] | |||
|
11 | args = sys.argv[2:] | |||
|
12 | assert (len(args) % 2) == 0 | |||
|
13 | ||||
|
14 | f = file(path, 'wb') | |||
|
15 | for i in xrange(len(args)/2): | |||
|
16 | count, s = args[2*i:2*i+2] | |||
|
17 | count = int(count) | |||
|
18 | s = s.decode('string_escape') | |||
|
19 | f.write(s*count) | |||
|
20 | f.close() | |||
|
21 | ||||
|
22 | EOF | |||
|
23 | ||||
|
24 | echo "[extensions]" >> $HGRCPATH | |||
|
25 | echo "mq=" >> $HGRCPATH | |||
|
26 | ||||
|
27 | hg init normal | |||
|
28 | cd normal | |||
|
29 | python ../writelines.py b 10 'a\n' | |||
|
30 | hg ci -Am addb | |||
|
31 | echo a > a | |||
|
32 | python ../writelines.py b 2 'b\n' 10 'a\n' 2 'c\n' | |||
|
33 | echo c > c | |||
|
34 | hg add a c | |||
|
35 | hg qnew -f changeb | |||
|
36 | hg qpop | |||
|
37 | hg rm b | |||
|
38 | hg ci -Am rmb | |||
|
39 | echo % push patch with missing target | |||
|
40 | hg qpush | |||
|
41 | echo % display added files | |||
|
42 | cat a | |||
|
43 | cat c | |||
|
44 | cd .. | |||
|
45 | ||||
|
46 | ||||
|
47 | echo "[diff]" >> $HGRCPATH | |||
|
48 | echo "git=1" >> $HGRCPATH | |||
|
49 | ||||
|
50 | hg init git | |||
|
51 | cd git | |||
|
52 | python ../writelines.py b 1 '\x00' | |||
|
53 | hg ci -Am addb | |||
|
54 | echo a > a | |||
|
55 | python ../writelines.py b 1 '\x01' 1 '\x00' | |||
|
56 | echo c > c | |||
|
57 | hg add a c | |||
|
58 | hg qnew -f changeb | |||
|
59 | hg qpop | |||
|
60 | hg rm b | |||
|
61 | hg ci -Am rmb | |||
|
62 | echo % push git patch with missing target | |||
|
63 | hg qpush 2>&1 | sed -e 's/b:.*/b: No such file or directory/' | |||
|
64 | hg st | |||
|
65 | echo % display added files | |||
|
66 | cat a | |||
|
67 | cat c | |||
|
68 | cd .. | |||
|
69 |
@@ -0,0 +1,25 b'' | |||||
|
1 | adding b | |||
|
2 | Patch queue now empty | |||
|
3 | % push patch with missing target | |||
|
4 | applying changeb | |||
|
5 | unable to find b or b for patching | |||
|
6 | unable to find b or b for patching | |||
|
7 | patch failed, unable to continue (try -v) | |||
|
8 | patch failed, rejects left in working dir | |||
|
9 | Errors during apply, please fix and refresh changeb | |||
|
10 | % display added files | |||
|
11 | a | |||
|
12 | c | |||
|
13 | adding b | |||
|
14 | Patch queue now empty | |||
|
15 | % push git patch with missing target | |||
|
16 | applying changeb | |||
|
17 | unable to find b or b for patching | |||
|
18 | patch failed, unable to continue (try -v) | |||
|
19 | b: No such file or directory | |||
|
20 | b not tracked! | |||
|
21 | patch failed, rejects left in working dir | |||
|
22 | Errors during apply, please fix and refresh changeb | |||
|
23 | % display added files | |||
|
24 | a | |||
|
25 | c |
@@ -885,6 +885,19 b' def applydiff(ui, fp, changed, strip=1, ' | |||||
885 | dopatch = True |
|
885 | dopatch = True | |
886 | gitworkdone = False |
|
886 | gitworkdone = False | |
887 |
|
887 | |||
|
888 | def getpatchfile(afile, bfile, hunk): | |||
|
889 | try: | |||
|
890 | if sourcefile: | |||
|
891 | targetfile = patchfile(ui, sourcefile) | |||
|
892 | else: | |||
|
893 | targetfile = selectfile(afile, bfile, hunk, | |||
|
894 | strip, reverse) | |||
|
895 | targetfile = patchfile(ui, targetfile) | |||
|
896 | return targetfile | |||
|
897 | except PatchError, err: | |||
|
898 | ui.warn(str(err) + '\n') | |||
|
899 | return None | |||
|
900 | ||||
888 | while True: |
|
901 | while True: | |
889 | newfile = False |
|
902 | newfile = False | |
890 | x = lr.readline() |
|
903 | x = lr.readline() | |
@@ -912,22 +925,20 b' def applydiff(ui, fp, changed, strip=1, ' | |||||
912 | continue |
|
925 | continue | |
913 | hunknum += 1 |
|
926 | hunknum += 1 | |
914 | if not current_file: |
|
927 | if not current_file: | |
915 | if sourcefile: |
|
928 | current_file = getpatchfile(afile, bfile, current_hunk) | |
916 |
|
|
929 | if not current_file: | |
917 | else: |
|
930 | current_file, current_hunk = None, None | |
918 | current_file = selectfile(afile, bfile, current_hunk, |
|
931 | rejects += 1 | |
919 | strip, reverse) |
|
932 | continue | |
920 | current_file = patchfile(ui, current_file) |
|
|||
921 | elif state == BFILE and x.startswith('GIT binary patch'): |
|
933 | elif state == BFILE and x.startswith('GIT binary patch'): | |
922 | current_hunk = binhunk(changed[bfile[2:]][1]) |
|
934 | current_hunk = binhunk(changed[bfile[2:]][1]) | |
|
935 | hunknum += 1 | |||
923 | if not current_file: |
|
936 | if not current_file: | |
924 | if sourcefile: |
|
937 | current_file = getpatchfile(afile, bfile, current_hunk) | |
925 |
|
|
938 | if not current_file: | |
926 | else: |
|
939 | current_file, current_hunk = None, None | |
927 | current_file = selectfile(afile, bfile, current_hunk, |
|
940 | rejects += 1 | |
928 | strip, reverse) |
|
941 | continue | |
929 | current_file = patchfile(ui, current_file) |
|
|||
930 | hunknum += 1 |
|
|||
931 | current_hunk.extract(fp) |
|
942 | current_hunk.extract(fp) | |
932 | elif x.startswith('diff --git'): |
|
943 | elif x.startswith('diff --git'): | |
933 | # check for git diff, scanning the whole patch file if needed |
|
944 | # check for git diff, scanning the whole patch file if needed |
General Comments 0
You need to be logged in to leave comments.
Login now