Show More
@@ -33,15 +33,18 b' class convert(object):' | |||
|
33 | 33 | self.source = source |
|
34 | 34 | self.dest = dest |
|
35 | 35 | self.ui = ui |
|
36 | self.mapfile = mapfile | |
|
37 | 36 | self.opts = opts |
|
38 | 37 | self.commitcache = {} |
|
38 | self.mapfile = mapfile | |
|
39 | self.mapfilefd = None | |
|
39 | 40 | |
|
40 | 41 | self.map = {} |
|
41 | 42 | try: |
|
42 |
|
|
|
43 | origmapfile = open(self.mapfile, 'r') | |
|
44 | for l in origmapfile: | |
|
43 | 45 | sv, dv = l[:-1].split() |
|
44 | 46 | self.map[sv] = dv |
|
47 | origmapfile.close() | |
|
45 | 48 | except IOError: |
|
46 | 49 | pass |
|
47 | 50 | |
@@ -118,6 +121,16 b' class convert(object):' | |||
|
118 | 121 | |
|
119 | 122 | return s |
|
120 | 123 | |
|
124 | def mapentry(self, src, dst): | |
|
125 | if self.mapfilefd is None: | |
|
126 | try: | |
|
127 | self.mapfilefd = open(self.mapfile, "a") | |
|
128 | except IOError, (errno, strerror): | |
|
129 | raise util.Abort("Could not open map file %s: %s, %s\n" % (self.mapfile, errno, strerror)) | |
|
130 | self.map[src] = dst | |
|
131 | self.mapfilefd.write("%s %s\n" % (src, dst)) | |
|
132 | self.mapfilefd.flush() | |
|
133 | ||
|
121 | 134 | def copy(self, rev): |
|
122 | 135 | c = self.commitcache[rev] |
|
123 | 136 | files = self.source.getchanges(rev) |
@@ -133,10 +146,11 b' class convert(object):' | |||
|
133 | 146 | |
|
134 | 147 | r = [self.map[v] for v in c.parents] |
|
135 | 148 | f = [f for f, v in files] |
|
136 |
|
|
|
137 | file(self.mapfile, "a").write("%s %s\n" % (rev, self.map[rev])) | |
|
149 | newnode = self.dest.putcommit(f, r, c) | |
|
150 | self.mapentry(rev, newnode) | |
|
138 | 151 | |
|
139 | 152 | def convert(self): |
|
153 | try: | |
|
140 | 154 | self.ui.status("scanning source...\n") |
|
141 | 155 | heads = self.source.getheads() |
|
142 | 156 | parents = self.walktree(heads) |
@@ -166,7 +180,13 b' class convert(object):' | |||
|
166 | 180 | # write another hash correspondence to override the previous |
|
167 | 181 | # one so we don't end up with extra tag heads |
|
168 | 182 | if nrev: |
|
169 |
|
|
|
183 | self.mapentry(c, nrev) | |
|
184 | finally: | |
|
185 | self.cleanup() | |
|
186 | ||
|
187 | def cleanup(self): | |
|
188 | if self.mapfilefd: | |
|
189 | self.mapfilefd.close() | |
|
170 | 190 | |
|
171 | 191 | def _convert(ui, src, dest=None, mapfile=None, **opts): |
|
172 | 192 | '''Convert a foreign SCM repository to a Mercurial one. |
General Comments 0
You need to be logged in to leave comments.
Login now