Mercurial > hg-git
comparison git_handler.py @ 113:d862b6a4fbd4
adding rename detection to already imported objects
author | Scott Chacon <schacon@gmail.com> |
---|---|
date | Mon, 11 May 2009 10:18:05 -0700 |
parents | dca3be87e9f1 |
children | b3be536e3f50 |
comparison
equal
deleted
inserted
replaced
112:dca3be87e9f1 | 113:d862b6a4fbd4 |
---|---|
454 except: | 454 except: |
455 self.ui.warn(_("Cannot import tags yet\n")) # TODO | 455 self.ui.warn(_("Cannot import tags yet\n")) # TODO |
456 | 456 |
457 # sort the commits | 457 # sort the commits |
458 commits = toposort.TopoSort(convert_list).items() | 458 commits = toposort.TopoSort(convert_list).items() |
459 | 459 |
460 # import each of the commits, oldest first | 460 # import each of the commits, oldest first |
461 for csha in commits: | 461 for csha in commits: |
462 commit = convert_list[csha] | |
462 if not self.map_hg_get(csha): # it's already here | 463 if not self.map_hg_get(csha): # it's already here |
463 commit = convert_list[csha] | |
464 self.import_git_commit(commit) | 464 self.import_git_commit(commit) |
465 | 465 else: |
466 self.pseudo_import_git_commit(commit) | |
467 | |
466 self.update_hg_bookmarks(remote_name) | 468 self.update_hg_bookmarks(remote_name) |
467 | 469 |
468 def update_hg_bookmarks(self, remote_name): | 470 def update_hg_bookmarks(self, remote_name): |
469 try: | 471 try: |
470 bms = bookmarks.parse(self.repo) | 472 bms = bookmarks.parse(self.repo) |
503 before, after = data.split(" => ", 1) | 505 before, after = data.split(" => ", 1) |
504 renames[after] = before | 506 renames[after] = before |
505 if command == 'branch': | 507 if command == 'branch': |
506 branch = data | 508 branch = data |
507 return (message, renames, branch) | 509 return (message, renames, branch) |
508 | 510 |
511 def pseudo_import_git_commit(self, commit): | |
512 (strip_message, hg_renames, hg_branch) = self.extract_hg_metadata(commit.message) | |
513 cs = self.map_hg_get(commit.id) | |
514 p1 = "0" * 40 | |
515 p2 = "0" * 40 | |
516 if len(commit.parents) > 0: | |
517 sha = commit.parents[0] | |
518 p1 = self.map_hg_get(sha) | |
519 if len(commit.parents) > 1: | |
520 sha = commit.parents[1] | |
521 p2 = self.map_hg_get(sha) | |
522 if len(commit.parents) > 2: | |
523 # TODO : map extra parents to the extras file | |
524 pass | |
525 # saving rename info | |
526 if (not (p2 == "0"*40) or (p1 == "0"*40)): | |
527 self.renames[cs] = {} | |
528 else: | |
529 self.renames[cs] = self.renames[p1].copy() | |
530 | |
531 self.renames[cs].update(hg_renames) | |
532 | |
509 def import_git_commit(self, commit): | 533 def import_git_commit(self, commit): |
510 self.ui.debug(_("importing: %s\n") % commit.id) | 534 self.ui.debug(_("importing: %s\n") % commit.id) |
511 # TODO : find and use hg named branches | 535 # TODO : find and use hg named branches |
512 # TODO : add extra Git data (committer info) as extras to changeset | 536 # TODO : add extra Git data (committer info) as extras to changeset |
513 | 537 |