comparison contrib/convert-repo @ 1715:40346aa66b0f

Revert convert-repo changes
author Matt Mackall <mpm@selenic.com>
date Mon, 13 Feb 2006 12:48:28 -0600
parents 14d73fff4c45
children 5cc414722587
comparison
equal deleted inserted replaced
1714:eabfbd220f39 1715:40346aa66b0f
19 # 19 #
20 # This updates the mapfile on each commit copied, so it can be 20 # This updates the mapfile on each commit copied, so it can be
21 # interrupted and can be run repeatedly to copy new commits. 21 # interrupted and can be run repeatedly to copy new commits.
22 22
23 import sys, os, zlib, sha, time 23 import sys, os, zlib, sha, time
24 from mercurial import hg, ui, util, commands 24 from mercurial import hg, ui, util
25 25
26 class convert_git: 26 class convert_git:
27 def __init__(self, path): 27 def __init__(self, path):
28 self.path = path 28 self.path = path
29 29
111 os.unlink(self.repo.wjoin(f)) 111 os.unlink(self.repo.wjoin(f))
112 #self.repo.remove([f]) 112 #self.repo.remove([f])
113 except: 113 except:
114 pass 114 pass
115 115
116 def putcommit(self, files, parents, author, date, text): 116 def putcommit(self, files, parents, author, dest, text):
117 seen = {} 117 seen = {}
118 pl = [] 118 pl = []
119 for p in parents: 119 for p in parents:
120 if p not in seen: 120 if p not in seen:
121 pl.append(p) 121 pl.append(p)
127 p2 = parents.pop(0) 127 p2 = parents.pop(0)
128 128
129 while parents: 129 while parents:
130 p1 = p2 130 p1 = p2
131 p2 = parents.pop(0) 131 p2 = parents.pop(0)
132 self.repo.dirstate.setparents(hg.bin(p1), hg.bin(p2)) 132 self.repo.rawcommit(files, text, author, dest,
133 if len(files) > 0: 133 hg.bin(p1), hg.bin(p2))
134 olddir = os.getcwd()
135 os.chdir(self.path)
136 commands.addremove(self.repo.ui, self.repo, *files)
137 os.chdir(olddir)
138 self.repo.commit(files, text, author, date)
139 text = "(octopus merge fixup)\n" 134 text = "(octopus merge fixup)\n"
140 p2 = hg.hex(self.repo.changelog.tip()) 135 p2 = hg.hex(self.repo.changelog.tip())
141 136
142 return p2 137 return p2
143 138
263 heads = self.source.getheads() 258 heads = self.source.getheads()
264 parents = self.walktree(heads) 259 parents = self.walktree(heads)
265 t = self.toposort(parents) 260 t = self.toposort(parents)
266 t = [n for n in t if n not in self.map] 261 t = [n for n in t if n not in self.map]
267 num = len(t) 262 num = len(t)
263 c = None
268 264
269 for c in t: 265 for c in t:
270 num -= 1 266 num -= 1
271 desc = self.commitcache[c][3].splitlines()[0] 267 desc = self.commitcache[c][3].splitlines()[0]
272 #print num, desc 268 #print num, desc
277 for k in tags: 273 for k in tags:
278 v = tags[k] 274 v = tags[k]
279 if v in self.map: 275 if v in self.map:
280 ctags[k] = self.map[v] 276 ctags[k] = self.map[v]
281 277
282 if ctags: 278 if c and ctags:
283 nrev = self.dest.puttags(ctags) 279 nrev = self.dest.puttags(ctags)
284 # write another hash correspondence to override the previous 280 # write another hash correspondence to override the previous
285 # one so we don't end up with extra tag heads 281 # one so we don't end up with extra tag heads
286 file(self.mapfile, "a").write("%s %s\n" % (c, nrev)) 282 file(self.mapfile, "a").write("%s %s\n" % (c, nrev))
287 283