# HG changeset patch # User Scott Chacon <schacon@gmail.com> # Date 1242062285 25200 # Mon May 11 10:18:05 2009 -0700 # Node ID d862b6a4fbd4e02d93433cc4ad30c2f0ec8af4da # Parent dca3be87e9f167dacb4d9713516cd47768edd359 adding rename detection to already imported objects diff --git a/git_handler.py b/git_handler.py --- a/git_handler.py +++ b/git_handler.py @@ -456,13 +456,15 @@ # sort the commits commits = toposort.TopoSort(convert_list).items() - + # import each of the commits, oldest first for csha in commits: + commit = convert_list[csha] if not self.map_hg_get(csha): # it's already here - commit = convert_list[csha] self.import_git_commit(commit) - + else: + self.pseudo_import_git_commit(commit) + self.update_hg_bookmarks(remote_name) def update_hg_bookmarks(self, remote_name): @@ -505,7 +507,29 @@ if command == 'branch': branch = data return (message, renames, branch) - + + def pseudo_import_git_commit(self, commit): + (strip_message, hg_renames, hg_branch) = self.extract_hg_metadata(commit.message) + cs = self.map_hg_get(commit.id) + p1 = "0" * 40 + p2 = "0" * 40 + if len(commit.parents) > 0: + sha = commit.parents[0] + p1 = self.map_hg_get(sha) + if len(commit.parents) > 1: + sha = commit.parents[1] + p2 = self.map_hg_get(sha) + if len(commit.parents) > 2: + # TODO : map extra parents to the extras file + pass + # saving rename info + if (not (p2 == "0"*40) or (p1 == "0"*40)): + self.renames[cs] = {} + else: + self.renames[cs] = self.renames[p1].copy() + + self.renames[cs].update(hg_renames) + def import_git_commit(self, commit): self.ui.debug(_("importing: %s\n") % commit.id) # TODO : find and use hg named branches