Show More
@@ -294,23 +294,34 b' class filemap_source(converter_source):' | |||||
294 | # A parent p is interesting if its mapped version (self.parentmap[p]): |
|
294 | # A parent p is interesting if its mapped version (self.parentmap[p]): | |
295 | # - is not SKIPREV |
|
295 | # - is not SKIPREV | |
296 | # - is still not in the list of parents (we don't want duplicates) |
|
296 | # - is still not in the list of parents (we don't want duplicates) | |
297 | # - is not an ancestor of the mapped versions of the other parents |
|
297 | # - is not an ancestor of the mapped versions of the other parents or | |
|
298 | # there is no parent in the same branch than the current revision. | |||
298 | mparents = [] |
|
299 | mparents = [] | |
299 |
wp = |
|
300 | knownparents = set() | |
|
301 | branch = self.commits[rev].branch | |||
|
302 | hasbranchparent = False | |||
300 | for i, p1 in enumerate(parents): |
|
303 | for i, p1 in enumerate(parents): | |
301 | mp1 = self.parentmap[p1] |
|
304 | mp1 = self.parentmap[p1] | |
302 |
if mp1 == SKIPREV or mp1 in |
|
305 | if mp1 == SKIPREV or mp1 in knownparents: | |
303 | continue |
|
306 | continue | |
304 |
for p2 in parents |
|
307 | isancestor = util.any(p2 for p2 in parents | |
305 |
if p1 |
|
308 | if p1 != p2 and mp1 != self.parentmap[p2] | |
306 | continue |
|
309 | and mp1 in self.wantedancestors[p2]) | |
307 | if mp1 in self.wantedancestors[p2]: |
|
310 | if not isancestor and not hasbranchparent and len(parents) > 1: | |
308 | break |
|
311 | # This could be expensive, avoid unnecessary calls. | |
309 | else: |
|
312 | if self._cachedcommit(p1).branch == branch: | |
310 | mparents.append(mp1) |
|
313 | hasbranchparent = True | |
311 | wp = i |
|
314 | mparents.append((p1, mp1, i, isancestor)) | |
312 |
|
315 | knownparents.add(mp1) | ||
313 | if wp is None and parents: |
|
316 | # Discard parents ancestors of other parents if there is a | |
|
317 | # non-ancestor one on the same branch than current revision. | |||
|
318 | if hasbranchparent: | |||
|
319 | mparents = [p for p in mparents if not p[3]] | |||
|
320 | wp = None | |||
|
321 | if mparents: | |||
|
322 | wp = max(p[2] for p in mparents) | |||
|
323 | mparents = [p[1] for p in mparents] | |||
|
324 | elif parents: | |||
314 | wp = 0 |
|
325 | wp = 0 | |
315 |
|
326 | |||
316 | self.origparents[rev] = parents |
|
327 | self.origparents[rev] = parents | |
@@ -319,7 +330,6 b' class filemap_source(converter_source):' | |||||
319 | if 'close' in self.commits[rev].extra: |
|
330 | if 'close' in self.commits[rev].extra: | |
320 | # A branch closing revision is only useful if one of its |
|
331 | # A branch closing revision is only useful if one of its | |
321 | # parents belong to the branch being closed |
|
332 | # parents belong to the branch being closed | |
322 | branch = self.commits[rev].branch |
|
|||
323 | pbranches = [self._cachedcommit(p).branch for p in mparents] |
|
333 | pbranches = [self._cachedcommit(p).branch for p in mparents] | |
324 | if branch in pbranches: |
|
334 | if branch in pbranches: | |
325 | closed = True |
|
335 | closed = True |
@@ -375,3 +375,189 b' exercise incremental conversion at the s' | |||||
375 | | |
|
375 | | | |
376 | o 0 "addb" files: b |
|
376 | o 0 "addb" files: b | |
377 |
|
377 | |||
|
378 | ||||
|
379 | test merge parents/empty merges pruning | |||
|
380 | ||||
|
381 | $ glog() | |||
|
382 | > { | |||
|
383 | > hg glog --template '{rev}:{node|short}@{branch} "{desc}" files: {files}\n' "$@" | |||
|
384 | > } | |||
|
385 | ||||
|
386 | test anonymous branch pruning | |||
|
387 | ||||
|
388 | $ hg init anonymousbranch | |||
|
389 | $ cd anonymousbranch | |||
|
390 | $ echo a > a | |||
|
391 | $ echo b > b | |||
|
392 | $ hg ci -Am add | |||
|
393 | adding a | |||
|
394 | adding b | |||
|
395 | $ echo a >> a | |||
|
396 | $ hg ci -m changea | |||
|
397 | $ hg up 0 | |||
|
398 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
399 | $ echo b >> b | |||
|
400 | $ hg ci -m changeb | |||
|
401 | created new head | |||
|
402 | $ hg up 1 | |||
|
403 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
404 | $ hg merge | |||
|
405 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
406 | (branch merge, don't forget to commit) | |||
|
407 | $ hg ci -m merge | |||
|
408 | $ cd .. | |||
|
409 | ||||
|
410 | $ cat > filemap <<EOF | |||
|
411 | > include a | |||
|
412 | > EOF | |||
|
413 | $ hg convert --filemap filemap anonymousbranch anonymousbranch-hg | |||
|
414 | initializing destination anonymousbranch-hg repository | |||
|
415 | scanning source... | |||
|
416 | sorting... | |||
|
417 | converting... | |||
|
418 | 3 add | |||
|
419 | 2 changea | |||
|
420 | 1 changeb | |||
|
421 | 0 merge | |||
|
422 | $ glog -R anonymousbranch | |||
|
423 | @ 3:c71d5201a498@default "merge" files: | |||
|
424 | |\ | |||
|
425 | | o 2:607eb44b17f9@default "changeb" files: b | |||
|
426 | | | | |||
|
427 | o | 1:1f60ea617824@default "changea" files: a | |||
|
428 | |/ | |||
|
429 | o 0:0146e6129113@default "add" files: a b | |||
|
430 | ||||
|
431 | $ glog -R anonymousbranch-hg | |||
|
432 | o 1:cda818e7219b@default "changea" files: a | |||
|
433 | | | |||
|
434 | o 0:c334dc3be0da@default "add" files: a | |||
|
435 | ||||
|
436 | $ cat anonymousbranch-hg/.hg/shamap | |||
|
437 | 0146e6129113dba9ac90207cfdf2d7ed35257ae5 c334dc3be0daa2a4e9ce4d2e2bdcba40c09d4916 | |||
|
438 | 1f60ea61782421edf8d051ff4fcb61b330f26a4a cda818e7219b5f7f3fb9f49780054ed6a1905ec3 | |||
|
439 | 607eb44b17f9348cd5cbd26e16af87ba77b0b037 c334dc3be0daa2a4e9ce4d2e2bdcba40c09d4916 | |||
|
440 | c71d5201a498b2658d105a6bf69d7a0df2649aea cda818e7219b5f7f3fb9f49780054ed6a1905ec3 | |||
|
441 | ||||
|
442 | $ cat > filemap <<EOF | |||
|
443 | > include b | |||
|
444 | > EOF | |||
|
445 | $ hg convert --filemap filemap anonymousbranch anonymousbranch-hg2 | |||
|
446 | initializing destination anonymousbranch-hg2 repository | |||
|
447 | scanning source... | |||
|
448 | sorting... | |||
|
449 | converting... | |||
|
450 | 3 add | |||
|
451 | 2 changea | |||
|
452 | 1 changeb | |||
|
453 | 0 merge | |||
|
454 | $ glog -R anonymousbranch | |||
|
455 | @ 3:c71d5201a498@default "merge" files: | |||
|
456 | |\ | |||
|
457 | | o 2:607eb44b17f9@default "changeb" files: b | |||
|
458 | | | | |||
|
459 | o | 1:1f60ea617824@default "changea" files: a | |||
|
460 | |/ | |||
|
461 | o 0:0146e6129113@default "add" files: a b | |||
|
462 | ||||
|
463 | $ glog -R anonymousbranch-hg2 | |||
|
464 | o 1:62dd350b0df6@default "changeb" files: b | |||
|
465 | | | |||
|
466 | o 0:4b9ced861657@default "add" files: b | |||
|
467 | ||||
|
468 | $ cat anonymousbranch-hg2/.hg/shamap | |||
|
469 | 0146e6129113dba9ac90207cfdf2d7ed35257ae5 4b9ced86165703791653059a1db6ed864630a523 | |||
|
470 | 1f60ea61782421edf8d051ff4fcb61b330f26a4a 4b9ced86165703791653059a1db6ed864630a523 | |||
|
471 | 607eb44b17f9348cd5cbd26e16af87ba77b0b037 62dd350b0df695f7d2c82a02e0499b16fd790f22 | |||
|
472 | c71d5201a498b2658d105a6bf69d7a0df2649aea 62dd350b0df695f7d2c82a02e0499b16fd790f22 | |||
|
473 | ||||
|
474 | test named branch pruning | |||
|
475 | ||||
|
476 | $ hg init namedbranch | |||
|
477 | $ cd namedbranch | |||
|
478 | $ echo a > a | |||
|
479 | $ echo b > b | |||
|
480 | $ hg ci -Am add | |||
|
481 | adding a | |||
|
482 | adding b | |||
|
483 | $ echo a >> a | |||
|
484 | $ hg ci -m changea | |||
|
485 | $ hg up 0 | |||
|
486 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
487 | $ hg branch foo | |||
|
488 | marked working directory as branch foo | |||
|
489 | (branches are permanent and global, did you want a bookmark?) | |||
|
490 | $ echo b >> b | |||
|
491 | $ hg ci -m changeb | |||
|
492 | $ hg up default | |||
|
493 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
494 | $ hg merge foo | |||
|
495 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
496 | (branch merge, don't forget to commit) | |||
|
497 | $ hg ci -m merge | |||
|
498 | $ cd .. | |||
|
499 | ||||
|
500 | $ cat > filemap <<EOF | |||
|
501 | > include a | |||
|
502 | > EOF | |||
|
503 | $ hg convert --filemap filemap namedbranch namedbranch-hg | |||
|
504 | initializing destination namedbranch-hg repository | |||
|
505 | scanning source... | |||
|
506 | sorting... | |||
|
507 | converting... | |||
|
508 | 3 add | |||
|
509 | 2 changea | |||
|
510 | 1 changeb | |||
|
511 | 0 merge | |||
|
512 | $ glog -R namedbranch | |||
|
513 | @ 3:73899bcbe45c@default "merge" files: | |||
|
514 | |\ | |||
|
515 | | o 2:8097982d19fc@foo "changeb" files: b | |||
|
516 | | | | |||
|
517 | o | 1:1f60ea617824@default "changea" files: a | |||
|
518 | |/ | |||
|
519 | o 0:0146e6129113@default "add" files: a b | |||
|
520 | ||||
|
521 | $ glog -R namedbranch-hg | |||
|
522 | o 1:cda818e7219b@default "changea" files: a | |||
|
523 | | | |||
|
524 | o 0:c334dc3be0da@default "add" files: a | |||
|
525 | ||||
|
526 | ||||
|
527 | $ cd namedbranch | |||
|
528 | $ hg --config extensions.mq= strip tip | |||
|
529 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
530 | saved backup bundle to $TESTTMP/namedbranch/.hg/strip-backup/73899bcbe45c-backup.hg | |||
|
531 | $ hg up foo | |||
|
532 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
533 | $ hg merge default | |||
|
534 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
535 | (branch merge, don't forget to commit) | |||
|
536 | $ hg ci -m merge | |||
|
537 | $ cd .. | |||
|
538 | ||||
|
539 | $ hg convert --filemap filemap namedbranch namedbranch-hg2 | |||
|
540 | initializing destination namedbranch-hg2 repository | |||
|
541 | scanning source... | |||
|
542 | sorting... | |||
|
543 | converting... | |||
|
544 | 3 add | |||
|
545 | 2 changea | |||
|
546 | 1 changeb | |||
|
547 | 0 merge | |||
|
548 | $ glog -R namedbranch | |||
|
549 | @ 3:e1959de76e1b@foo "merge" files: | |||
|
550 | |\ | |||
|
551 | | o 2:8097982d19fc@foo "changeb" files: b | |||
|
552 | | | | |||
|
553 | o | 1:1f60ea617824@default "changea" files: a | |||
|
554 | |/ | |||
|
555 | o 0:0146e6129113@default "add" files: a b | |||
|
556 | ||||
|
557 | $ glog -R namedbranch-hg2 | |||
|
558 | o 2:dcf314454667@foo "merge" files: | |||
|
559 | |\ | |||
|
560 | | o 1:cda818e7219b@default "changea" files: a | |||
|
561 | |/ | |||
|
562 | o 0:c334dc3be0da@default "add" files: a | |||
|
563 |
General Comments 0
You need to be logged in to leave comments.
Login now