##// END OF EJS Templates
convert: look up copies in getchanges instead of getcommit...
Brendan Cully -
r5121:ef338e34 default
parent child Browse files
Show More
@@ -193,7 +193,8 b' class convert(object):'
193 do_copies = hasattr(self.dest, 'copyfile')
193 do_copies = hasattr(self.dest, 'copyfile')
194 filenames = []
194 filenames = []
195
195
196 for f, v in self.source.getchanges(rev):
196 files, copies = self.source.getchanges(rev)
197 for f, v in files:
197 newf = self.mapfile(f)
198 newf = self.mapfile(f)
198 if not newf:
199 if not newf:
199 continue
200 continue
@@ -206,8 +207,8 b' class convert(object):'
206 e = self.source.getmode(f, v)
207 e = self.source.getmode(f, v)
207 self.dest.putfile(newf, e, data)
208 self.dest.putfile(newf, e, data)
208 if do_copies:
209 if do_copies:
209 if f in commit.copies:
210 if f in copies:
210 copyf = self.mapfile(commit.copies[f])
211 copyf = self.mapfile(copies[f])
211 if copyf:
212 if copyf:
212 # Merely marks that a copy happened.
213 # Merely marks that a copy happened.
213 self.dest.copyfile(copyf, newf)
214 self.dest.copyfile(copyf, newf)
@@ -3,15 +3,13 b''
3 class NoRepo(Exception): pass
3 class NoRepo(Exception): pass
4
4
5 class commit(object):
5 class commit(object):
6 def __init__(self, author, date, desc, parents, branch=None, rev=None,
6 def __init__(self, author, date, desc, parents, branch=None, rev=None):
7 copies={}):
8 self.author = author
7 self.author = author
9 self.date = date
8 self.date = date
10 self.desc = desc
9 self.desc = desc
11 self.parents = parents
10 self.parents = parents
12 self.branch = branch
11 self.branch = branch
13 self.rev = rev
12 self.rev = rev
14 self.copies = copies
15
13
16 class converter_source(object):
14 class converter_source(object):
17 """Conversion source interface"""
15 """Conversion source interface"""
@@ -42,10 +40,12 b' class converter_source(object):'
42 raise NotImplementedError()
40 raise NotImplementedError()
43
41
44 def getchanges(self, version):
42 def getchanges(self, version):
45 """Return sorted list of (filename, id) tuples for all files changed in rev.
43 """Returns a tuple of (files, copies)
44 Files is a sorted list of (filename, id) tuples for all files changed
45 in version, where id is the source revision id of the file.
46
46
47 id just tells us which revision to return in getfile(), e.g. in
47 copies is a dictionary of dest: source
48 git it's an object hash."""
48 """
49 raise NotImplementedError()
49 raise NotImplementedError()
50
50
51 def getcommit(self, version):
51 def getcommit(self, version):
@@ -250,7 +250,7 b' class convert_cvs(converter_source):'
250 files = self.files[rev]
250 files = self.files[rev]
251 cl = files.items()
251 cl = files.items()
252 cl.sort()
252 cl.sort()
253 return cl
253 return (cl, {})
254
254
255 def getcommit(self, rev):
255 def getcommit(self, rev):
256 return self.changeset[rev]
256 return self.changeset[rev]
@@ -48,7 +48,7 b' class convert_git(converter_source):'
48 s = (m[1] == "120000")
48 s = (m[1] == "120000")
49 self.modecache[(f, h)] = (p and "x") or (s and "l") or ""
49 self.modecache[(f, h)] = (p and "x") or (s and "l") or ""
50 changes.append((f, h))
50 changes.append((f, h))
51 return changes
51 return (changes, {})
52
52
53 def getcommit(self, version):
53 def getcommit(self, version):
54 c = self.catfile(version, "commit") # read the commit hash
54 c = self.catfile(version, "commit") # read the commit hash
@@ -151,7 +151,7 b' class mercurial_source(converter_source)'
151 m, a, r = self.repo.status(ctx.parents()[0].node(), ctx.node())[:3]
151 m, a, r = self.repo.status(ctx.parents()[0].node(), ctx.node())[:3]
152 changes = [(name, rev) for name in m + a + r]
152 changes = [(name, rev) for name in m + a + r]
153 changes.sort()
153 changes.sort()
154 return changes
154 return (changes, self.getcopies(ctx))
155
155
156 def getcopies(self, ctx):
156 def getcopies(self, ctx):
157 added = self.repo.status(ctx.parents()[0].node(), ctx.node())[1]
157 added = self.repo.status(ctx.parents()[0].node(), ctx.node())[1]
@@ -168,7 +168,7 b' class mercurial_source(converter_source)'
168 parents = [hex(p.node()) for p in ctx.parents() if p.node() != nullid]
168 parents = [hex(p.node()) for p in ctx.parents() if p.node() != nullid]
169 return commit(author=ctx.user(), date=util.datestr(ctx.date()),
169 return commit(author=ctx.user(), date=util.datestr(ctx.date()),
170 desc=ctx.description(), parents=parents,
170 desc=ctx.description(), parents=parents,
171 branch=ctx.branch(), copies=self.getcopies(ctx))
171 branch=ctx.branch())
172
172
173 def gettags(self):
173 def gettags(self):
174 tags = [t for t in self.repo.tagslist() if t[0] != 'tip']
174 tags = [t for t in self.repo.tagslist() if t[0] != 'tip']
@@ -98,7 +98,7 b' class convert_svn(converter_source):'
98 self.module = self.url[len(self.base):]
98 self.module = self.url[len(self.base):]
99 self.modulemap = {} # revision, module
99 self.modulemap = {} # revision, module
100 self.commits = {}
100 self.commits = {}
101 self.files = {}
101 self.paths = {}
102 self.uuid = svn.ra.get_uuid(self.ra).decode(self.encoding)
102 self.uuid = svn.ra.get_uuid(self.ra).decode(self.encoding)
103 except SubversionException, e:
103 except SubversionException, e:
104 raise NoRepo("couldn't open SVN repo %s" % self.url)
104 raise NoRepo("couldn't open SVN repo %s" % self.url)
@@ -173,12 +173,14 b' class convert_svn(converter_source):'
173
173
174 def getchanges(self, rev):
174 def getchanges(self, rev):
175 self.modecache = {}
175 self.modecache = {}
176 files = self.files[rev]
176 (paths, parents) = self.paths[rev]
177 cl = files
177 files, copies = self.expandpaths(rev, paths, parents)
178 cl.sort()
178 files.sort()
179 files = zip(files, [rev] * len(files))
180
179 # caller caches the result, so free it here to release memory
181 # caller caches the result, so free it here to release memory
180 del self.files[rev]
182 del self.paths[rev]
181 return cl
183 return (files, copies)
182
184
183 def getcommit(self, rev):
185 def getcommit(self, rev):
184 if rev not in self.commits:
186 if rev not in self.commits:
@@ -350,8 +352,14 b' class convert_svn(converter_source):'
350 copies = {}
352 copies = {}
351 revnum = self.revnum(rev)
353 revnum = self.revnum(rev)
352
354
355 if revnum in self.modulemap:
356 new_module = self.modulemap[revnum]
357 if new_module != self.module:
358 self.module = new_module
359 self.reparent(self.module)
360
353 for path, ent in paths:
361 for path, ent in paths:
354 # self.ui.write("path %s\n" % path)
362 self.ui.write("path %s\n" % path)
355 entrypath = get_entry_from_path(path, module=self.module)
363 entrypath = get_entry_from_path(path, module=self.module)
356 entry = entrypath.decode(self.encoding)
364 entry = entrypath.decode(self.encoding)
357
365
@@ -554,12 +562,7 b' class convert_svn(converter_source):'
554 continue
562 continue
555 paths.append((path, ent))
563 paths.append((path, ent))
556
564
557 entries, copies = self.expandpaths(rev, paths, parents)
565 self.paths[rev] = (paths, parents)
558 # a list of (filename, id) where id lets us retrieve the file.
559 # eg in git, id is the object hash. for svn it'll be the
560 self.files[rev] = zip(entries, [rev] * len(entries))
561 if not entries:
562 return
563
566
564 # Example SVN datetime. Includes microseconds.
567 # Example SVN datetime. Includes microseconds.
565 # ISO-8601 conformant
568 # ISO-8601 conformant
@@ -579,7 +582,6 b' class convert_svn(converter_source):'
579 date=util.datestr(date),
582 date=util.datestr(date),
580 desc=log,
583 desc=log,
581 parents=parents,
584 parents=parents,
582 copies=copies,
583 branch=branch,
585 branch=branch,
584 rev=rev.encode('utf-8'))
586 rev=rev.encode('utf-8'))
585
587
General Comments 0
You need to be logged in to leave comments. Login now