| 1 |
$ hg init t |
| 2 |
$ cd t |
| 3 |
|
| 4 |
$ mkdir a |
| 5 |
$ echo foo > a/a |
| 6 |
$ echo bar > a/b |
| 7 |
$ hg ci -Am "0" |
| 8 |
adding a/a |
| 9 |
adding a/b |
| 10 |
|
| 11 |
$ hg co -C 0 |
| 12 |
0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 13 |
$ hg mv a b |
| 14 |
moving a/a to b/a |
| 15 |
moving a/b to b/b |
| 16 |
$ hg ci -m "1 mv a/ b/" |
| 17 |
|
| 18 |
$ hg co -C 0 |
| 19 |
2 files updated, 0 files merged, 2 files removed, 0 files unresolved |
| 20 |
$ echo baz > a/c |
| 21 |
$ echo quux > a/d |
| 22 |
$ hg add a/c |
| 23 |
$ hg ci -m "2 add a/c" |
| 24 |
created new head |
| 25 |
|
| 26 |
$ hg merge --debug 1 |
| 27 |
unmatched files in local: |
| 28 |
a/c |
| 29 |
unmatched files in other: |
| 30 |
b/a |
| 31 |
b/b |
| 32 |
all copies found (* = to merge, ! = divergent, % = renamed and deleted): |
| 33 |
on remote side: |
| 34 |
src: 'a/a' -> dst: 'b/a' |
| 35 |
src: 'a/b' -> dst: 'b/b' |
| 36 |
checking for directory renames |
| 37 |
discovered dir src: 'a/' -> dst: 'b/' |
| 38 |
pending file src: 'a/c' -> dst: 'b/c' |
| 39 |
resolving manifests |
| 40 |
branchmerge: True, force: False, partial: False |
| 41 |
ancestor: f9b20c0d4c51, local: ce36d17b18fb+, remote: 397f8b00a740 |
| 42 |
a/a: other deleted -> r |
| 43 |
removing a/a |
| 44 |
a/b: other deleted -> r |
| 45 |
removing a/b |
| 46 |
b/a: remote created -> g |
| 47 |
getting b/a |
| 48 |
b/b: remote created -> g |
| 49 |
getting b/b |
| 50 |
b/c: remote directory rename - move from a/c -> dm |
| 51 |
moving a/c to b/c |
| 52 |
3 files updated, 0 files merged, 2 files removed, 0 files unresolved |
| 53 |
(branch merge, don't forget to commit) |
| 54 |
|
| 55 |
$ echo a/* b/* |
| 56 |
a/d b/a b/b b/c |
| 57 |
$ hg st -C |
| 58 |
M b/a |
| 59 |
M b/b |
| 60 |
A b/c |
| 61 |
a/c |
| 62 |
R a/a |
| 63 |
R a/b |
| 64 |
R a/c |
| 65 |
? a/d |
| 66 |
$ hg ci -m "3 merge 2+1" |
| 67 |
$ hg debugrename b/c |
| 68 |
b/c renamed from a/c:354ae8da6e890359ef49ade27b68bbc361f3ca88 |
| 69 |
|
| 70 |
$ hg co -C 1 |
| 71 |
0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
| 72 |
$ hg merge --debug 2 |
| 73 |
unmatched files in local: |
| 74 |
b/a |
| 75 |
b/b |
| 76 |
unmatched files in other: |
| 77 |
a/c |
| 78 |
all copies found (* = to merge, ! = divergent, % = renamed and deleted): |
| 79 |
on local side: |
| 80 |
src: 'a/a' -> dst: 'b/a' |
| 81 |
src: 'a/b' -> dst: 'b/b' |
| 82 |
checking for directory renames |
| 83 |
discovered dir src: 'a/' -> dst: 'b/' |
| 84 |
pending file src: 'a/c' -> dst: 'b/c' |
| 85 |
resolving manifests |
| 86 |
branchmerge: True, force: False, partial: False |
| 87 |
ancestor: f9b20c0d4c51, local: 397f8b00a740+, remote: ce36d17b18fb |
| 88 |
starting 4 threads for background file closing (?) |
| 89 |
b/c: local directory rename - get from a/c -> dg |
| 90 |
getting a/c to b/c |
| 91 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 92 |
(branch merge, don't forget to commit) |
| 93 |
|
| 94 |
$ echo a/* b/* |
| 95 |
a/d b/a b/b b/c |
| 96 |
$ hg st -C |
| 97 |
A b/c |
| 98 |
a/c |
| 99 |
? a/d |
| 100 |
$ hg ci -m "4 merge 1+2" |
| 101 |
created new head |
| 102 |
$ hg debugrename b/c |
| 103 |
b/c renamed from a/c:354ae8da6e890359ef49ade27b68bbc361f3ca88 |
| 104 |
|
| 105 |
Local directory rename with conflicting file added in remote source directory |
| 106 |
and untracked in local target directory. |
| 107 |
|
| 108 |
$ hg co -qC 1 |
| 109 |
$ echo target > b/c |
| 110 |
$ hg merge 2 |
| 111 |
b/c: untracked file differs |
| 112 |
abort: untracked files in working directory differ from files in requested revision |
| 113 |
[20] |
| 114 |
$ cat b/c |
| 115 |
target |
| 116 |
but it should succeed if the content matches |
| 117 |
$ hg cat -r 2 a/c > b/c |
| 118 |
$ hg merge 2 |
| 119 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 120 |
(branch merge, don't forget to commit) |
| 121 |
$ hg st -C |
| 122 |
A b/c |
| 123 |
a/c |
| 124 |
? a/d |
| 125 |
|
| 126 |
Local directory rename with conflicting file added in remote source directory |
| 127 |
and committed in local target directory. |
| 128 |
|
| 129 |
$ hg co -qC 1 |
| 130 |
$ echo target > b/c |
| 131 |
$ hg add b/c |
| 132 |
$ hg commit -qm 'new file in target directory' |
| 133 |
$ hg merge 2 |
| 134 |
merging b/c and a/c to b/c |
| 135 |
warning: conflicts while merging b/c! (edit, then use 'hg resolve --mark') |
| 136 |
0 files updated, 0 files merged, 0 files removed, 1 files unresolved |
| 137 |
use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon |
| 138 |
[1] |
| 139 |
$ hg st -A |
| 140 |
M b/c |
| 141 |
a/c |
| 142 |
? a/d |
| 143 |
? b/c.orig |
| 144 |
C b/a |
| 145 |
C b/b |
| 146 |
$ cat b/c |
| 147 |
<<<<<<< working copy: f1c50ca4f127 - test: new file in target directory |
| 148 |
target |
| 149 |
======= |
| 150 |
baz |
| 151 |
>>>>>>> merge rev: ce36d17b18fb - test: 2 add a/c |
| 152 |
$ rm b/c.orig |
| 153 |
|
| 154 |
Remote directory rename with conflicting file added in remote target directory |
| 155 |
and committed in local source directory. |
| 156 |
|
| 157 |
$ hg co -qC 2 |
| 158 |
$ hg st -A |
| 159 |
? a/d |
| 160 |
C a/a |
| 161 |
C a/b |
| 162 |
C a/c |
| 163 |
$ hg merge 5 |
| 164 |
merging a/c and b/c to b/c |
| 165 |
warning: conflicts while merging b/c! (edit, then use 'hg resolve --mark') |
| 166 |
2 files updated, 0 files merged, 2 files removed, 1 files unresolved |
| 167 |
use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon |
| 168 |
[1] |
| 169 |
$ hg st -A |
| 170 |
M b/a |
| 171 |
M b/b |
| 172 |
M b/c |
| 173 |
a/c |
| 174 |
R a/a |
| 175 |
R a/b |
| 176 |
R a/c |
| 177 |
? a/d |
| 178 |
? b/c.orig |
| 179 |
$ cat b/c |
| 180 |
<<<<<<< working copy: ce36d17b18fb - test: 2 add a/c |
| 181 |
baz |
| 182 |
======= |
| 183 |
target |
| 184 |
>>>>>>> merge rev: f1c50ca4f127 - test: new file in target directory |
| 185 |
|
| 186 |
Second scenario with two repos: |
| 187 |
|
| 188 |
$ cd .. |
| 189 |
$ hg init r1 |
| 190 |
$ cd r1 |
| 191 |
$ mkdir a |
| 192 |
$ echo foo > a/f |
| 193 |
$ hg add a |
| 194 |
adding a/f |
| 195 |
$ hg ci -m "a/f == foo" |
| 196 |
$ cd .. |
| 197 |
|
| 198 |
$ hg clone r1 r2 |
| 199 |
updating to branch default |
| 200 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 201 |
$ cd r2 |
| 202 |
$ hg mv a b |
| 203 |
moving a/f to b/f |
| 204 |
$ echo foo1 > b/f |
| 205 |
$ hg ci -m" a -> b, b/f == foo1" |
| 206 |
$ cd .. |
| 207 |
|
| 208 |
$ cd r1 |
| 209 |
$ mkdir a/aa |
| 210 |
$ echo bar > a/aa/g |
| 211 |
$ hg add a/aa |
| 212 |
adding a/aa/g |
| 213 |
$ hg ci -m "a/aa/g" |
| 214 |
$ hg pull ../r2 |
| 215 |
pulling from ../r2 |
| 216 |
searching for changes |
| 217 |
adding changesets |
| 218 |
adding manifests |
| 219 |
adding file changes |
| 220 |
added 1 changesets with 1 changes to 1 files (+1 heads) |
| 221 |
new changesets 7d51ed18da25 |
| 222 |
1 local changesets published |
| 223 |
(run 'hg heads' to see heads, 'hg merge' to merge) |
| 224 |
|
| 225 |
$ hg merge |
| 226 |
2 files updated, 0 files merged, 1 files removed, 0 files unresolved |
| 227 |
(branch merge, don't forget to commit) |
| 228 |
|
| 229 |
$ hg st -C |
| 230 |
M b/f |
| 231 |
A b/aa/g |
| 232 |
a/aa/g |
| 233 |
R a/aa/g |
| 234 |
R a/f |
| 235 |
|
| 236 |
$ cd .. |
| 237 |
|
| 238 |
Test renames to separate directories |
| 239 |
|
| 240 |
$ hg init a |
| 241 |
$ cd a |
| 242 |
$ mkdir a |
| 243 |
$ touch a/s |
| 244 |
$ touch a/t |
| 245 |
$ hg ci -Am0 |
| 246 |
adding a/s |
| 247 |
adding a/t |
| 248 |
|
| 249 |
Add more files |
| 250 |
|
| 251 |
$ touch a/s2 |
| 252 |
$ touch a/t2 |
| 253 |
$ hg ci -Am1 |
| 254 |
adding a/s2 |
| 255 |
adding a/t2 |
| 256 |
|
| 257 |
Do moves on a branch |
| 258 |
|
| 259 |
$ hg up 0 |
| 260 |
0 files updated, 0 files merged, 2 files removed, 0 files unresolved |
| 261 |
$ mkdir s |
| 262 |
$ mkdir t |
| 263 |
$ hg mv a/s s |
| 264 |
$ hg mv a/t t |
| 265 |
$ hg ci -Am2 |
| 266 |
created new head |
| 267 |
$ hg st --copies --change . |
| 268 |
A s/s |
| 269 |
a/s |
| 270 |
A t/t |
| 271 |
a/t |
| 272 |
R a/s |
| 273 |
R a/t |
| 274 |
|
| 275 |
Merge shouldn't move s2, t2 |
| 276 |
|
| 277 |
$ hg merge |
| 278 |
2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 279 |
(branch merge, don't forget to commit) |
| 280 |
$ hg st --copies |
| 281 |
M a/s2 |
| 282 |
M a/t2 |
| 283 |
|
| 284 |
Try the merge in the other direction. It may or may not be appropriate for |
| 285 |
status to list copies here. |
| 286 |
|
| 287 |
$ hg up -C 1 |
| 288 |
4 files updated, 0 files merged, 2 files removed, 0 files unresolved |
| 289 |
$ hg merge |
| 290 |
2 files updated, 0 files merged, 2 files removed, 0 files unresolved |
| 291 |
(branch merge, don't forget to commit) |
| 292 |
$ hg st --copies |
| 293 |
M s/s |
| 294 |
M t/t |
| 295 |
R a/s |
| 296 |
R a/t |
| 297 |
|
| 298 |
$ cd .. |
| 299 |
|
| 300 |
|
| 301 |
Test that files are moved to a new directory based on the path prefix that |
| 302 |
matches the most. dir1/ below gets renamed to dir2/, and dir1/subdir1/ gets |
| 303 |
renamed to dir2/subdir2/. We want dir1/subdir1/newfile to move to |
| 304 |
dir2/subdir2/ (not to dir2/subdir1/ as we would infer based on just the rename |
| 305 |
of dir1/ to dir2/). |
| 306 |
|
| 307 |
$ hg init nested-renames |
| 308 |
$ cd nested-renames |
| 309 |
$ mkdir dir1 |
| 310 |
$ echo a > dir1/file1 |
| 311 |
$ echo b > dir1/file2 |
| 312 |
$ mkdir dir1/subdir1 |
| 313 |
$ echo c > dir1/subdir1/file3 |
| 314 |
$ echo d > dir1/subdir1/file4 |
| 315 |
$ hg ci -Aqm initial |
| 316 |
$ hg mv dir1 dir2 |
| 317 |
moving dir1/file1 to dir2/file1 |
| 318 |
moving dir1/file2 to dir2/file2 |
| 319 |
moving dir1/subdir1/file3 to dir2/subdir1/file3 |
| 320 |
moving dir1/subdir1/file4 to dir2/subdir1/file4 |
| 321 |
$ hg mv dir2/subdir1 dir2/subdir2 |
| 322 |
moving dir2/subdir1/file3 to dir2/subdir2/file3 |
| 323 |
moving dir2/subdir1/file4 to dir2/subdir2/file4 |
| 324 |
$ hg ci -m 'move dir1/ to dir2/ and dir1/subdir1/ to dir2/subdir2/' |
| 325 |
$ hg co 0 |
| 326 |
4 files updated, 0 files merged, 4 files removed, 0 files unresolved |
| 327 |
$ echo e > dir1/subdir1/file5 |
| 328 |
$ hg ci -Aqm 'add file in dir1/subdir1/' |
| 329 |
$ hg merge 1 |
| 330 |
5 files updated, 0 files merged, 4 files removed, 0 files unresolved |
| 331 |
(branch merge, don't forget to commit) |
| 332 |
$ hg files |
| 333 |
dir2/file1 |
| 334 |
dir2/file2 |
| 335 |
dir2/subdir2/file3 |
| 336 |
dir2/subdir2/file4 |
| 337 |
dir2/subdir2/file5 |
| 338 |
$ cd .. |