##// END OF EJS Templates
convert: hg sink commits without working dir
Patrick Mezard -
r6717:2011bb8a default
parent child Browse files
Show More
@@ -1,305 +1,290
1 # hg backend for convert extension
1 # hg backend for convert extension
2
2
3 # Notes for hg->hg conversion:
3 # Notes for hg->hg conversion:
4 #
4 #
5 # * Old versions of Mercurial didn't trim the whitespace from the ends
5 # * Old versions of Mercurial didn't trim the whitespace from the ends
6 # of commit messages, but new versions do. Changesets created by
6 # of commit messages, but new versions do. Changesets created by
7 # those older versions, then converted, may thus have different
7 # those older versions, then converted, may thus have different
8 # hashes for changesets that are otherwise identical.
8 # hashes for changesets that are otherwise identical.
9 #
9 #
10 # * By default, the source revision is stored in the converted
10 # * By default, the source revision is stored in the converted
11 # revision. This will cause the converted revision to have a
11 # revision. This will cause the converted revision to have a
12 # different identity than the source. To avoid this, use the
12 # different identity than the source. To avoid this, use the
13 # following option: "--config convert.hg.saverev=false"
13 # following option: "--config convert.hg.saverev=false"
14
14
15
15
16 import os, time
16 import os, time
17 from mercurial.i18n import _
17 from mercurial.i18n import _
18 from mercurial.repo import RepoError
18 from mercurial.repo import RepoError
19 from mercurial.node import bin, hex, nullid
19 from mercurial.node import bin, hex, nullid
20 from mercurial import hg, revlog, util
20 from mercurial import hg, revlog, util, context
21
21
22 from common import NoRepo, commit, converter_source, converter_sink
22 from common import NoRepo, commit, converter_source, converter_sink
23
23
24 class mercurial_sink(converter_sink):
24 class mercurial_sink(converter_sink):
25 def __init__(self, ui, path):
25 def __init__(self, ui, path):
26 converter_sink.__init__(self, ui, path)
26 converter_sink.__init__(self, ui, path)
27 self.branchnames = ui.configbool('convert', 'hg.usebranchnames', True)
27 self.branchnames = ui.configbool('convert', 'hg.usebranchnames', True)
28 self.clonebranches = ui.configbool('convert', 'hg.clonebranches', False)
28 self.clonebranches = ui.configbool('convert', 'hg.clonebranches', False)
29 self.tagsbranch = ui.config('convert', 'hg.tagsbranch', 'default')
29 self.tagsbranch = ui.config('convert', 'hg.tagsbranch', 'default')
30 self.lastbranch = None
30 self.lastbranch = None
31 if os.path.isdir(path) and len(os.listdir(path)) > 0:
31 if os.path.isdir(path) and len(os.listdir(path)) > 0:
32 try:
32 try:
33 self.repo = hg.repository(self.ui, path)
33 self.repo = hg.repository(self.ui, path)
34 if not self.repo.local():
34 if not self.repo.local():
35 raise NoRepo(_('%s is not a local Mercurial repo') % path)
35 raise NoRepo(_('%s is not a local Mercurial repo') % path)
36 except RepoError, err:
36 except RepoError, err:
37 ui.print_exc()
37 ui.print_exc()
38 raise NoRepo(err.args[0])
38 raise NoRepo(err.args[0])
39 else:
39 else:
40 try:
40 try:
41 ui.status(_('initializing destination %s repository\n') % path)
41 ui.status(_('initializing destination %s repository\n') % path)
42 self.repo = hg.repository(self.ui, path, create=True)
42 self.repo = hg.repository(self.ui, path, create=True)
43 if not self.repo.local():
43 if not self.repo.local():
44 raise NoRepo(_('%s is not a local Mercurial repo') % path)
44 raise NoRepo(_('%s is not a local Mercurial repo') % path)
45 self.created.append(path)
45 self.created.append(path)
46 except RepoError, err:
46 except RepoError, err:
47 ui.print_exc()
47 ui.print_exc()
48 raise NoRepo("could not create hg repo %s as sink" % path)
48 raise NoRepo("could not create hg repo %s as sink" % path)
49 self.lock = None
49 self.lock = None
50 self.wlock = None
50 self.wlock = None
51 self.filemapmode = False
51 self.filemapmode = False
52
52
53 def before(self):
53 def before(self):
54 self.ui.debug(_('run hg sink pre-conversion action\n'))
54 self.ui.debug(_('run hg sink pre-conversion action\n'))
55 self.wlock = self.repo.wlock()
55 self.wlock = self.repo.wlock()
56 self.lock = self.repo.lock()
56 self.lock = self.repo.lock()
57 self.repo.dirstate.clear()
58
57
59 def after(self):
58 def after(self):
60 self.ui.debug(_('run hg sink post-conversion action\n'))
59 self.ui.debug(_('run hg sink post-conversion action\n'))
61 self.repo.dirstate.invalidate()
62 self.lock = None
60 self.lock = None
63 self.wlock = None
61 self.wlock = None
64
62
65 def revmapfile(self):
63 def revmapfile(self):
66 return os.path.join(self.path, ".hg", "shamap")
64 return os.path.join(self.path, ".hg", "shamap")
67
65
68 def authorfile(self):
66 def authorfile(self):
69 return os.path.join(self.path, ".hg", "authormap")
67 return os.path.join(self.path, ".hg", "authormap")
70
68
71 def getheads(self):
69 def getheads(self):
72 h = self.repo.changelog.heads()
70 h = self.repo.changelog.heads()
73 return [ hex(x) for x in h ]
71 return [ hex(x) for x in h ]
74
72
75 def setbranch(self, branch, pbranches):
73 def setbranch(self, branch, pbranches):
76 if not self.clonebranches:
74 if not self.clonebranches:
77 return
75 return
78
76
79 setbranch = (branch != self.lastbranch)
77 setbranch = (branch != self.lastbranch)
80 self.lastbranch = branch
78 self.lastbranch = branch
81 if not branch:
79 if not branch:
82 branch = 'default'
80 branch = 'default'
83 pbranches = [(b[0], b[1] and b[1] or 'default') for b in pbranches]
81 pbranches = [(b[0], b[1] and b[1] or 'default') for b in pbranches]
84 pbranch = pbranches and pbranches[0][1] or 'default'
82 pbranch = pbranches and pbranches[0][1] or 'default'
85
83
86 branchpath = os.path.join(self.path, branch)
84 branchpath = os.path.join(self.path, branch)
87 if setbranch:
85 if setbranch:
88 self.after()
86 self.after()
89 try:
87 try:
90 self.repo = hg.repository(self.ui, branchpath)
88 self.repo = hg.repository(self.ui, branchpath)
91 except:
89 except:
92 self.repo = hg.repository(self.ui, branchpath, create=True)
90 self.repo = hg.repository(self.ui, branchpath, create=True)
93 self.before()
91 self.before()
94
92
95 # pbranches may bring revisions from other branches (merge parents)
93 # pbranches may bring revisions from other branches (merge parents)
96 # Make sure we have them, or pull them.
94 # Make sure we have them, or pull them.
97 missings = {}
95 missings = {}
98 for b in pbranches:
96 for b in pbranches:
99 try:
97 try:
100 self.repo.lookup(b[0])
98 self.repo.lookup(b[0])
101 except:
99 except:
102 missings.setdefault(b[1], []).append(b[0])
100 missings.setdefault(b[1], []).append(b[0])
103
101
104 if missings:
102 if missings:
105 self.after()
103 self.after()
106 for pbranch, heads in missings.iteritems():
104 for pbranch, heads in missings.iteritems():
107 pbranchpath = os.path.join(self.path, pbranch)
105 pbranchpath = os.path.join(self.path, pbranch)
108 prepo = hg.repository(self.ui, pbranchpath)
106 prepo = hg.repository(self.ui, pbranchpath)
109 self.ui.note(_('pulling from %s into %s\n') % (pbranch, branch))
107 self.ui.note(_('pulling from %s into %s\n') % (pbranch, branch))
110 self.repo.pull(prepo, [prepo.lookup(h) for h in heads])
108 self.repo.pull(prepo, [prepo.lookup(h) for h in heads])
111 self.before()
109 self.before()
112
110
113 def putcommit(self, files, copies, parents, commit, source):
111 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
112
132 seen = {}
113 files = dict(files)
114 def getfilectx(repo, memctx, f):
115 v = files[f]
116 data = source.getfile(f, v)
117 e = source.getmode(f, v)
118 return context.memfilectx(f, data, 'l' in e, 'x' in e, copies.get(f))
119
133 pl = []
120 pl = []
134 for p in parents:
121 for p in parents:
135 if p not in seen:
122 if p not in pl:
136 pl.append(p)
123 pl.append(p)
137 seen[p] = 1
138 parents = pl
124 parents = pl
139 nparents = len(parents)
125 nparents = len(parents)
140 if self.filemapmode and nparents == 1:
126 if self.filemapmode and nparents == 1:
141 m1node = self.repo.changelog.read(bin(parents[0]))[0]
127 m1node = self.repo.changelog.read(bin(parents[0]))[0]
142 parent = parents[0]
128 parent = parents[0]
143
129
144 if len(parents) < 2: parents.append("0" * 40)
130 if len(parents) < 2: parents.append("0" * 40)
145 if len(parents) < 2: parents.append("0" * 40)
131 if len(parents) < 2: parents.append("0" * 40)
146 p2 = parents.pop(0)
132 p2 = parents.pop(0)
147
133
148 text = commit.desc
134 text = commit.desc
149 extra = commit.extra.copy()
135 extra = commit.extra.copy()
150 if self.branchnames and commit.branch:
136 if self.branchnames and commit.branch:
151 extra['branch'] = commit.branch
137 extra['branch'] = commit.branch
152 if commit.rev:
138 if commit.rev:
153 extra['convert_revision'] = commit.rev
139 extra['convert_revision'] = commit.rev
154
140
155 while parents:
141 while parents:
156 p1 = p2
142 p1 = p2
157 p2 = parents.pop(0)
143 p2 = parents.pop(0)
158 a = self.repo.rawcommit(files, text, commit.author, commit.date,
144 ctx = context.memctx(self.repo, (p1, p2), text, files.keys(), getfilectx,
159 bin(p1), bin(p2), extra=extra)
145 commit.author, commit.date, extra)
160 self.repo.dirstate.clear()
146 a = self.repo.commitctx(ctx)
161 text = "(octopus merge fixup)\n"
147 text = "(octopus merge fixup)\n"
162 p2 = hex(self.repo.changelog.tip())
148 p2 = hex(self.repo.changelog.tip())
163
149
164 if self.filemapmode and nparents == 1:
150 if self.filemapmode and nparents == 1:
165 man = self.repo.manifest
151 man = self.repo.manifest
166 mnode = self.repo.changelog.read(bin(p2))[0]
152 mnode = self.repo.changelog.read(bin(p2))[0]
167 if not man.cmp(m1node, man.revision(mnode)):
153 if not man.cmp(m1node, man.revision(mnode)):
168 self.repo.rollback()
154 self.repo.rollback()
169 self.repo.dirstate.clear()
170 return parent
155 return parent
171 return p2
156 return p2
172
157
173 def puttags(self, tags):
158 def puttags(self, tags):
174 try:
159 try:
175 old = self.repo.wfile(".hgtags").read()
160 parentctx = self.repo.changectx(self.tagsbranch)
176 oldlines = old.splitlines(1)
161 tagparent = parentctx.node()
177 oldlines.sort()
162 except RepoError, inst:
178 except:
163 parentctx = None
179 oldlines = []
164 tagparent = nullid
180
165
181 k = tags.keys()
166 try:
182 k.sort()
167 old = parentctx.filectx(".hgtags").data()
183 newlines = []
168 oldlines = old.splitlines(1)
184 for tag in k:
169 oldlines.sort()
185 newlines.append("%s %s\n" % (tags[tag], tag))
170 except:
186
171 oldlines = []
187 newlines.sort()
188
172
189 if newlines != oldlines:
173 newlines = [("%s %s\n" % (tags[tag], tag)) for tag in tags.keys()]
190 self.ui.status("updating tags\n")
174 newlines.sort()
191 f = self.repo.wfile(".hgtags", "w")
175
192 f.write("".join(newlines))
176 if newlines == oldlines:
193 f.close()
177 return None
194 if not oldlines: self.repo.add([".hgtags"])
178 data = "".join(newlines)
195 date = "%s 0" % int(time.mktime(time.gmtime()))
179
196 extra = {}
180 def getfilectx(repo, memctx, f):
197 if self.tagsbranch != 'default':
181 return context.memfilectx(f, data, False, False, None)
198 extra['branch'] = self.tagsbranch
182
199 try:
183 self.ui.status("updating tags\n")
200 tagparent = self.repo.changectx(self.tagsbranch).node()
184 date = "%s 0" % int(time.mktime(time.gmtime()))
201 except RepoError, inst:
185 extra = {'branch': self.tagsbranch}
202 tagparent = nullid
186 ctx = context.memctx(self.repo, (tagparent, None), "update tags",
203 self.repo.rawcommit([".hgtags"], "update tags", "convert-repo",
187 [".hgtags"], getfilectx, "convert-repo", date,
204 date, tagparent, nullid, extra=extra)
188 extra)
205 return hex(self.repo.changelog.tip())
189 self.repo.commitctx(ctx)
190 return hex(self.repo.changelog.tip())
206
191
207 def setfilemapmode(self, active):
192 def setfilemapmode(self, active):
208 self.filemapmode = active
193 self.filemapmode = active
209
194
210 class mercurial_source(converter_source):
195 class mercurial_source(converter_source):
211 def __init__(self, ui, path, rev=None):
196 def __init__(self, ui, path, rev=None):
212 converter_source.__init__(self, ui, path, rev)
197 converter_source.__init__(self, ui, path, rev)
213 self.saverev = ui.configbool('convert', 'hg.saverev', True)
198 self.saverev = ui.configbool('convert', 'hg.saverev', True)
214 try:
199 try:
215 self.repo = hg.repository(self.ui, path)
200 self.repo = hg.repository(self.ui, path)
216 # try to provoke an exception if this isn't really a hg
201 # try to provoke an exception if this isn't really a hg
217 # repo, but some other bogus compatible-looking url
202 # repo, but some other bogus compatible-looking url
218 if not self.repo.local():
203 if not self.repo.local():
219 raise RepoError()
204 raise RepoError()
220 except RepoError:
205 except RepoError:
221 ui.print_exc()
206 ui.print_exc()
222 raise NoRepo("%s is not a local Mercurial repo" % path)
207 raise NoRepo("%s is not a local Mercurial repo" % path)
223 self.lastrev = None
208 self.lastrev = None
224 self.lastctx = None
209 self.lastctx = None
225 self._changescache = None
210 self._changescache = None
226 self.convertfp = None
211 self.convertfp = None
227
212
228 def changectx(self, rev):
213 def changectx(self, rev):
229 if self.lastrev != rev:
214 if self.lastrev != rev:
230 self.lastctx = self.repo.changectx(rev)
215 self.lastctx = self.repo.changectx(rev)
231 self.lastrev = rev
216 self.lastrev = rev
232 return self.lastctx
217 return self.lastctx
233
218
234 def getheads(self):
219 def getheads(self):
235 if self.rev:
220 if self.rev:
236 return [hex(self.repo.changectx(self.rev).node())]
221 return [hex(self.repo.changectx(self.rev).node())]
237 else:
222 else:
238 return [hex(node) for node in self.repo.heads()]
223 return [hex(node) for node in self.repo.heads()]
239
224
240 def getfile(self, name, rev):
225 def getfile(self, name, rev):
241 try:
226 try:
242 return self.changectx(rev).filectx(name).data()
227 return self.changectx(rev).filectx(name).data()
243 except revlog.LookupError, err:
228 except revlog.LookupError, err:
244 raise IOError(err)
229 raise IOError(err)
245
230
246 def getmode(self, name, rev):
231 def getmode(self, name, rev):
247 m = self.changectx(rev).manifest()
232 m = self.changectx(rev).manifest()
248 return (m.execf(name) and 'x' or '') + (m.linkf(name) and 'l' or '')
233 return (m.execf(name) and 'x' or '') + (m.linkf(name) and 'l' or '')
249
234
250 def getchanges(self, rev):
235 def getchanges(self, rev):
251 ctx = self.changectx(rev)
236 ctx = self.changectx(rev)
252 if self._changescache and self._changescache[0] == rev:
237 if self._changescache and self._changescache[0] == rev:
253 m, a, r = self._changescache[1]
238 m, a, r = self._changescache[1]
254 else:
239 else:
255 m, a, r = self.repo.status(ctx.parents()[0].node(), ctx.node())[:3]
240 m, a, r = self.repo.status(ctx.parents()[0].node(), ctx.node())[:3]
256 changes = [(name, rev) for name in m + a + r]
241 changes = [(name, rev) for name in m + a + r]
257 changes.sort()
242 changes.sort()
258 return (changes, self.getcopies(ctx, m + a))
243 return (changes, self.getcopies(ctx, m + a))
259
244
260 def getcopies(self, ctx, files):
245 def getcopies(self, ctx, files):
261 copies = {}
246 copies = {}
262 for name in files:
247 for name in files:
263 try:
248 try:
264 copies[name] = ctx.filectx(name).renamed()[0]
249 copies[name] = ctx.filectx(name).renamed()[0]
265 except TypeError:
250 except TypeError:
266 pass
251 pass
267 return copies
252 return copies
268
253
269 def getcommit(self, rev):
254 def getcommit(self, rev):
270 ctx = self.changectx(rev)
255 ctx = self.changectx(rev)
271 parents = [hex(p.node()) for p in ctx.parents() if p.node() != nullid]
256 parents = [hex(p.node()) for p in ctx.parents() if p.node() != nullid]
272 if self.saverev:
257 if self.saverev:
273 crev = rev
258 crev = rev
274 else:
259 else:
275 crev = None
260 crev = None
276 return commit(author=ctx.user(), date=util.datestr(ctx.date()),
261 return commit(author=ctx.user(), date=util.datestr(ctx.date()),
277 desc=ctx.description(), rev=crev, parents=parents,
262 desc=ctx.description(), rev=crev, parents=parents,
278 branch=ctx.branch(), extra=ctx.extra())
263 branch=ctx.branch(), extra=ctx.extra())
279
264
280 def gettags(self):
265 def gettags(self):
281 tags = [t for t in self.repo.tagslist() if t[0] != 'tip']
266 tags = [t for t in self.repo.tagslist() if t[0] != 'tip']
282 return dict([(name, hex(node)) for name, node in tags])
267 return dict([(name, hex(node)) for name, node in tags])
283
268
284 def getchangedfiles(self, rev, i):
269 def getchangedfiles(self, rev, i):
285 ctx = self.changectx(rev)
270 ctx = self.changectx(rev)
286 i = i or 0
271 i = i or 0
287 changes = self.repo.status(ctx.parents()[i].node(), ctx.node())[:3]
272 changes = self.repo.status(ctx.parents()[i].node(), ctx.node())[:3]
288
273
289 if i == 0:
274 if i == 0:
290 self._changescache = (rev, changes)
275 self._changescache = (rev, changes)
291
276
292 return changes[0] + changes[1] + changes[2]
277 return changes[0] + changes[1] + changes[2]
293
278
294 def converted(self, rev, destrev):
279 def converted(self, rev, destrev):
295 if self.convertfp is None:
280 if self.convertfp is None:
296 self.convertfp = open(os.path.join(self.path, '.hg', 'shamap'),
281 self.convertfp = open(os.path.join(self.path, '.hg', 'shamap'),
297 'a')
282 'a')
298 self.convertfp.write('%s %s\n' % (destrev, rev))
283 self.convertfp.write('%s %s\n' % (destrev, rev))
299 self.convertfp.flush()
284 self.convertfp.flush()
300
285
301 def before(self):
286 def before(self):
302 self.ui.debug(_('run hg source pre-conversion action\n'))
287 self.ui.debug(_('run hg source pre-conversion action\n'))
303
288
304 def after(self):
289 def after(self):
305 self.ui.debug(_('run hg source post-conversion action\n'))
290 self.ui.debug(_('run hg source post-conversion action\n'))
@@ -1,96 +1,101
1 #!/bin/sh
1 #!/bin/sh
2
2
3 "$TESTDIR/hghave" cvs cvsps || exit 80
3 "$TESTDIR/hghave" cvs cvsps || exit 80
4
4
5 cvscall()
5 cvscall()
6 {
6 {
7 cvs -f $@
7 cvs -f $@
8 }
8 }
9
9
10 hgcat()
11 {
12 hg --cwd src-hg cat -r tip "$1"
13 }
14
10 echo "[extensions]" >> $HGRCPATH
15 echo "[extensions]" >> $HGRCPATH
11 echo "convert = " >> $HGRCPATH
16 echo "convert = " >> $HGRCPATH
12
17
13 echo % create cvs repository
18 echo % create cvs repository
14 mkdir cvsrepo
19 mkdir cvsrepo
15 cd cvsrepo
20 cd cvsrepo
16 export CVSROOT=`pwd`
21 export CVSROOT=`pwd`
17 export CVS_OPTIONS=-f
22 export CVS_OPTIONS=-f
18 cd ..
23 cd ..
19
24
20 cvscall -q -d "$CVSROOT" init
25 cvscall -q -d "$CVSROOT" init
21
26
22 echo % create source directory
27 echo % create source directory
23 mkdir src-temp
28 mkdir src-temp
24 cd src-temp
29 cd src-temp
25 echo a > a
30 echo a > a
26 mkdir b
31 mkdir b
27 cd b
32 cd b
28 echo c > c
33 echo c > c
29 cd ..
34 cd ..
30
35
31 echo % import source directory
36 echo % import source directory
32 cvscall -q import -m import src INITIAL start
37 cvscall -q import -m import src INITIAL start
33 cd ..
38 cd ..
34
39
35 echo % checkout source directory
40 echo % checkout source directory
36 cvscall -q checkout src
41 cvscall -q checkout src
37
42
38 echo % commit a new revision changing b/c
43 echo % commit a new revision changing b/c
39 cd src
44 cd src
40 sleep 1
45 sleep 1
41 echo c >> b/c
46 echo c >> b/c
42 cvscall -q commit -mci0 . | grep '<--' |\
47 cvscall -q commit -mci0 . | grep '<--' |\
43 sed -e 's:.*src/\(.*\),v.*:checking in src/\1,v:g'
48 sed -e 's:.*src/\(.*\),v.*:checking in src/\1,v:g'
44 cd ..
49 cd ..
45
50
46 echo % convert fresh repo
51 echo % convert fresh repo
47 hg convert src src-hg | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g'
52 hg convert src src-hg | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g'
48 cat src-hg/a
53 hgcat a
49 cat src-hg/b/c
54 hgcat b/c
50
55
51 echo % convert fresh repo with --filemap
56 echo % convert fresh repo with --filemap
52 echo include b/c > filemap
57 echo include b/c > filemap
53 hg convert --filemap filemap src src-filemap | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g'
58 hg convert --filemap filemap src src-filemap | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g'
54 cat src-hg/b/c
59 hgcat b/c
55 hg -R src-filemap log --template '#rev# #desc# files: #files#\n'
60 hg -R src-filemap log --template '#rev# #desc# files: #files#\n'
56
61
57 echo % commit new file revisions
62 echo % commit new file revisions
58 cd src
63 cd src
59 echo a >> a
64 echo a >> a
60 echo c >> b/c
65 echo c >> b/c
61 cvscall -q commit -mci1 . | grep '<--' |\
66 cvscall -q commit -mci1 . | grep '<--' |\
62 sed -e 's:.*src/\(.*\),v.*:checking in src/\1,v:g'
67 sed -e 's:.*src/\(.*\),v.*:checking in src/\1,v:g'
63 cd ..
68 cd ..
64
69
65 echo % convert again
70 echo % convert again
66 hg convert src src-hg | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g'
71 hg convert src src-hg | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g'
67 cat src-hg/a
72 hgcat a
68 cat src-hg/b/c
73 hgcat b/c
69
74
70 echo % convert again with --filemap
75 echo % convert again with --filemap
71 hg convert --filemap filemap src src-filemap | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g'
76 hg convert --filemap filemap src src-filemap | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g'
72 cat src-hg/b/c
77 hgcat b/c
73 hg -R src-filemap log --template '#rev# #desc# files: #files#\n'
78 hg -R src-filemap log --template '#rev# #desc# files: #files#\n'
74
79
75 echo % commit branch
80 echo % commit branch
76 cd src
81 cd src
77 cvs -q update -r1.1 b/c
82 cvs -q update -r1.1 b/c
78 cvs -q tag -b branch
83 cvs -q tag -b branch
79 cvs -q update -r branch
84 cvs -q update -r branch
80 echo d >> b/c
85 echo d >> b/c
81 cvs -q commit -mci2 . | grep '<--' |\
86 cvs -q commit -mci2 . | grep '<--' |\
82 sed -e 's:.*src/\(.*\),v.*:checking in src/\1,v:g'
87 sed -e 's:.*src/\(.*\),v.*:checking in src/\1,v:g'
83 cd ..
88 cd ..
84
89
85 echo % convert again
90 echo % convert again
86 hg convert src src-hg | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g'
91 hg convert src src-hg | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g'
87 cat src-hg/a
92 hgcat a
88 cat src-hg/b/c
93 hgcat b/c
89
94
90 echo % convert again with --filemap
95 echo % convert again with --filemap
91 hg convert --filemap filemap src src-filemap | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g'
96 hg convert --filemap filemap src src-filemap | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g'
92 cat src-hg/b/c
97 hgcat b/c
93 hg -R src-filemap log --template '#rev# #desc# files: #files#\n'
98 hg -R src-filemap log --template '#rev# #desc# files: #files#\n'
94
99
95 echo "graphlog = " >> $HGRCPATH
100 echo "graphlog = " >> $HGRCPATH
96 hg -R src-hg glog --template '#rev# (#branches#) #desc# files: #files#\n'
101 hg -R src-hg glog --template '#rev# (#branches#) #desc# files: #files#\n'
@@ -1,99 +1,104
1 #!/bin/sh
1 #!/bin/sh
2
2
3 "$TESTDIR/hghave" cvs || exit 80
3 "$TESTDIR/hghave" cvs || exit 80
4
4
5 cvscall()
5 cvscall()
6 {
6 {
7 cvs -f "$@"
7 cvs -f "$@"
8 }
8 }
9
9
10 hgcat()
11 {
12 hg --cwd src-hg cat -r tip "$1"
13 }
14
10 echo "[extensions]" >> $HGRCPATH
15 echo "[extensions]" >> $HGRCPATH
11 echo "convert = " >> $HGRCPATH
16 echo "convert = " >> $HGRCPATH
12 echo "graphlog = " >> $HGRCPATH
17 echo "graphlog = " >> $HGRCPATH
13 echo "[convert]" >> $HGRCPATH
18 echo "[convert]" >> $HGRCPATH
14 echo "cvsps=builtin" >> $HGRCPATH
19 echo "cvsps=builtin" >> $HGRCPATH
15
20
16 echo % create cvs repository
21 echo % create cvs repository
17 mkdir cvsrepo
22 mkdir cvsrepo
18 cd cvsrepo
23 cd cvsrepo
19 export CVSROOT=`pwd`
24 export CVSROOT=`pwd`
20 export CVS_OPTIONS=-f
25 export CVS_OPTIONS=-f
21 cd ..
26 cd ..
22
27
23 cvscall -q -d "$CVSROOT" init
28 cvscall -q -d "$CVSROOT" init
24
29
25 echo % create source directory
30 echo % create source directory
26 mkdir src-temp
31 mkdir src-temp
27 cd src-temp
32 cd src-temp
28 echo a > a
33 echo a > a
29 mkdir b
34 mkdir b
30 cd b
35 cd b
31 echo c > c
36 echo c > c
32 cd ..
37 cd ..
33
38
34 echo % import source directory
39 echo % import source directory
35 cvscall -q import -m import src INITIAL start
40 cvscall -q import -m import src INITIAL start
36 cd ..
41 cd ..
37
42
38 echo % checkout source directory
43 echo % checkout source directory
39 cvscall -q checkout src
44 cvscall -q checkout src
40
45
41 echo % commit a new revision changing b/c
46 echo % commit a new revision changing b/c
42 cd src
47 cd src
43 sleep 1
48 sleep 1
44 echo c >> b/c
49 echo c >> b/c
45 cvscall -q commit -mci0 . | grep '<--' |\
50 cvscall -q commit -mci0 . | grep '<--' |\
46 sed -e 's:.*src/\(.*\),v.*:checking in src/\1,v:g'
51 sed -e 's:.*src/\(.*\),v.*:checking in src/\1,v:g'
47 cd ..
52 cd ..
48
53
49 echo % convert fresh repo
54 echo % convert fresh repo
50 hg convert src src-hg | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g'
55 hg convert src src-hg | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g'
51 cat src-hg/a
56 hgcat a
52 cat src-hg/b/c
57 hgcat b/c
53
58
54 echo % convert fresh repo with --filemap
59 echo % convert fresh repo with --filemap
55 echo include b/c > filemap
60 echo include b/c > filemap
56 hg convert --filemap filemap src src-filemap | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g'
61 hg convert --filemap filemap src src-filemap | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g'
57 cat src-hg/b/c
62 hgcat b/c
58 hg -R src-filemap log --template '#rev# #desc# files: #files#\n'
63 hg -R src-filemap log --template '#rev# #desc# files: #files#\n'
59
64
60 echo % commit new file revisions
65 echo % commit new file revisions
61 cd src
66 cd src
62 echo a >> a
67 echo a >> a
63 echo c >> b/c
68 echo c >> b/c
64 cvscall -q commit -mci1 . | grep '<--' |\
69 cvscall -q commit -mci1 . | grep '<--' |\
65 sed -e 's:.*src/\(.*\),v.*:checking in src/\1,v:g'
70 sed -e 's:.*src/\(.*\),v.*:checking in src/\1,v:g'
66 cd ..
71 cd ..
67
72
68 echo % convert again
73 echo % convert again
69 hg convert src src-hg | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g'
74 hg convert src src-hg | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g'
70 cat src-hg/a
75 hgcat a
71 cat src-hg/b/c
76 hgcat b/c
72
77
73 echo % convert again with --filemap
78 echo % convert again with --filemap
74 hg convert --filemap filemap src src-filemap | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g'
79 hg convert --filemap filemap src src-filemap | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g'
75 cat src-hg/b/c
80 hgcat b/c
76 hg -R src-filemap log --template '#rev# #desc# files: #files#\n'
81 hg -R src-filemap log --template '#rev# #desc# files: #files#\n'
77
82
78 echo % commit branch
83 echo % commit branch
79 cd src
84 cd src
80 cvs -q update -r1.1 b/c
85 cvs -q update -r1.1 b/c
81 cvs -q tag -b branch
86 cvs -q tag -b branch
82 cvs -q update -r branch
87 cvs -q update -r branch
83 echo d >> b/c
88 echo d >> b/c
84 cvs -q commit -mci2 . | grep '<--' |\
89 cvs -q commit -mci2 . | grep '<--' |\
85 sed -e 's:.*src/\(.*\),v.*:checking in src/\1,v:g'
90 sed -e 's:.*src/\(.*\),v.*:checking in src/\1,v:g'
86 cd ..
91 cd ..
87
92
88 echo % convert again
93 echo % convert again
89 hg convert src src-hg | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g'
94 hg convert src src-hg | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g'
90 cat src-hg/a
95 hgcat a
91 cat src-hg/b/c
96 hgcat b/c
92
97
93 echo % convert again with --filemap
98 echo % convert again with --filemap
94 hg convert --filemap filemap src src-filemap | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g'
99 hg convert --filemap filemap src src-filemap | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g'
95 cat src-hg/b/c
100 hgcat b/c
96 hg -R src-filemap log --template '#rev# #desc# files: #files#\n'
101 hg -R src-filemap log --template '#rev# #desc# files: #files#\n'
97
102
98 echo "graphlog = " >> $HGRCPATH
103 echo "graphlog = " >> $HGRCPATH
99 hg -R src-hg glog --template '#rev# (#branches#) #desc# files: #files#\n'
104 hg -R src-hg glog --template '#rev# (#branches#) #desc# files: #files#\n'
@@ -1,139 +1,138
1 % create cvs repository
1 % create cvs repository
2 % create source directory
2 % create source directory
3 % import source directory
3 % import source directory
4 N src/a
4 N src/a
5 N src/b/c
5 N src/b/c
6
6
7 No conflicts created by this import
7 No conflicts created by this import
8
8
9 % checkout source directory
9 % checkout source directory
10 U src/a
10 U src/a
11 U src/b/c
11 U src/b/c
12 % commit a new revision changing b/c
12 % commit a new revision changing b/c
13 checking in src/b/c,v
13 checking in src/b/c,v
14 % convert fresh repo
14 % convert fresh repo
15 initializing destination src-hg repository
15 initializing destination src-hg repository
16 using builtin cvsps
16 using builtin cvsps
17 collecting CVS rlog
17 collecting CVS rlog
18 5 log entries
18 5 log entries
19 creating changesets
19 creating changesets
20 3 changeset entries
20 3 changeset entries
21 connecting to cvsrepo
21 connecting to cvsrepo
22 scanning source...
22 scanning source...
23 sorting...
23 sorting...
24 converting...
24 converting...
25 2 Initial revision
25 2 Initial revision
26 1 import
26 1 import
27 0 ci0
27 0 ci0
28 updating tags
28 updating tags
29 a
29 a
30 c
30 c
31 c
31 c
32 % convert fresh repo with --filemap
32 % convert fresh repo with --filemap
33 initializing destination src-filemap repository
33 initializing destination src-filemap repository
34 using builtin cvsps
34 using builtin cvsps
35 collecting CVS rlog
35 collecting CVS rlog
36 5 log entries
36 5 log entries
37 creating changesets
37 creating changesets
38 3 changeset entries
38 3 changeset entries
39 connecting to cvsrepo
39 connecting to cvsrepo
40 scanning source...
40 scanning source...
41 sorting...
41 sorting...
42 converting...
42 converting...
43 2 Initial revision
43 2 Initial revision
44 1 import
44 1 import
45 rolling back last transaction
45 rolling back last transaction
46 0 ci0
46 0 ci0
47 updating tags
47 updating tags
48 c
48 c
49 c
49 c
50 2 update tags files: .hgtags
50 2 update tags files: .hgtags
51 1 ci0 files: b/c
51 1 ci0 files: b/c
52 0 Initial revision files: b/c
52 0 Initial revision files: b/c
53 % commit new file revisions
53 % commit new file revisions
54 checking in src/a,v
54 checking in src/a,v
55 checking in src/b/c,v
55 checking in src/b/c,v
56 % convert again
56 % convert again
57 using builtin cvsps
57 using builtin cvsps
58 collecting CVS rlog
58 collecting CVS rlog
59 7 log entries
59 7 log entries
60 creating changesets
60 creating changesets
61 4 changeset entries
61 4 changeset entries
62 connecting to cvsrepo
62 connecting to cvsrepo
63 scanning source...
63 scanning source...
64 sorting...
64 sorting...
65 converting...
65 converting...
66 0 ci1
66 0 ci1
67 a
67 a
68 a
68 a
69 c
69 c
70 c
70 c
71 c
71 c
72 % convert again with --filemap
72 % convert again with --filemap
73 using builtin cvsps
73 using builtin cvsps
74 collecting CVS rlog
74 collecting CVS rlog
75 7 log entries
75 7 log entries
76 creating changesets
76 creating changesets
77 4 changeset entries
77 4 changeset entries
78 connecting to cvsrepo
78 connecting to cvsrepo
79 scanning source...
79 scanning source...
80 sorting...
80 sorting...
81 converting...
81 converting...
82 0 ci1
82 0 ci1
83 c
83 c
84 c
84 c
85 c
85 c
86 3 ci1 files: b/c
86 3 ci1 files: b/c
87 2 update tags files: .hgtags
87 2 update tags files: .hgtags
88 1 ci0 files: b/c
88 1 ci0 files: b/c
89 0 Initial revision files: b/c
89 0 Initial revision files: b/c
90 % commit branch
90 % commit branch
91 U b/c
91 U b/c
92 T a
92 T a
93 T b/c
93 T b/c
94 checking in src/b/c,v
94 checking in src/b/c,v
95 % convert again
95 % convert again
96 using builtin cvsps
96 using builtin cvsps
97 collecting CVS rlog
97 collecting CVS rlog
98 8 log entries
98 8 log entries
99 creating changesets
99 creating changesets
100 5 changeset entries
100 5 changeset entries
101 connecting to cvsrepo
101 connecting to cvsrepo
102 scanning source...
102 scanning source...
103 sorting...
103 sorting...
104 converting...
104 converting...
105 0 ci2
105 0 ci2
106 a
106 a
107 a
108 c
107 c
109 d
108 d
110 % convert again with --filemap
109 % convert again with --filemap
111 using builtin cvsps
110 using builtin cvsps
112 collecting CVS rlog
111 collecting CVS rlog
113 8 log entries
112 8 log entries
114 creating changesets
113 creating changesets
115 5 changeset entries
114 5 changeset entries
116 connecting to cvsrepo
115 connecting to cvsrepo
117 scanning source...
116 scanning source...
118 sorting...
117 sorting...
119 converting...
118 converting...
120 0 ci2
119 0 ci2
121 c
120 c
122 d
121 d
123 4 ci2 files: b/c
122 4 ci2 files: b/c
124 3 ci1 files: b/c
123 3 ci1 files: b/c
125 2 update tags files: .hgtags
124 2 update tags files: .hgtags
126 1 ci0 files: b/c
125 1 ci0 files: b/c
127 0 Initial revision files: b/c
126 0 Initial revision files: b/c
128 o 5 (branch) ci2 files: b/c
127 o 5 (branch) ci2 files: b/c
129 |
128 |
130 | o 4 () ci1 files: a b/c
129 | o 4 () ci1 files: a b/c
131 | |
130 | |
132 | o 3 () update tags files: .hgtags
131 | o 3 () update tags files: .hgtags
133 | |
132 | |
134 | o 2 () ci0 files: b/c
133 | o 2 () ci0 files: b/c
135 |/
134 |/
136 | o 1 (INITIAL) import files:
135 | o 1 (INITIAL) import files:
137 |/
136 |/
138 o 0 () Initial revision files: a b/c
137 o 0 () Initial revision files: a b/c
139
138
@@ -1,109 +1,108
1 % create cvs repository
1 % create cvs repository
2 % create source directory
2 % create source directory
3 % import source directory
3 % import source directory
4 N src/a
4 N src/a
5 N src/b/c
5 N src/b/c
6
6
7 No conflicts created by this import
7 No conflicts created by this import
8
8
9 % checkout source directory
9 % checkout source directory
10 U src/a
10 U src/a
11 U src/b/c
11 U src/b/c
12 % commit a new revision changing b/c
12 % commit a new revision changing b/c
13 checking in src/b/c,v
13 checking in src/b/c,v
14 % convert fresh repo
14 % convert fresh repo
15 initializing destination src-hg repository
15 initializing destination src-hg repository
16 connecting to cvsrepo
16 connecting to cvsrepo
17 scanning source...
17 scanning source...
18 sorting...
18 sorting...
19 converting...
19 converting...
20 2 Initial revision
20 2 Initial revision
21 1 import
21 1 import
22 0 ci0
22 0 ci0
23 updating tags
23 updating tags
24 a
24 a
25 c
25 c
26 c
26 c
27 % convert fresh repo with --filemap
27 % convert fresh repo with --filemap
28 initializing destination src-filemap repository
28 initializing destination src-filemap repository
29 connecting to cvsrepo
29 connecting to cvsrepo
30 scanning source...
30 scanning source...
31 sorting...
31 sorting...
32 converting...
32 converting...
33 2 Initial revision
33 2 Initial revision
34 1 import
34 1 import
35 rolling back last transaction
35 rolling back last transaction
36 0 ci0
36 0 ci0
37 updating tags
37 updating tags
38 c
38 c
39 c
39 c
40 2 update tags files: .hgtags
40 2 update tags files: .hgtags
41 1 ci0 files: b/c
41 1 ci0 files: b/c
42 0 Initial revision files: b/c
42 0 Initial revision files: b/c
43 % commit new file revisions
43 % commit new file revisions
44 checking in src/a,v
44 checking in src/a,v
45 checking in src/b/c,v
45 checking in src/b/c,v
46 % convert again
46 % convert again
47 connecting to cvsrepo
47 connecting to cvsrepo
48 scanning source...
48 scanning source...
49 sorting...
49 sorting...
50 converting...
50 converting...
51 0 ci1
51 0 ci1
52 a
52 a
53 a
53 a
54 c
54 c
55 c
55 c
56 c
56 c
57 % convert again with --filemap
57 % convert again with --filemap
58 connecting to cvsrepo
58 connecting to cvsrepo
59 scanning source...
59 scanning source...
60 sorting...
60 sorting...
61 converting...
61 converting...
62 0 ci1
62 0 ci1
63 c
63 c
64 c
64 c
65 c
65 c
66 3 ci1 files: b/c
66 3 ci1 files: b/c
67 2 update tags files: .hgtags
67 2 update tags files: .hgtags
68 1 ci0 files: b/c
68 1 ci0 files: b/c
69 0 Initial revision files: b/c
69 0 Initial revision files: b/c
70 % commit branch
70 % commit branch
71 U b/c
71 U b/c
72 T a
72 T a
73 T b/c
73 T b/c
74 checking in src/b/c,v
74 checking in src/b/c,v
75 % convert again
75 % convert again
76 connecting to cvsrepo
76 connecting to cvsrepo
77 scanning source...
77 scanning source...
78 sorting...
78 sorting...
79 converting...
79 converting...
80 0 ci2
80 0 ci2
81 a
81 a
82 a
83 c
82 c
84 d
83 d
85 % convert again with --filemap
84 % convert again with --filemap
86 connecting to cvsrepo
85 connecting to cvsrepo
87 scanning source...
86 scanning source...
88 sorting...
87 sorting...
89 converting...
88 converting...
90 0 ci2
89 0 ci2
91 c
90 c
92 d
91 d
93 4 ci2 files: b/c
92 4 ci2 files: b/c
94 3 ci1 files: b/c
93 3 ci1 files: b/c
95 2 update tags files: .hgtags
94 2 update tags files: .hgtags
96 1 ci0 files: b/c
95 1 ci0 files: b/c
97 0 Initial revision files: b/c
96 0 Initial revision files: b/c
98 o 5 (branch) ci2 files: b/c
97 o 5 (branch) ci2 files: b/c
99 |
98 |
100 | o 4 () ci1 files: a b/c
99 | o 4 () ci1 files: a b/c
101 | |
100 | |
102 | o 3 () update tags files: .hgtags
101 | o 3 () update tags files: .hgtags
103 | |
102 | |
104 | o 2 () ci0 files: b/c
103 | o 2 () ci0 files: b/c
105 |/
104 |/
106 | o 1 (INITIAL) import files:
105 | o 1 (INITIAL) import files:
107 |/
106 |/
108 o 0 () Initial revision files: a b/c
107 o 0 () Initial revision files: a b/c
109
108
General Comments 0
You need to be logged in to leave comments. Login now