| 1 |
$ cat <<EOF > merge |
| 2 |
> import sys, os |
| 3 |
> |
| 4 |
> try: |
| 5 |
> import msvcrt |
| 6 |
> msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) |
| 7 |
> msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY) |
| 8 |
> except ImportError: |
| 9 |
> pass |
| 10 |
> |
| 11 |
> print("merging for", os.path.basename(sys.argv[1])) |
| 12 |
> EOF |
| 13 |
$ HGMERGE="\"$PYTHON\" ../merge"; export HGMERGE |
| 14 |
|
| 15 |
$ hg init t |
| 16 |
$ cd t |
| 17 |
$ echo This is file a1 > a |
| 18 |
$ hg add a |
| 19 |
$ hg commit -m "commit #0" |
| 20 |
$ echo This is file b1 > b |
| 21 |
$ hg add b |
| 22 |
$ hg commit -m "commit #1" |
| 23 |
|
| 24 |
$ hg update 0 |
| 25 |
0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
| 26 |
|
| 27 |
Test interrupted updates by having a non-empty dir with the same name as one |
| 28 |
of the files in a commit we're updating to |
| 29 |
|
| 30 |
$ mkdir b && touch b/nonempty |
| 31 |
$ hg up |
| 32 |
abort: Unlinking directory not permitted: *$TESTTMP/t/b* (glob) (windows !) |
| 33 |
abort: Directory not empty: '?\$TESTTMP/t/b'? (re) (no-windows no-rust !) |
| 34 |
abort: conflicting unknown directory '$TESTTMP/t/b' is not empty (no-windows rust !) |
| 35 |
[255] |
| 36 |
$ hg ci |
| 37 |
abort: last update was interrupted |
| 38 |
(use 'hg update' to get a consistent checkout) |
| 39 |
[20] |
| 40 |
$ hg sum |
| 41 |
parent: 0:538afb845929 |
| 42 |
commit #0 |
| 43 |
branch: default |
| 44 |
commit: 1 unknown (interrupted update) |
| 45 |
update: 1 new changesets (update) |
| 46 |
phases: 2 draft |
| 47 |
Detect interrupted update by hg status --verbose |
| 48 |
$ hg status -v |
| 49 |
? b/nonempty |
| 50 |
# The repository is in an unfinished *update* state. |
| 51 |
|
| 52 |
# To continue: hg update . |
| 53 |
|
| 54 |
|
| 55 |
$ rm b/nonempty |
| 56 |
|
| 57 |
$ hg up |
| 58 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 59 |
$ hg sum |
| 60 |
parent: 1:b8bb4a988f25 tip |
| 61 |
commit #1 |
| 62 |
branch: default |
| 63 |
commit: (clean) |
| 64 |
update: (current) |
| 65 |
phases: 2 draft |
| 66 |
|
| 67 |
Prepare a basic merge |
| 68 |
|
| 69 |
$ hg up 0 |
| 70 |
0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
| 71 |
$ echo This is file c1 > c |
| 72 |
$ hg add c |
| 73 |
$ hg commit -m "commit #2" |
| 74 |
created new head |
| 75 |
$ echo This is file b1 > b |
| 76 |
no merges expected |
| 77 |
$ hg merge -P 1 |
| 78 |
changeset: 1:b8bb4a988f25 |
| 79 |
user: test |
| 80 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 81 |
summary: commit #1 |
| 82 |
|
| 83 |
$ hg merge 1 |
| 84 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 85 |
(branch merge, don't forget to commit) |
| 86 |
$ hg diff --nodates |
| 87 |
diff -r 49035e18a8e6 b |
| 88 |
--- /dev/null |
| 89 |
+++ b/b |
| 90 |
@@ -0,0 +1,1 @@ |
| 91 |
+This is file b1 |
| 92 |
$ hg status |
| 93 |
M b |
| 94 |
$ cd ..; rm -r t |
| 95 |
|
| 96 |
$ hg init t |
| 97 |
$ cd t |
| 98 |
$ echo This is file a1 > a |
| 99 |
$ hg add a |
| 100 |
$ hg commit -m "commit #0" |
| 101 |
$ echo This is file b1 > b |
| 102 |
$ hg add b |
| 103 |
$ hg commit -m "commit #1" |
| 104 |
|
| 105 |
$ hg update 0 |
| 106 |
0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
| 107 |
$ echo This is file c1 > c |
| 108 |
$ hg add c |
| 109 |
$ hg commit -m "commit #2" |
| 110 |
created new head |
| 111 |
$ echo This is file b2 > b |
| 112 |
merge should fail |
| 113 |
$ hg merge 1 |
| 114 |
b: untracked file differs |
| 115 |
abort: untracked files in working directory differ from files in requested revision |
| 116 |
[20] |
| 117 |
|
| 118 |
#if symlink |
| 119 |
symlinks to directories should be treated as regular files (issue5027) |
| 120 |
$ rm b |
| 121 |
$ ln -s 'This is file b2' b |
| 122 |
$ hg merge 1 |
| 123 |
b: untracked file differs |
| 124 |
abort: untracked files in working directory differ from files in requested revision |
| 125 |
[20] |
| 126 |
symlinks shouldn't be followed |
| 127 |
$ rm b |
| 128 |
$ echo This is file b1 > .hg/b |
| 129 |
$ ln -s .hg/b b |
| 130 |
$ hg merge 1 |
| 131 |
b: untracked file differs |
| 132 |
abort: untracked files in working directory differ from files in requested revision |
| 133 |
[20] |
| 134 |
|
| 135 |
$ rm b |
| 136 |
$ echo This is file b2 > b |
| 137 |
#endif |
| 138 |
|
| 139 |
bad config |
| 140 |
$ hg merge 1 --config merge.checkunknown=x |
| 141 |
config error: merge.checkunknown not valid ('x' is none of 'abort', 'ignore', 'warn') |
| 142 |
[30] |
| 143 |
this merge should fail |
| 144 |
$ hg merge 1 --config merge.checkunknown=abort |
| 145 |
b: untracked file differs |
| 146 |
abort: untracked files in working directory differ from files in requested revision |
| 147 |
[20] |
| 148 |
|
| 149 |
this merge should warn |
| 150 |
$ hg merge 1 --config merge.checkunknown=warn |
| 151 |
b: replacing untracked file |
| 152 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 153 |
(branch merge, don't forget to commit) |
| 154 |
$ cat b.orig |
| 155 |
This is file b2 |
| 156 |
$ hg up --clean 2 |
| 157 |
0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
| 158 |
$ mv b.orig b |
| 159 |
|
| 160 |
this merge should silently ignore |
| 161 |
$ cat b |
| 162 |
This is file b2 |
| 163 |
$ hg merge 1 --config merge.checkunknown=ignore |
| 164 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 165 |
(branch merge, don't forget to commit) |
| 166 |
|
| 167 |
merge.checkignored |
| 168 |
$ hg up --clean 1 |
| 169 |
1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
| 170 |
$ cat >> .hgignore << EOF |
| 171 |
> remoteignored |
| 172 |
> EOF |
| 173 |
$ echo This is file localignored3 > localignored |
| 174 |
$ echo This is file remoteignored3 > remoteignored |
| 175 |
$ hg add .hgignore localignored remoteignored |
| 176 |
$ hg commit -m "commit #3" |
| 177 |
|
| 178 |
$ hg up 2 |
| 179 |
1 files updated, 0 files merged, 4 files removed, 0 files unresolved |
| 180 |
$ cat >> .hgignore << EOF |
| 181 |
> localignored |
| 182 |
> EOF |
| 183 |
$ hg add .hgignore |
| 184 |
$ hg commit -m "commit #4" |
| 185 |
|
| 186 |
remote .hgignore shouldn't be used for determining whether a file is ignored |
| 187 |
$ echo This is file remoteignored4 > remoteignored |
| 188 |
$ hg merge 3 --config merge.checkignored=ignore --config merge.checkunknown=abort |
| 189 |
remoteignored: untracked file differs |
| 190 |
abort: untracked files in working directory differ from files in requested revision |
| 191 |
[20] |
| 192 |
$ hg merge 3 --config merge.checkignored=abort --config merge.checkunknown=ignore |
| 193 |
merging .hgignore |
| 194 |
merging for .hgignore |
| 195 |
3 files updated, 1 files merged, 0 files removed, 0 files unresolved |
| 196 |
(branch merge, don't forget to commit) |
| 197 |
$ cat remoteignored |
| 198 |
This is file remoteignored3 |
| 199 |
$ cat remoteignored.orig |
| 200 |
This is file remoteignored4 |
| 201 |
$ rm remoteignored.orig |
| 202 |
|
| 203 |
local .hgignore should be used for that |
| 204 |
$ hg up --clean 4 |
| 205 |
1 files updated, 0 files merged, 3 files removed, 0 files unresolved |
| 206 |
$ echo This is file localignored4 > localignored |
| 207 |
also test other conflicting files to see we output the full set of warnings |
| 208 |
$ echo This is file b2 > b |
| 209 |
$ hg merge 3 --config merge.checkignored=abort --config merge.checkunknown=abort |
| 210 |
b: untracked file differs |
| 211 |
localignored: untracked file differs |
| 212 |
abort: untracked files in working directory differ from files in requested revision |
| 213 |
[20] |
| 214 |
$ hg merge 3 --config merge.checkignored=abort --config merge.checkunknown=ignore |
| 215 |
localignored: untracked file differs |
| 216 |
abort: untracked files in working directory differ from files in requested revision |
| 217 |
[20] |
| 218 |
$ hg merge 3 --config merge.checkignored=warn --config merge.checkunknown=abort |
| 219 |
b: untracked file differs |
| 220 |
abort: untracked files in working directory differ from files in requested revision |
| 221 |
[20] |
| 222 |
$ hg merge 3 --config merge.checkignored=warn --config merge.checkunknown=warn |
| 223 |
b: replacing untracked file |
| 224 |
localignored: replacing untracked file |
| 225 |
merging .hgignore |
| 226 |
merging for .hgignore |
| 227 |
3 files updated, 1 files merged, 0 files removed, 0 files unresolved |
| 228 |
(branch merge, don't forget to commit) |
| 229 |
$ cat localignored |
| 230 |
This is file localignored3 |
| 231 |
$ cat localignored.orig |
| 232 |
This is file localignored4 |
| 233 |
$ rm localignored.orig |
| 234 |
|
| 235 |
$ cat b.orig |
| 236 |
This is file b2 |
| 237 |
$ hg up --clean 2 |
| 238 |
0 files updated, 0 files merged, 4 files removed, 0 files unresolved |
| 239 |
$ mv b.orig b |
| 240 |
|
| 241 |
this merge of b should work |
| 242 |
$ cat b |
| 243 |
This is file b2 |
| 244 |
$ hg merge -f 1 |
| 245 |
merging b |
| 246 |
merging for b |
| 247 |
0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
| 248 |
(branch merge, don't forget to commit) |
| 249 |
$ hg diff --nodates |
| 250 |
diff -r 49035e18a8e6 b |
| 251 |
--- /dev/null |
| 252 |
+++ b/b |
| 253 |
@@ -0,0 +1,1 @@ |
| 254 |
+This is file b2 |
| 255 |
$ hg status |
| 256 |
M b |
| 257 |
$ cd ..; rm -r t |
| 258 |
|
| 259 |
$ hg init t |
| 260 |
$ cd t |
| 261 |
$ echo This is file a1 > a |
| 262 |
$ hg add a |
| 263 |
$ hg commit -m "commit #0" |
| 264 |
$ echo This is file b1 > b |
| 265 |
$ hg add b |
| 266 |
$ hg commit -m "commit #1" |
| 267 |
$ echo This is file b22 > b |
| 268 |
$ hg commit -m "commit #2" |
| 269 |
$ hg update 1 |
| 270 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 271 |
$ echo This is file c1 > c |
| 272 |
$ hg add c |
| 273 |
$ hg commit -m "commit #3" |
| 274 |
created new head |
| 275 |
|
| 276 |
Contents of b should be "this is file b1" |
| 277 |
$ cat b |
| 278 |
This is file b1 |
| 279 |
|
| 280 |
$ echo This is file b22 > b |
| 281 |
merge fails |
| 282 |
$ hg merge 2 |
| 283 |
abort: uncommitted changes |
| 284 |
(use 'hg status' to list changes) |
| 285 |
[20] |
| 286 |
merge expected! |
| 287 |
$ hg merge -f 2 |
| 288 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 289 |
(branch merge, don't forget to commit) |
| 290 |
$ hg diff --nodates |
| 291 |
diff -r 85de557015a8 b |
| 292 |
--- a/b |
| 293 |
+++ b/b |
| 294 |
@@ -1,1 +1,1 @@ |
| 295 |
-This is file b1 |
| 296 |
+This is file b22 |
| 297 |
$ hg status |
| 298 |
M b |
| 299 |
$ cd ..; rm -r t |
| 300 |
|
| 301 |
$ hg init t |
| 302 |
$ cd t |
| 303 |
$ echo This is file a1 > a |
| 304 |
$ hg add a |
| 305 |
$ hg commit -m "commit #0" |
| 306 |
$ echo This is file b1 > b |
| 307 |
$ hg add b |
| 308 |
$ hg commit -m "commit #1" |
| 309 |
$ echo This is file b22 > b |
| 310 |
$ hg commit -m "commit #2" |
| 311 |
$ hg update 1 |
| 312 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 313 |
$ echo This is file c1 > c |
| 314 |
$ hg add c |
| 315 |
$ hg commit -m "commit #3" |
| 316 |
created new head |
| 317 |
$ echo This is file b33 > b |
| 318 |
merge of b should fail |
| 319 |
$ hg merge 2 |
| 320 |
abort: uncommitted changes |
| 321 |
(use 'hg status' to list changes) |
| 322 |
[20] |
| 323 |
merge of b expected |
| 324 |
$ hg merge -f 2 |
| 325 |
merging b |
| 326 |
merging for b |
| 327 |
0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
| 328 |
(branch merge, don't forget to commit) |
| 329 |
$ hg diff --nodates |
| 330 |
diff -r 85de557015a8 b |
| 331 |
--- a/b |
| 332 |
+++ b/b |
| 333 |
@@ -1,1 +1,1 @@ |
| 334 |
-This is file b1 |
| 335 |
+This is file b33 |
| 336 |
$ hg status |
| 337 |
M b |
| 338 |
|
| 339 |
Test for issue2364 |
| 340 |
|
| 341 |
$ hg up -qC . |
| 342 |
$ hg rm b |
| 343 |
$ hg ci -md |
| 344 |
$ hg revert -r -2 b |
| 345 |
$ hg up -q -- -2 |
| 346 |
|
| 347 |
Test that updated files are treated as "modified", when |
| 348 |
'merge.update()' is aborted before 'merge.recordupdates()' (= parents |
| 349 |
aren't changed), even if none of mode, size and timestamp of them |
| 350 |
isn't changed on the filesystem (see also issue4583). |
| 351 |
|
| 352 |
This test is now "best effort" as the mechanism to prevent such race are |
| 353 |
getting better, it get more complicated to test a specific scenario that would |
| 354 |
trigger it. If you see flakyness here, there is a race. |
| 355 |
|
| 356 |
$ cat > $TESTTMP/abort.py <<EOF |
| 357 |
> # emulate aborting before "recordupdates()". in this case, files |
| 358 |
> # are changed without updating dirstate |
| 359 |
> from mercurial import ( |
| 360 |
> error, |
| 361 |
> extensions, |
| 362 |
> ) |
| 363 |
> from mercurial.merge_utils import update |
| 364 |
> def apply_updates(orig, *args, **kwargs): |
| 365 |
> orig(*args, **kwargs) |
| 366 |
> raise error.Abort(b'intentional aborting') |
| 367 |
> def extsetup(ui): |
| 368 |
> extensions.wrapfunction(update, "apply_updates", apply_updates) |
| 369 |
> EOF |
| 370 |
|
| 371 |
(file gotten from other revision) |
| 372 |
|
| 373 |
$ hg update -q -C 2 |
| 374 |
$ echo 'THIS IS FILE B5' > b |
| 375 |
$ hg commit -m 'commit #5' |
| 376 |
|
| 377 |
$ hg update -q -C 3 |
| 378 |
$ cat b |
| 379 |
This is file b1 |
| 380 |
$ cat >> .hg/hgrc <<EOF |
| 381 |
> [extensions] |
| 382 |
> abort = $TESTTMP/abort.py |
| 383 |
> EOF |
| 384 |
$ hg merge 5 |
| 385 |
abort: intentional aborting |
| 386 |
[255] |
| 387 |
$ cat >> .hg/hgrc <<EOF |
| 388 |
> [extensions] |
| 389 |
> abort = ! |
| 390 |
> EOF |
| 391 |
|
| 392 |
$ cat b |
| 393 |
THIS IS FILE B5 |
| 394 |
$ hg status -A b |
| 395 |
M b |
| 396 |
|
| 397 |
(file merged from other revision) |
| 398 |
|
| 399 |
$ hg update -q -C 3 |
| 400 |
$ echo 'this is file b6' > b |
| 401 |
$ hg commit -m 'commit #6' |
| 402 |
created new head |
| 403 |
|
| 404 |
$ cat b |
| 405 |
this is file b6 |
| 406 |
$ hg status |
| 407 |
|
| 408 |
$ cat >> .hg/hgrc <<EOF |
| 409 |
> [extensions] |
| 410 |
> abort = $TESTTMP/abort.py |
| 411 |
> EOF |
| 412 |
$ hg merge --tool internal:other 5 |
| 413 |
abort: intentional aborting |
| 414 |
[255] |
| 415 |
$ cat >> .hg/hgrc <<EOF |
| 416 |
> [extensions] |
| 417 |
> abort = ! |
| 418 |
> EOF |
| 419 |
|
| 420 |
$ cat b |
| 421 |
THIS IS FILE B5 |
| 422 |
$ hg status -A b |
| 423 |
M b |
| 424 |
|
| 425 |
$ cd .. |