Show More
@@ -0,0 +1,114 b'' | |||||
|
1 | $ echo "[extensions]" >> $HGRCPATH | |||
|
2 | $ echo "mq=" >> $HGRCPATH | |||
|
3 | ||||
|
4 | $ tipparents() { | |||
|
5 | > hg parents --template "{rev}:{node|short} {desc|firstline}\n" -r tip | |||
|
6 | > } | |||
|
7 | ||||
|
8 | Test import and merge diffs | |||
|
9 | ||||
|
10 | $ hg init repo | |||
|
11 | $ cd repo | |||
|
12 | $ echo a > a | |||
|
13 | $ hg ci -Am adda | |||
|
14 | adding a | |||
|
15 | $ echo a >> a | |||
|
16 | $ hg ci -m changea | |||
|
17 | $ echo c > c | |||
|
18 | $ hg ci -Am addc | |||
|
19 | adding c | |||
|
20 | $ hg up 0 | |||
|
21 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved | |||
|
22 | $ echo b > b | |||
|
23 | $ hg ci -Am addb | |||
|
24 | adding b | |||
|
25 | created new head | |||
|
26 | $ hg up 1 | |||
|
27 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved | |||
|
28 | $ hg merge 3 | |||
|
29 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
30 | (branch merge, don't forget to commit) | |||
|
31 | $ hg ci -m merge | |||
|
32 | $ hg export . > ../merge.diff | |||
|
33 | $ cd .. | |||
|
34 | $ hg clone -r2 repo repo2 | |||
|
35 | adding changesets | |||
|
36 | adding manifests | |||
|
37 | adding file changes | |||
|
38 | added 3 changesets with 3 changes to 2 files | |||
|
39 | updating to branch default | |||
|
40 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
41 | $ cd repo2 | |||
|
42 | $ hg pull -r3 ../repo | |||
|
43 | pulling from ../repo | |||
|
44 | searching for changes | |||
|
45 | adding changesets | |||
|
46 | adding manifests | |||
|
47 | adding file changes | |||
|
48 | added 1 changesets with 1 changes to 1 files (+1 heads) | |||
|
49 | (run 'hg heads' to see heads, 'hg merge' to merge) | |||
|
50 | ||||
|
51 | Test without --exact and diff.p1 == workingdir.p1 | |||
|
52 | ||||
|
53 | $ hg up 1 | |||
|
54 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |||
|
55 | $ hg import ../merge.diff | |||
|
56 | applying ../merge.diff | |||
|
57 | $ tipparents | |||
|
58 | 1:540395c44225 changea | |||
|
59 | 3:102a90ea7b4a addb | |||
|
60 | $ hg strip --no-backup tip | |||
|
61 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |||
|
62 | ||||
|
63 | Test without --exact and diff.p1 != workingdir.p1 | |||
|
64 | ||||
|
65 | $ hg up 2 | |||
|
66 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
67 | $ hg import ../merge.diff | |||
|
68 | applying ../merge.diff | |||
|
69 | $ tipparents | |||
|
70 | 2:890ecaa90481 addc | |||
|
71 | $ hg strip --no-backup tip | |||
|
72 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |||
|
73 | ||||
|
74 | Test with --exact | |||
|
75 | ||||
|
76 | $ hg import --exact ../merge.diff | |||
|
77 | applying ../merge.diff | |||
|
78 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |||
|
79 | $ tipparents | |||
|
80 | 1:540395c44225 changea | |||
|
81 | 3:102a90ea7b4a addb | |||
|
82 | $ hg strip --no-backup tip | |||
|
83 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |||
|
84 | ||||
|
85 | Test with --bypass and diff.p1 == workingdir.p1 | |||
|
86 | ||||
|
87 | $ hg up 1 | |||
|
88 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
89 | $ hg import --bypass ../merge.diff | |||
|
90 | applying ../merge.diff | |||
|
91 | $ tipparents | |||
|
92 | 1:540395c44225 changea | |||
|
93 | 3:102a90ea7b4a addb | |||
|
94 | $ hg strip --no-backup tip | |||
|
95 | ||||
|
96 | Test with --bypass and diff.p1 != workingdir.p1 | |||
|
97 | ||||
|
98 | $ hg up 2 | |||
|
99 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
100 | $ hg import --bypass ../merge.diff | |||
|
101 | applying ../merge.diff | |||
|
102 | $ tipparents | |||
|
103 | 2:890ecaa90481 addc | |||
|
104 | $ hg strip --no-backup tip | |||
|
105 | ||||
|
106 | Test with --bypass and --exact | |||
|
107 | ||||
|
108 | $ hg import --bypass --exact ../merge.diff | |||
|
109 | applying ../merge.diff | |||
|
110 | $ tipparents | |||
|
111 | 1:540395c44225 changea | |||
|
112 | 3:102a90ea7b4a addb | |||
|
113 | $ hg strip --no-backup tip | |||
|
114 |
@@ -3510,6 +3510,12 b' def import_(ui, repo, patch1=None, *patc' | |||||
3510 | try: |
|
3510 | try: | |
3511 | p1 = repo[p1] |
|
3511 | p1 = repo[p1] | |
3512 | p2 = repo[p2] |
|
3512 | p2 = repo[p2] | |
|
3513 | # Without any options, consider p2 only if the | |||
|
3514 | # patch is being applied on top of the recorded | |||
|
3515 | # first parent. | |||
|
3516 | if p1 != parents[0]: | |||
|
3517 | p1 = parents[0] | |||
|
3518 | p2 = repo[nullid] | |||
3513 | except error.RepoError: |
|
3519 | except error.RepoError: | |
3514 | p1, p2 = parents |
|
3520 | p1, p2 = parents | |
3515 | else: |
|
3521 | else: | |
@@ -3517,9 +3523,9 b' def import_(ui, repo, patch1=None, *patc' | |||||
3517 |
|
3523 | |||
3518 | n = None |
|
3524 | n = None | |
3519 | if update: |
|
3525 | if update: | |
3520 |
if |
|
3526 | if p1 != parents[0]: | |
3521 | hg.clean(repo, p1.node()) |
|
3527 | hg.clean(repo, p1.node()) | |
3522 |
if |
|
3528 | if p2 != parents[1]: | |
3523 | repo.dirstate.setparents(p1.node(), p2.node()) |
|
3529 | repo.dirstate.setparents(p1.node(), p2.node()) | |
3524 |
|
3530 | |||
3525 | if opts.get('exact') or opts.get('import_branch'): |
|
3531 | if opts.get('exact') or opts.get('import_branch'): | |
@@ -3533,7 +3539,10 b' def import_(ui, repo, patch1=None, *patc' | |||||
3533 | if message: |
|
3539 | if message: | |
3534 | msgs.append(message) |
|
3540 | msgs.append(message) | |
3535 | else: |
|
3541 | else: | |
3536 | if opts.get('exact'): |
|
3542 | if opts.get('exact') or p2: | |
|
3543 | # If you got here, you either use --force and know what | |||
|
3544 | # you are doing or used --exact or a merge patch while | |||
|
3545 | # being updated to its first parent. | |||
3537 | m = None |
|
3546 | m = None | |
3538 | else: |
|
3547 | else: | |
3539 | m = scmutil.matchfiles(repo, files or []) |
|
3548 | m = scmutil.matchfiles(repo, files or []) |
General Comments 0
You need to be logged in to leave comments.
Login now