Show More
@@ -153,26 +153,18 b' class converter_sink(object):' | |||||
153 | mapping equivalent authors identifiers for each system.""" |
|
153 | mapping equivalent authors identifiers for each system.""" | |
154 | return None |
|
154 | return None | |
155 |
|
155 | |||
156 | def putfile(self, f, e, data): |
|
156 | def putcommit(self, files, copies, parents, commit, source): | |
157 | """Put file for next putcommit(). |
|
|||
158 | f: path to file |
|
|||
159 | e: '', 'x', or 'l' (regular file, executable, or symlink) |
|
|||
160 | data: file contents""" |
|
|||
161 | raise NotImplementedError() |
|
|||
162 |
|
||||
163 | def delfile(self, f): |
|
|||
164 | """Delete file for next putcommit(). |
|
|||
165 | f: path to file""" |
|
|||
166 | raise NotImplementedError() |
|
|||
167 |
|
||||
168 | def putcommit(self, files, parents, commit): |
|
|||
169 | """Create a revision with all changed files listed in 'files' |
|
157 | """Create a revision with all changed files listed in 'files' | |
170 | and having listed parents. 'commit' is a commit object containing |
|
158 | and having listed parents. 'commit' is a commit object containing | |
171 | at a minimum the author, date, and message for this changeset. |
|
159 | at a minimum the author, date, and message for this changeset. | |
172 | Called after putfile() and delfile() calls. Note that the sink |
|
160 | 'files' is a list of (path, version) tuples, 'copies'is a dictionary | |
173 | repository is not told to update itself to a particular revision |
|
161 | mapping destinations to sources, and 'source' is the source repository. | |
174 | (or even what that revision would be) before it receives the |
|
162 | Only getfile() and getmode() should be called on 'source'. | |
175 | file data.""" |
|
163 | ||
|
164 | Note that the sink repository is not told to update itself to | |||
|
165 | a particular revision (or even what that revision would be) | |||
|
166 | before it receives the file data. | |||
|
167 | """ | |||
176 | raise NotImplementedError() |
|
168 | raise NotImplementedError() | |
177 |
|
169 | |||
178 | def puttags(self, tags): |
|
170 | def puttags(self, tags): | |
@@ -181,7 +173,7 b' class converter_sink(object):' | |||||
181 | raise NotImplementedError() |
|
173 | raise NotImplementedError() | |
182 |
|
174 | |||
183 | def setbranch(self, branch, pbranches): |
|
175 | def setbranch(self, branch, pbranches): | |
184 |
"""Set the current branch name. Called before the first put |
|
176 | """Set the current branch name. Called before the first putcommit | |
185 | on the branch. |
|
177 | on the branch. | |
186 | branch: branch name for subsequent commits |
|
178 | branch: branch name for subsequent commits | |
187 | pbranches: (converted parent revision, parent branch) tuples""" |
|
179 | pbranches: (converted parent revision, parent branch) tuples""" |
@@ -221,8 +221,6 b' class converter(object):' | |||||
221 |
|
221 | |||
222 | def copy(self, rev): |
|
222 | def copy(self, rev): | |
223 | commit = self.commitcache[rev] |
|
223 | commit = self.commitcache[rev] | |
224 | do_copies = hasattr(self.dest, 'copyfile') |
|
|||
225 | filenames = [] |
|
|||
226 |
|
224 | |||
227 | changes = self.source.getchanges(rev) |
|
225 | changes = self.source.getchanges(rev) | |
228 | if isinstance(changes, basestring): |
|
226 | if isinstance(changes, basestring): | |
@@ -241,21 +239,6 b' class converter(object):' | |||||
241 | pbranches.append((self.map[prev], |
|
239 | pbranches.append((self.map[prev], | |
242 | self.commitcache[prev].branch)) |
|
240 | self.commitcache[prev].branch)) | |
243 | self.dest.setbranch(commit.branch, pbranches) |
|
241 | self.dest.setbranch(commit.branch, pbranches) | |
244 | for f, v in files: |
|
|||
245 | filenames.append(f) |
|
|||
246 | try: |
|
|||
247 | data = self.source.getfile(f, v) |
|
|||
248 | except IOError, inst: |
|
|||
249 | self.dest.delfile(f) |
|
|||
250 | else: |
|
|||
251 | e = self.source.getmode(f, v) |
|
|||
252 | self.dest.putfile(f, e, data) |
|
|||
253 | if do_copies: |
|
|||
254 | if f in copies: |
|
|||
255 | copyf = copies[f] |
|
|||
256 | # Merely marks that a copy happened. |
|
|||
257 | self.dest.copyfile(copyf, f) |
|
|||
258 |
|
||||
259 | try: |
|
242 | try: | |
260 | parents = self.splicemap[rev].replace(',', ' ').split() |
|
243 | parents = self.splicemap[rev].replace(',', ' ').split() | |
261 | self.ui.status('spliced in %s as parents of %s\n' % |
|
244 | self.ui.status('spliced in %s as parents of %s\n' % | |
@@ -263,7 +246,7 b' class converter(object):' | |||||
263 | parents = [self.map.get(p, p) for p in parents] |
|
246 | parents = [self.map.get(p, p) for p in parents] | |
264 | except KeyError: |
|
247 | except KeyError: | |
265 | parents = [b[0] for b in pbranches] |
|
248 | parents = [b[0] for b in pbranches] | |
266 |
newnode = self.dest.putcommit(file |
|
249 | newnode = self.dest.putcommit(files, copies, parents, commit, self.source) | |
267 | self.source.converted(rev, newnode) |
|
250 | self.source.converted(rev, newnode) | |
268 | self.map[rev] = newnode |
|
251 | self.map[rev] = newnode | |
269 |
|
252 |
@@ -72,21 +72,6 b' class mercurial_sink(converter_sink):' | |||||
72 | h = self.repo.changelog.heads() |
|
72 | h = self.repo.changelog.heads() | |
73 | return [ hex(x) for x in h ] |
|
73 | return [ hex(x) for x in h ] | |
74 |
|
74 | |||
75 | def putfile(self, f, e, data): |
|
|||
76 | self.repo.wwrite(f, data, e) |
|
|||
77 | if f not in self.repo.dirstate: |
|
|||
78 | self.repo.dirstate.normallookup(f) |
|
|||
79 |
|
||||
80 | def copyfile(self, source, dest): |
|
|||
81 | self.repo.copy(source, dest) |
|
|||
82 |
|
||||
83 | def delfile(self, f): |
|
|||
84 | try: |
|
|||
85 | util.unlink(self.repo.wjoin(f)) |
|
|||
86 | #self.repo.remove([f]) |
|
|||
87 | except OSError: |
|
|||
88 | pass |
|
|||
89 |
|
||||
90 | def setbranch(self, branch, pbranches): |
|
75 | def setbranch(self, branch, pbranches): | |
91 | if not self.clonebranches: |
|
76 | if not self.clonebranches: | |
92 | return |
|
77 | return | |
@@ -125,7 +110,25 b' class mercurial_sink(converter_sink):' | |||||
125 | self.repo.pull(prepo, [prepo.lookup(h) for h in heads]) |
|
110 | self.repo.pull(prepo, [prepo.lookup(h) for h in heads]) | |
126 | self.before() |
|
111 | self.before() | |
127 |
|
112 | |||
128 | def putcommit(self, files, parents, commit): |
|
113 | def putcommit(self, files, copies, parents, commit, source): | |
|
114 | # Apply changes to working copy | |||
|
115 | for f, v in files: | |||
|
116 | try: | |||
|
117 | data = source.getfile(f, v) | |||
|
118 | except IOError, inst: | |||
|
119 | try: | |||
|
120 | util.unlink(self.repo.wjoin(f)) | |||
|
121 | except OSError: | |||
|
122 | pass | |||
|
123 | else: | |||
|
124 | e = source.getmode(f, v) | |||
|
125 | self.repo.wwrite(f, data, e) | |||
|
126 | if f not in self.repo.dirstate: | |||
|
127 | self.repo.dirstate.normallookup(f) | |||
|
128 | if f in copies: | |||
|
129 | self.repo.copy(copies[f], f) | |||
|
130 | files = [f[0] for f in files] | |||
|
131 | ||||
129 | seen = {} |
|
132 | seen = {} | |
130 | pl = [] |
|
133 | pl = [] | |
131 | for p in parents: |
|
134 | for p in parents: |
@@ -1013,12 +1013,6 b' class svn_sink(converter_sink, commandli' | |||||
1013 | if 'x' in flags: |
|
1013 | if 'x' in flags: | |
1014 | self.setexec.append(filename) |
|
1014 | self.setexec.append(filename) | |
1015 |
|
1015 | |||
1016 | def delfile(self, name): |
|
|||
1017 | self.delete.append(name) |
|
|||
1018 |
|
||||
1019 | def copyfile(self, source, dest): |
|
|||
1020 | self.copies.append([source, dest]) |
|
|||
1021 |
|
||||
1022 | def _copyfile(self, source, dest): |
|
1016 | def _copyfile(self, source, dest): | |
1023 | # SVN's copy command pukes if the destination file exists, but |
|
1017 | # SVN's copy command pukes if the destination file exists, but | |
1024 | # our copyfile method expects to record a copy that has |
|
1018 | # our copyfile method expects to record a copy that has | |
@@ -1081,7 +1075,20 b' class svn_sink(converter_sink, commandli' | |||||
1081 | def revid(self, rev): |
|
1075 | def revid(self, rev): | |
1082 | return u"svn:%s@%s" % (self.uuid, rev) |
|
1076 | return u"svn:%s@%s" % (self.uuid, rev) | |
1083 |
|
1077 | |||
1084 | def putcommit(self, files, parents, commit): |
|
1078 | def putcommit(self, files, copies, parents, commit, source): | |
|
1079 | # Apply changes to working copy | |||
|
1080 | for f, v in files: | |||
|
1081 | try: | |||
|
1082 | data = source.getfile(f, v) | |||
|
1083 | except IOError, inst: | |||
|
1084 | self.delete.append(f) | |||
|
1085 | else: | |||
|
1086 | e = source.getmode(f, v) | |||
|
1087 | self.putfile(f, e, data) | |||
|
1088 | if f in copies: | |||
|
1089 | self.copies.append([copies[f], f]) | |||
|
1090 | files = [f[0] for f in files] | |||
|
1091 | ||||
1085 | for parent in parents: |
|
1092 | for parent in parents: | |
1086 | try: |
|
1093 | try: | |
1087 | return self.revid(self.childmap[parent]) |
|
1094 | return self.revid(self.childmap[parent]) |
General Comments 0
You need to be logged in to leave comments.
Login now