Mercurial > hg > hg-git
comparison git_handler.py @ 8:2548735d24ef
will now more or less correctly determine a changelist from a git commit
author | Scott Chacon <schacon@gmail.com> |
---|---|
date | Sat, 25 Apr 2009 16:57:11 -0700 (2009-04-25) |
parents | 89992b6d2eef |
children | 7e776864b301 |
comparison
equal
deleted
inserted
replaced
7:89992b6d2eef | 8:2548735d24ef |
---|---|
79 # sort the commits by commit date (TODO: change to topo sort) | 79 # sort the commits by commit date (TODO: change to topo sort) |
80 convert_list.sort(cmp=lambda x,y: x.commit_time-y.commit_time) | 80 convert_list.sort(cmp=lambda x,y: x.commit_time-y.commit_time) |
81 | 81 |
82 # import each of the commits, oldest first | 82 # import each of the commits, oldest first |
83 for commit in convert_list: | 83 for commit in convert_list: |
84 print "commit: %s" % sha | |
85 self.import_git_commit(commit) | 84 self.import_git_commit(commit) |
86 | 85 |
87 # TODO : update Hg bookmarks (possibly named heads?) | 86 # TODO : update Hg bookmarks (possibly named heads?) |
88 print bookmarks.parse(self.repo) | 87 print bookmarks.parse(self.repo) |
89 | 88 |
90 def import_git_commit(self, commit): | 89 def import_git_commit(self, commit): |
91 print commit.parents | 90 print "importing: " + commit.id |
92 | 91 |
93 # TODO : have to handle merge contexts at some point (two parent files, etc) | 92 # TODO : have to handle merge contexts at some point (two parent files, etc) |
94 def getfilectx(repo, memctx, f): | 93 def getfilectx(repo, memctx, f): |
95 data = commit.getfile(f) | 94 (e, sha, data) = self.git.get_file(commit, f) |
96 e = commit.getmode(f) | 95 e = '' # TODO : make this a real mode |
97 return context.memfilectx(f, data, 'l' in e, 'x' in e, None) | 96 return context.memfilectx(f, data, 'l' in e, 'x' in e, None) |
98 | 97 |
99 p1 = "0" * 40 | 98 p1 = "0" * 40 |
100 p2 = "0" * 40 | 99 p2 = "0" * 40 |
101 # TODO : do something if parent is not mapped yet! | 100 # TODO : do something if parent is not mapped yet! |
107 p2 = self._map[sha] | 106 p2 = self._map[sha] |
108 if len(commit.parents) > 2: | 107 if len(commit.parents) > 2: |
109 # TODO : map extra parents to the extras file | 108 # TODO : map extra parents to the extras file |
110 pass | 109 pass |
111 | 110 |
112 files = commit.getfiles() | 111 files = self.git.get_files_changed(commit) |
112 | |
113 print files | |
113 | 114 |
114 # get a list of the changed, added, removed files | 115 # get a list of the changed, added, removed files |
115 extra = {} | 116 extra = {} |
116 text = commit.message | 117 text = commit.message |
117 date = datetime.datetime.fromtimestamp(commit.author_time).strftime("%Y-%m-%d %H:%M:%S") | 118 date = datetime.datetime.fromtimestamp(commit.author_time).strftime("%Y-%m-%d %H:%M:%S") |