Mercurial > hgsubversion
comparison fetch_command.py @ 147:22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
with another. Includes a test case.
| author | Augie Fackler <durin42@gmail.com> |
|---|---|
| date | Sat, 20 Dec 2008 19:04:59 -0600 |
| parents | 6f2d67bf3039 |
| children | 6fa97cfbf62f |
comparison
equal
deleted
inserted
replaced
| 146:4da9f20aef01 | 147:22162380c4b9 |
|---|---|
| 479 # this server fails at replay | 479 # this server fails at replay |
| 480 branches = hg_editor.branches_in_paths(r.paths) | 480 branches = hg_editor.branches_in_paths(r.paths) |
| 481 deleted_branches = {} | 481 deleted_branches = {} |
| 482 date = r.date.replace('T', ' ').replace('Z', '').split('.')[0] | 482 date = r.date.replace('T', ' ').replace('Z', '').split('.')[0] |
| 483 date += ' -0000' | 483 date += ' -0000' |
| 484 check_deleted_branches = set() | |
| 484 for b in branches: | 485 for b in branches: |
| 485 parentctx = hg_editor.repo[hg_editor.get_parent_revision(r.revnum, b)] | 486 parentctx = hg_editor.repo[hg_editor.get_parent_revision(r.revnum, b)] |
| 487 if parentctx.branch() != (b or 'default'): | |
| 488 check_deleted_branches.add(b) | |
| 486 kind = svn.checkpath(branches[b], r.revnum) | 489 kind = svn.checkpath(branches[b], r.revnum) |
| 487 if kind != 'd': | 490 if kind != 'd': |
| 488 # Branch does not exist at this revision. Get parent revision and | 491 # Branch does not exist at this revision. Get parent revision and |
| 489 # remove everything. | 492 # remove everything. |
| 490 deleted_branches[b] = parentctx.node() | 493 deleted_branches[b] = parentctx.node() |
| 521 ha = hg_editor.repo.commitctx(current_ctx) | 524 ha = hg_editor.repo.commitctx(current_ctx) |
| 522 hg_editor.add_to_revmap(r.revnum, b, ha) | 525 hg_editor.add_to_revmap(r.revnum, b, ha) |
| 523 hg_editor._save_metadata() | 526 hg_editor._save_metadata() |
| 524 ui.status('committed as %s on branch %s\n' % | 527 ui.status('committed as %s on branch %s\n' % |
| 525 (node.hex(ha), b or 'default')) | 528 (node.hex(ha), b or 'default')) |
| 529 # These are branches which would have an 'R' status in svn log. This means they were | |
| 530 # replaced by some other branch, so we need to verify they get marked as closed. | |
| 531 for branch in check_deleted_branches: | |
| 532 branchedits = sorted(filter(lambda x: x[0][1] == branch and x[0][0] < r.revnum, | |
| 533 hg_editor.revmap.iteritems()), reverse=True) | |
| 534 is_closed = False | |
| 535 if len(branchedits) > 0: | |
| 536 branchtip = branchedits[0][1] | |
| 537 for child in hg_editor.repo[branchtip].children(): | |
| 538 if child.branch() == 'closed-branches': | |
| 539 is_closed = True | |
| 540 break | |
| 541 if not is_closed: | |
| 542 deleted_branches[branch] = branchtip | |
| 526 for b, parent in deleted_branches.iteritems(): | 543 for b, parent in deleted_branches.iteritems(): |
| 527 if parent == node.nullid: | 544 if parent == node.nullid: |
| 528 continue | 545 continue |
| 529 parentctx = hg_editor.repo[parent] | 546 parentctx = hg_editor.repo[parent] |
| 530 if parentctx.children(): | |
| 531 continue | |
| 532 files_touched = parentctx.manifest().keys() | 547 files_touched = parentctx.manifest().keys() |
| 533 def filectxfn(repo, memctx, path): | 548 def filectxfn(repo, memctx, path): |
| 534 raise IOError() | 549 raise IOError() |
| 535 closed = node.nullid | 550 closed = node.nullid |
| 536 if 'closed-branches' in hg_editor.repo.branchtags(): | 551 if 'closed-branches' in hg_editor.repo.branchtags(): |
