Show More
@@ -1,276 +1,284 b'' | |||||
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.node import * |
|
18 | from mercurial.node import * | |
19 | from mercurial import hg, lock, revlog, util |
|
19 | from mercurial import hg, lock, revlog, util | |
20 |
|
20 | |||
21 | from common import NoRepo, commit, converter_source, converter_sink |
|
21 | from common import NoRepo, commit, converter_source, converter_sink | |
22 |
|
22 | |||
23 | class mercurial_sink(converter_sink): |
|
23 | class mercurial_sink(converter_sink): | |
24 | def __init__(self, ui, path): |
|
24 | def __init__(self, ui, path): | |
25 | converter_sink.__init__(self, ui, path) |
|
25 | converter_sink.__init__(self, ui, path) | |
26 | self.branchnames = ui.configbool('convert', 'hg.usebranchnames', True) |
|
26 | self.branchnames = ui.configbool('convert', 'hg.usebranchnames', True) | |
27 | self.clonebranches = ui.configbool('convert', 'hg.clonebranches', False) |
|
27 | self.clonebranches = ui.configbool('convert', 'hg.clonebranches', False) | |
28 | self.tagsbranch = ui.config('convert', 'hg.tagsbranch', 'default') |
|
28 | self.tagsbranch = ui.config('convert', 'hg.tagsbranch', 'default') | |
29 | self.lastbranch = None |
|
29 | self.lastbranch = None | |
30 | if os.path.isdir(path) and len(os.listdir(path)) > 0: |
|
30 | if os.path.isdir(path) and len(os.listdir(path)) > 0: | |
31 | try: |
|
31 | try: | |
32 | self.repo = hg.repository(self.ui, path) |
|
32 | self.repo = hg.repository(self.ui, path) | |
33 | except hg.RepoError, err: |
|
33 | except hg.RepoError, err: | |
34 | ui.print_exc() |
|
34 | ui.print_exc() | |
35 | raise NoRepo(err.args[0]) |
|
35 | raise NoRepo(err.args[0]) | |
36 | else: |
|
36 | else: | |
37 | try: |
|
37 | try: | |
38 | ui.status(_('initializing destination %s repository\n') % path) |
|
38 | ui.status(_('initializing destination %s repository\n') % path) | |
39 | self.repo = hg.repository(self.ui, path, create=True) |
|
39 | self.repo = hg.repository(self.ui, path, create=True) | |
40 | self.created.append(path) |
|
40 | self.created.append(path) | |
41 | except hg.RepoError, err: |
|
41 | except hg.RepoError, err: | |
42 | ui.print_exc() |
|
42 | ui.print_exc() | |
43 | raise NoRepo("could not create hg repo %s as sink" % path) |
|
43 | raise NoRepo("could not create hg repo %s as sink" % path) | |
44 | self.lock = None |
|
44 | self.lock = None | |
45 | self.wlock = None |
|
45 | self.wlock = None | |
46 | self.filemapmode = False |
|
46 | self.filemapmode = False | |
47 |
|
47 | |||
48 | def before(self): |
|
48 | def before(self): | |
|
49 | self.ui.debug(_('run hg sink pre-conversion action\n')) | |||
49 | self.wlock = self.repo.wlock() |
|
50 | self.wlock = self.repo.wlock() | |
50 | self.lock = self.repo.lock() |
|
51 | self.lock = self.repo.lock() | |
51 | self.repo.dirstate.clear() |
|
52 | self.repo.dirstate.clear() | |
52 |
|
53 | |||
53 | def after(self): |
|
54 | def after(self): | |
|
55 | self.ui.debug(_('run hg sink post-conversion action\n')) | |||
54 | self.repo.dirstate.invalidate() |
|
56 | self.repo.dirstate.invalidate() | |
55 | self.lock = None |
|
57 | self.lock = None | |
56 | self.wlock = None |
|
58 | self.wlock = None | |
57 |
|
59 | |||
58 | def revmapfile(self): |
|
60 | def revmapfile(self): | |
59 | return os.path.join(self.path, ".hg", "shamap") |
|
61 | return os.path.join(self.path, ".hg", "shamap") | |
60 |
|
62 | |||
61 | def authorfile(self): |
|
63 | def authorfile(self): | |
62 | return os.path.join(self.path, ".hg", "authormap") |
|
64 | return os.path.join(self.path, ".hg", "authormap") | |
63 |
|
65 | |||
64 | def getheads(self): |
|
66 | def getheads(self): | |
65 | h = self.repo.changelog.heads() |
|
67 | h = self.repo.changelog.heads() | |
66 | return [ hex(x) for x in h ] |
|
68 | return [ hex(x) for x in h ] | |
67 |
|
69 | |||
68 | def putfile(self, f, e, data): |
|
70 | def putfile(self, f, e, data): | |
69 | self.repo.wwrite(f, data, e) |
|
71 | self.repo.wwrite(f, data, e) | |
70 | if f not in self.repo.dirstate: |
|
72 | if f not in self.repo.dirstate: | |
71 | self.repo.dirstate.normallookup(f) |
|
73 | self.repo.dirstate.normallookup(f) | |
72 |
|
74 | |||
73 | def copyfile(self, source, dest): |
|
75 | def copyfile(self, source, dest): | |
74 | self.repo.copy(source, dest) |
|
76 | self.repo.copy(source, dest) | |
75 |
|
77 | |||
76 | def delfile(self, f): |
|
78 | def delfile(self, f): | |
77 | try: |
|
79 | try: | |
78 | util.unlink(self.repo.wjoin(f)) |
|
80 | util.unlink(self.repo.wjoin(f)) | |
79 | #self.repo.remove([f]) |
|
81 | #self.repo.remove([f]) | |
80 | except OSError: |
|
82 | except OSError: | |
81 | pass |
|
83 | pass | |
82 |
|
84 | |||
83 | def setbranch(self, branch, pbranch, parents): |
|
85 | def setbranch(self, branch, pbranch, parents): | |
84 | if (not self.clonebranches) or (branch == self.lastbranch): |
|
86 | if (not self.clonebranches) or (branch == self.lastbranch): | |
85 | return |
|
87 | return | |
86 |
|
88 | |||
87 | self.lastbranch = branch |
|
89 | self.lastbranch = branch | |
88 | self.after() |
|
90 | self.after() | |
89 | if not branch: |
|
91 | if not branch: | |
90 | branch = 'default' |
|
92 | branch = 'default' | |
91 | if not pbranch: |
|
93 | if not pbranch: | |
92 | pbranch = 'default' |
|
94 | pbranch = 'default' | |
93 |
|
95 | |||
94 | branchpath = os.path.join(self.path, branch) |
|
96 | branchpath = os.path.join(self.path, branch) | |
95 | try: |
|
97 | try: | |
96 | self.repo = hg.repository(self.ui, branchpath) |
|
98 | self.repo = hg.repository(self.ui, branchpath) | |
97 | except: |
|
99 | except: | |
98 | if not parents: |
|
100 | if not parents: | |
99 | self.repo = hg.repository(self.ui, branchpath, create=True) |
|
101 | self.repo = hg.repository(self.ui, branchpath, create=True) | |
100 | else: |
|
102 | else: | |
101 | self.ui.note(_('cloning branch %s to %s\n') % (pbranch, branch)) |
|
103 | self.ui.note(_('cloning branch %s to %s\n') % (pbranch, branch)) | |
102 | hg.clone(self.ui, os.path.join(self.path, pbranch), |
|
104 | hg.clone(self.ui, os.path.join(self.path, pbranch), | |
103 | branchpath, rev=parents, update=False, |
|
105 | branchpath, rev=parents, update=False, | |
104 | stream=True) |
|
106 | stream=True) | |
105 | self.repo = hg.repository(self.ui, branchpath) |
|
107 | self.repo = hg.repository(self.ui, branchpath) | |
106 | self.before() |
|
108 | self.before() | |
107 |
|
109 | |||
108 | def putcommit(self, files, parents, commit): |
|
110 | def putcommit(self, files, parents, commit): | |
109 | seen = {} |
|
111 | seen = {} | |
110 | pl = [] |
|
112 | pl = [] | |
111 | for p in parents: |
|
113 | for p in parents: | |
112 | if p not in seen: |
|
114 | if p not in seen: | |
113 | pl.append(p) |
|
115 | pl.append(p) | |
114 | seen[p] = 1 |
|
116 | seen[p] = 1 | |
115 | parents = pl |
|
117 | parents = pl | |
116 | nparents = len(parents) |
|
118 | nparents = len(parents) | |
117 | if self.filemapmode and nparents == 1: |
|
119 | if self.filemapmode and nparents == 1: | |
118 | m1node = self.repo.changelog.read(bin(parents[0]))[0] |
|
120 | m1node = self.repo.changelog.read(bin(parents[0]))[0] | |
119 | parent = parents[0] |
|
121 | parent = parents[0] | |
120 |
|
122 | |||
121 | if len(parents) < 2: parents.append("0" * 40) |
|
123 | if len(parents) < 2: parents.append("0" * 40) | |
122 | if len(parents) < 2: parents.append("0" * 40) |
|
124 | if len(parents) < 2: parents.append("0" * 40) | |
123 | p2 = parents.pop(0) |
|
125 | p2 = parents.pop(0) | |
124 |
|
126 | |||
125 | text = commit.desc |
|
127 | text = commit.desc | |
126 | extra = commit.extra.copy() |
|
128 | extra = commit.extra.copy() | |
127 | if self.branchnames and commit.branch: |
|
129 | if self.branchnames and commit.branch: | |
128 | extra['branch'] = commit.branch |
|
130 | extra['branch'] = commit.branch | |
129 | if commit.rev: |
|
131 | if commit.rev: | |
130 | extra['convert_revision'] = commit.rev |
|
132 | extra['convert_revision'] = commit.rev | |
131 |
|
133 | |||
132 | while parents: |
|
134 | while parents: | |
133 | p1 = p2 |
|
135 | p1 = p2 | |
134 | p2 = parents.pop(0) |
|
136 | p2 = parents.pop(0) | |
135 | a = self.repo.rawcommit(files, text, commit.author, commit.date, |
|
137 | a = self.repo.rawcommit(files, text, commit.author, commit.date, | |
136 | bin(p1), bin(p2), extra=extra) |
|
138 | bin(p1), bin(p2), extra=extra) | |
137 | self.repo.dirstate.clear() |
|
139 | self.repo.dirstate.clear() | |
138 | text = "(octopus merge fixup)\n" |
|
140 | text = "(octopus merge fixup)\n" | |
139 | p2 = hg.hex(self.repo.changelog.tip()) |
|
141 | p2 = hg.hex(self.repo.changelog.tip()) | |
140 |
|
142 | |||
141 | if self.filemapmode and nparents == 1: |
|
143 | if self.filemapmode and nparents == 1: | |
142 | man = self.repo.manifest |
|
144 | man = self.repo.manifest | |
143 | mnode = self.repo.changelog.read(bin(p2))[0] |
|
145 | mnode = self.repo.changelog.read(bin(p2))[0] | |
144 | if not man.cmp(m1node, man.revision(mnode)): |
|
146 | if not man.cmp(m1node, man.revision(mnode)): | |
145 | self.repo.rollback() |
|
147 | self.repo.rollback() | |
146 | self.repo.dirstate.clear() |
|
148 | self.repo.dirstate.clear() | |
147 | return parent |
|
149 | return parent | |
148 | return p2 |
|
150 | return p2 | |
149 |
|
151 | |||
150 | def puttags(self, tags): |
|
152 | def puttags(self, tags): | |
151 | try: |
|
153 | try: | |
152 | old = self.repo.wfile(".hgtags").read() |
|
154 | old = self.repo.wfile(".hgtags").read() | |
153 | oldlines = old.splitlines(1) |
|
155 | oldlines = old.splitlines(1) | |
154 | oldlines.sort() |
|
156 | oldlines.sort() | |
155 | except: |
|
157 | except: | |
156 | oldlines = [] |
|
158 | oldlines = [] | |
157 |
|
159 | |||
158 | k = tags.keys() |
|
160 | k = tags.keys() | |
159 | k.sort() |
|
161 | k.sort() | |
160 | newlines = [] |
|
162 | newlines = [] | |
161 | for tag in k: |
|
163 | for tag in k: | |
162 | newlines.append("%s %s\n" % (tags[tag], tag)) |
|
164 | newlines.append("%s %s\n" % (tags[tag], tag)) | |
163 |
|
165 | |||
164 | newlines.sort() |
|
166 | newlines.sort() | |
165 |
|
167 | |||
166 | if newlines != oldlines: |
|
168 | if newlines != oldlines: | |
167 | self.ui.status("updating tags\n") |
|
169 | self.ui.status("updating tags\n") | |
168 | f = self.repo.wfile(".hgtags", "w") |
|
170 | f = self.repo.wfile(".hgtags", "w") | |
169 | f.write("".join(newlines)) |
|
171 | f.write("".join(newlines)) | |
170 | f.close() |
|
172 | f.close() | |
171 | if not oldlines: self.repo.add([".hgtags"]) |
|
173 | if not oldlines: self.repo.add([".hgtags"]) | |
172 | date = "%s 0" % int(time.mktime(time.gmtime())) |
|
174 | date = "%s 0" % int(time.mktime(time.gmtime())) | |
173 | extra = {} |
|
175 | extra = {} | |
174 | if self.tagsbranch != 'default': |
|
176 | if self.tagsbranch != 'default': | |
175 | extra['branch'] = self.tagsbranch |
|
177 | extra['branch'] = self.tagsbranch | |
176 | try: |
|
178 | try: | |
177 | tagparent = self.repo.changectx(self.tagsbranch).node() |
|
179 | tagparent = self.repo.changectx(self.tagsbranch).node() | |
178 | except hg.RepoError, inst: |
|
180 | except hg.RepoError, inst: | |
179 | tagparent = nullid |
|
181 | tagparent = nullid | |
180 | self.repo.rawcommit([".hgtags"], "update tags", "convert-repo", |
|
182 | self.repo.rawcommit([".hgtags"], "update tags", "convert-repo", | |
181 | date, tagparent, nullid) |
|
183 | date, tagparent, nullid) | |
182 | return hex(self.repo.changelog.tip()) |
|
184 | return hex(self.repo.changelog.tip()) | |
183 |
|
185 | |||
184 | def setfilemapmode(self, active): |
|
186 | def setfilemapmode(self, active): | |
185 | self.filemapmode = active |
|
187 | self.filemapmode = active | |
186 |
|
188 | |||
187 | class mercurial_source(converter_source): |
|
189 | class mercurial_source(converter_source): | |
188 | def __init__(self, ui, path, rev=None): |
|
190 | def __init__(self, ui, path, rev=None): | |
189 | converter_source.__init__(self, ui, path, rev) |
|
191 | converter_source.__init__(self, ui, path, rev) | |
190 | self.saverev = ui.configbool('convert', 'hg.saverev', True) |
|
192 | self.saverev = ui.configbool('convert', 'hg.saverev', True) | |
191 | try: |
|
193 | try: | |
192 | self.repo = hg.repository(self.ui, path) |
|
194 | self.repo = hg.repository(self.ui, path) | |
193 | # try to provoke an exception if this isn't really a hg |
|
195 | # try to provoke an exception if this isn't really a hg | |
194 | # repo, but some other bogus compatible-looking url |
|
196 | # repo, but some other bogus compatible-looking url | |
195 | if not self.repo.local(): |
|
197 | if not self.repo.local(): | |
196 | raise hg.RepoError() |
|
198 | raise hg.RepoError() | |
197 | except hg.RepoError: |
|
199 | except hg.RepoError: | |
198 | ui.print_exc() |
|
200 | ui.print_exc() | |
199 | raise NoRepo("%s is not a local Mercurial repo" % path) |
|
201 | raise NoRepo("%s is not a local Mercurial repo" % path) | |
200 | self.lastrev = None |
|
202 | self.lastrev = None | |
201 | self.lastctx = None |
|
203 | self.lastctx = None | |
202 | self._changescache = None |
|
204 | self._changescache = None | |
203 | self.convertfp = None |
|
205 | self.convertfp = None | |
204 |
|
206 | |||
205 | def changectx(self, rev): |
|
207 | def changectx(self, rev): | |
206 | if self.lastrev != rev: |
|
208 | if self.lastrev != rev: | |
207 | self.lastctx = self.repo.changectx(rev) |
|
209 | self.lastctx = self.repo.changectx(rev) | |
208 | self.lastrev = rev |
|
210 | self.lastrev = rev | |
209 | return self.lastctx |
|
211 | return self.lastctx | |
210 |
|
212 | |||
211 | def getheads(self): |
|
213 | def getheads(self): | |
212 | if self.rev: |
|
214 | if self.rev: | |
213 | return [hex(self.repo.changectx(self.rev).node())] |
|
215 | return [hex(self.repo.changectx(self.rev).node())] | |
214 | else: |
|
216 | else: | |
215 | return [hex(node) for node in self.repo.heads()] |
|
217 | return [hex(node) for node in self.repo.heads()] | |
216 |
|
218 | |||
217 | def getfile(self, name, rev): |
|
219 | def getfile(self, name, rev): | |
218 | try: |
|
220 | try: | |
219 | return self.changectx(rev).filectx(name).data() |
|
221 | return self.changectx(rev).filectx(name).data() | |
220 | except revlog.LookupError, err: |
|
222 | except revlog.LookupError, err: | |
221 | raise IOError(err) |
|
223 | raise IOError(err) | |
222 |
|
224 | |||
223 | def getmode(self, name, rev): |
|
225 | def getmode(self, name, rev): | |
224 | m = self.changectx(rev).manifest() |
|
226 | m = self.changectx(rev).manifest() | |
225 | return (m.execf(name) and 'x' or '') + (m.linkf(name) and 'l' or '') |
|
227 | return (m.execf(name) and 'x' or '') + (m.linkf(name) and 'l' or '') | |
226 |
|
228 | |||
227 | def getchanges(self, rev): |
|
229 | def getchanges(self, rev): | |
228 | ctx = self.changectx(rev) |
|
230 | ctx = self.changectx(rev) | |
229 | if self._changescache and self._changescache[0] == rev: |
|
231 | if self._changescache and self._changescache[0] == rev: | |
230 | m, a, r = self._changescache[1] |
|
232 | m, a, r = self._changescache[1] | |
231 | else: |
|
233 | else: | |
232 | m, a, r = self.repo.status(ctx.parents()[0].node(), ctx.node())[:3] |
|
234 | m, a, r = self.repo.status(ctx.parents()[0].node(), ctx.node())[:3] | |
233 | changes = [(name, rev) for name in m + a + r] |
|
235 | changes = [(name, rev) for name in m + a + r] | |
234 | changes.sort() |
|
236 | changes.sort() | |
235 | return (changes, self.getcopies(ctx, m + a)) |
|
237 | return (changes, self.getcopies(ctx, m + a)) | |
236 |
|
238 | |||
237 | def getcopies(self, ctx, files): |
|
239 | def getcopies(self, ctx, files): | |
238 | copies = {} |
|
240 | copies = {} | |
239 | for name in files: |
|
241 | for name in files: | |
240 | try: |
|
242 | try: | |
241 | copies[name] = ctx.filectx(name).renamed()[0] |
|
243 | copies[name] = ctx.filectx(name).renamed()[0] | |
242 | except TypeError: |
|
244 | except TypeError: | |
243 | pass |
|
245 | pass | |
244 | return copies |
|
246 | return copies | |
245 |
|
247 | |||
246 | def getcommit(self, rev): |
|
248 | def getcommit(self, rev): | |
247 | ctx = self.changectx(rev) |
|
249 | ctx = self.changectx(rev) | |
248 | parents = [hex(p.node()) for p in ctx.parents() if p.node() != nullid] |
|
250 | parents = [hex(p.node()) for p in ctx.parents() if p.node() != nullid] | |
249 | if self.saverev: |
|
251 | if self.saverev: | |
250 | crev = rev |
|
252 | crev = rev | |
251 | else: |
|
253 | else: | |
252 | crev = None |
|
254 | crev = None | |
253 | return commit(author=ctx.user(), date=util.datestr(ctx.date()), |
|
255 | return commit(author=ctx.user(), date=util.datestr(ctx.date()), | |
254 | desc=ctx.description(), rev=crev, parents=parents, |
|
256 | desc=ctx.description(), rev=crev, parents=parents, | |
255 | branch=ctx.branch(), extra=ctx.extra()) |
|
257 | branch=ctx.branch(), extra=ctx.extra()) | |
256 |
|
258 | |||
257 | def gettags(self): |
|
259 | def gettags(self): | |
258 | tags = [t for t in self.repo.tagslist() if t[0] != 'tip'] |
|
260 | tags = [t for t in self.repo.tagslist() if t[0] != 'tip'] | |
259 | return dict([(name, hex(node)) for name, node in tags]) |
|
261 | return dict([(name, hex(node)) for name, node in tags]) | |
260 |
|
262 | |||
261 | def getchangedfiles(self, rev, i): |
|
263 | def getchangedfiles(self, rev, i): | |
262 | ctx = self.changectx(rev) |
|
264 | ctx = self.changectx(rev) | |
263 | i = i or 0 |
|
265 | i = i or 0 | |
264 | changes = self.repo.status(ctx.parents()[i].node(), ctx.node())[:3] |
|
266 | changes = self.repo.status(ctx.parents()[i].node(), ctx.node())[:3] | |
265 |
|
267 | |||
266 | if i == 0: |
|
268 | if i == 0: | |
267 | self._changescache = (rev, changes) |
|
269 | self._changescache = (rev, changes) | |
268 |
|
270 | |||
269 | return changes[0] + changes[1] + changes[2] |
|
271 | return changes[0] + changes[1] + changes[2] | |
270 |
|
272 | |||
271 | def converted(self, rev, destrev): |
|
273 | def converted(self, rev, destrev): | |
272 | if self.convertfp is None: |
|
274 | if self.convertfp is None: | |
273 | self.convertfp = open(os.path.join(self.path, '.hg', 'shamap'), |
|
275 | self.convertfp = open(os.path.join(self.path, '.hg', 'shamap'), | |
274 | 'a') |
|
276 | 'a') | |
275 | self.convertfp.write('%s %s\n' % (destrev, rev)) |
|
277 | self.convertfp.write('%s %s\n' % (destrev, rev)) | |
276 | self.convertfp.flush() |
|
278 | self.convertfp.flush() | |
|
279 | ||||
|
280 | def before(self): | |||
|
281 | self.ui.debug(_('run hg source pre-conversion action\n')) | |||
|
282 | ||||
|
283 | def after(self): | |||
|
284 | self.ui.debug(_('run hg source post-conversion action\n')) |
@@ -1,41 +1,46 b'' | |||||
1 | #!/bin/sh |
|
1 | #!/bin/sh | |
2 |
|
2 | |||
3 | cat >> $HGRCPATH <<EOF |
|
3 | cat >> $HGRCPATH <<EOF | |
4 | [extensions] |
|
4 | [extensions] | |
5 | convert= |
|
5 | convert= | |
6 | [convert] |
|
6 | [convert] | |
7 | hg.saverev=False |
|
7 | hg.saverev=False | |
8 | EOF |
|
8 | EOF | |
9 |
|
9 | |||
10 | hg help convert |
|
10 | hg help convert | |
11 |
|
11 | |||
12 | hg init a |
|
12 | hg init a | |
13 | cd a |
|
13 | cd a | |
14 | echo a > a |
|
14 | echo a > a | |
15 | hg ci -d'0 0' -Ama |
|
15 | hg ci -d'0 0' -Ama | |
16 | hg cp a b |
|
16 | hg cp a b | |
17 | hg ci -d'1 0' -mb |
|
17 | hg ci -d'1 0' -mb | |
18 | hg rm a |
|
18 | hg rm a | |
19 | hg ci -d'2 0' -mc |
|
19 | hg ci -d'2 0' -mc | |
20 | hg mv b a |
|
20 | hg mv b a | |
21 | hg ci -d'3 0' -md |
|
21 | hg ci -d'3 0' -md | |
22 | echo a >> a |
|
22 | echo a >> a | |
23 | hg ci -d'4 0' -me |
|
23 | hg ci -d'4 0' -me | |
24 |
|
24 | |||
25 | cd .. |
|
25 | cd .. | |
26 | hg convert a 2>&1 | grep -v 'subversion python bindings could not be loaded' |
|
26 | hg convert a 2>&1 | grep -v 'subversion python bindings could not be loaded' | |
27 | hg --cwd a-hg pull ../a |
|
27 | hg --cwd a-hg pull ../a | |
28 |
|
28 | |||
29 | touch bogusfile |
|
29 | touch bogusfile | |
30 | echo % should fail |
|
30 | echo % should fail | |
31 | hg convert a bogusfile |
|
31 | hg convert a bogusfile | |
32 |
|
32 | |||
33 | mkdir bogusdir |
|
33 | mkdir bogusdir | |
34 | chmod 000 bogusdir |
|
34 | chmod 000 bogusdir | |
35 |
|
35 | |||
36 | echo % should fail |
|
36 | echo % should fail | |
37 | hg convert a bogusdir |
|
37 | hg convert a bogusdir | |
38 |
|
38 | |||
39 | echo % should succeed |
|
39 | echo % should succeed | |
40 | chmod 700 bogusdir |
|
40 | chmod 700 bogusdir | |
41 | hg convert a bogusdir |
|
41 | hg convert a bogusdir | |
|
42 | ||||
|
43 | echo % test pre and post conversion actions | |||
|
44 | echo 'include b' > filemap | |||
|
45 | hg convert --debug --filemap filemap a partialb | \ | |||
|
46 | grep 'run hg' |
@@ -1,114 +1,119 b'' | |||||
1 | hg convert [OPTION]... SOURCE [DEST [MAPFILE]] |
|
1 | hg convert [OPTION]... SOURCE [DEST [MAPFILE]] | |
2 |
|
2 | |||
3 | Convert a foreign SCM repository to a Mercurial one. |
|
3 | Convert a foreign SCM repository to a Mercurial one. | |
4 |
|
4 | |||
5 | Accepted source formats: |
|
5 | Accepted source formats: | |
6 | - Mercurial |
|
6 | - Mercurial | |
7 | - CVS |
|
7 | - CVS | |
8 | - Darcs |
|
8 | - Darcs | |
9 | - git |
|
9 | - git | |
10 | - Subversion |
|
10 | - Subversion | |
11 |
|
11 | |||
12 | Accepted destination formats: |
|
12 | Accepted destination formats: | |
13 | - Mercurial |
|
13 | - Mercurial | |
14 | - Subversion (history on branches is not preserved) |
|
14 | - Subversion (history on branches is not preserved) | |
15 |
|
15 | |||
16 | If no revision is given, all revisions will be converted. Otherwise, |
|
16 | If no revision is given, all revisions will be converted. Otherwise, | |
17 | convert will only import up to the named revision (given in a format |
|
17 | convert will only import up to the named revision (given in a format | |
18 | understood by the source). |
|
18 | understood by the source). | |
19 |
|
19 | |||
20 | If no destination directory name is specified, it defaults to the |
|
20 | If no destination directory name is specified, it defaults to the | |
21 | basename of the source with '-hg' appended. If the destination |
|
21 | basename of the source with '-hg' appended. If the destination | |
22 | repository doesn't exist, it will be created. |
|
22 | repository doesn't exist, it will be created. | |
23 |
|
23 | |||
24 | If <MAPFILE> isn't given, it will be put in a default location |
|
24 | If <MAPFILE> isn't given, it will be put in a default location | |
25 | (<dest>/.hg/shamap by default). The <MAPFILE> is a simple text |
|
25 | (<dest>/.hg/shamap by default). The <MAPFILE> is a simple text | |
26 | file that maps each source commit ID to the destination ID for |
|
26 | file that maps each source commit ID to the destination ID for | |
27 | that revision, like so: |
|
27 | that revision, like so: | |
28 | <source ID> <destination ID> |
|
28 | <source ID> <destination ID> | |
29 |
|
29 | |||
30 | If the file doesn't exist, it's automatically created. It's updated |
|
30 | If the file doesn't exist, it's automatically created. It's updated | |
31 | on each commit copied, so convert-repo can be interrupted and can |
|
31 | on each commit copied, so convert-repo can be interrupted and can | |
32 | be run repeatedly to copy new commits. |
|
32 | be run repeatedly to copy new commits. | |
33 |
|
33 | |||
34 | The [username mapping] file is a simple text file that maps each source |
|
34 | The [username mapping] file is a simple text file that maps each source | |
35 | commit author to a destination commit author. It is handy for source SCMs |
|
35 | commit author to a destination commit author. It is handy for source SCMs | |
36 | that use unix logins to identify authors (eg: CVS). One line per author |
|
36 | that use unix logins to identify authors (eg: CVS). One line per author | |
37 | mapping and the line format is: |
|
37 | mapping and the line format is: | |
38 | srcauthor=whatever string you want |
|
38 | srcauthor=whatever string you want | |
39 |
|
39 | |||
40 | The filemap is a file that allows filtering and remapping of files |
|
40 | The filemap is a file that allows filtering and remapping of files | |
41 | and directories. Comment lines start with '#'. Each line can |
|
41 | and directories. Comment lines start with '#'. Each line can | |
42 | contain one of the following directives: |
|
42 | contain one of the following directives: | |
43 |
|
43 | |||
44 | include path/to/file |
|
44 | include path/to/file | |
45 |
|
45 | |||
46 | exclude path/to/file |
|
46 | exclude path/to/file | |
47 |
|
47 | |||
48 | rename from/file to/file |
|
48 | rename from/file to/file | |
49 |
|
49 | |||
50 | The 'include' directive causes a file, or all files under a |
|
50 | The 'include' directive causes a file, or all files under a | |
51 | directory, to be included in the destination repository, and the |
|
51 | directory, to be included in the destination repository, and the | |
52 | exclusion of all other files and dirs not explicitely included. |
|
52 | exclusion of all other files and dirs not explicitely included. | |
53 | The 'exclude' directive causes files or directories to be omitted. |
|
53 | The 'exclude' directive causes files or directories to be omitted. | |
54 | The 'rename' directive renames a file or directory. To rename from a |
|
54 | The 'rename' directive renames a file or directory. To rename from a | |
55 | subdirectory into the root of the repository, use '.' as the path to |
|
55 | subdirectory into the root of the repository, use '.' as the path to | |
56 | rename to. |
|
56 | rename to. | |
57 |
|
57 | |||
58 | Back end options: |
|
58 | Back end options: | |
59 |
|
59 | |||
60 | --config convert.hg.clonebranches=False (boolean) |
|
60 | --config convert.hg.clonebranches=False (boolean) | |
61 | hg target: XXX not documented |
|
61 | hg target: XXX not documented | |
62 | --config convert.hg.saverev=True (boolean) |
|
62 | --config convert.hg.saverev=True (boolean) | |
63 | hg source: allow target to preserve source revision ID |
|
63 | hg source: allow target to preserve source revision ID | |
64 | --config convert.hg.tagsbranch=default (branch name) |
|
64 | --config convert.hg.tagsbranch=default (branch name) | |
65 | hg target: XXX not documented |
|
65 | hg target: XXX not documented | |
66 | --config convert.hg.usebranchnames=True (boolean) |
|
66 | --config convert.hg.usebranchnames=True (boolean) | |
67 | hg target: preserve branch names |
|
67 | hg target: preserve branch names | |
68 |
|
68 | |||
69 | --config convert.svn.branches=branches (directory name) |
|
69 | --config convert.svn.branches=branches (directory name) | |
70 | svn source: specify the directory containing branches |
|
70 | svn source: specify the directory containing branches | |
71 | --config convert.svn.tags=tags (directory name) |
|
71 | --config convert.svn.tags=tags (directory name) | |
72 | svn source: specify the directory containing tags |
|
72 | svn source: specify the directory containing tags | |
73 | --config convert.svn.trunk=trunk (directory name) |
|
73 | --config convert.svn.trunk=trunk (directory name) | |
74 | svn source: specify the name of the trunk branch |
|
74 | svn source: specify the name of the trunk branch | |
75 |
|
75 | |||
76 | options: |
|
76 | options: | |
77 |
|
77 | |||
78 | -A --authors username mapping filename |
|
78 | -A --authors username mapping filename | |
79 | -d --dest-type destination repository type |
|
79 | -d --dest-type destination repository type | |
80 | --filemap remap file names using contents of file |
|
80 | --filemap remap file names using contents of file | |
81 | -r --rev import up to target revision REV |
|
81 | -r --rev import up to target revision REV | |
82 | -s --source-type source repository type |
|
82 | -s --source-type source repository type | |
83 | --datesort try to sort changesets by date |
|
83 | --datesort try to sort changesets by date | |
84 |
|
84 | |||
85 | use "hg -v help convert" to show global options |
|
85 | use "hg -v help convert" to show global options | |
86 | adding a |
|
86 | adding a | |
87 | assuming destination a-hg |
|
87 | assuming destination a-hg | |
88 | initializing destination a-hg repository |
|
88 | initializing destination a-hg repository | |
89 | scanning source... |
|
89 | scanning source... | |
90 | sorting... |
|
90 | sorting... | |
91 | converting... |
|
91 | converting... | |
92 | 4 a |
|
92 | 4 a | |
93 | 3 b |
|
93 | 3 b | |
94 | 2 c |
|
94 | 2 c | |
95 | 1 d |
|
95 | 1 d | |
96 | 0 e |
|
96 | 0 e | |
97 | pulling from ../a |
|
97 | pulling from ../a | |
98 | searching for changes |
|
98 | searching for changes | |
99 | no changes found |
|
99 | no changes found | |
100 | % should fail |
|
100 | % should fail | |
101 | initializing destination bogusfile repository |
|
101 | initializing destination bogusfile repository | |
102 | abort: cannot create new bundle repository |
|
102 | abort: cannot create new bundle repository | |
103 | % should fail |
|
103 | % should fail | |
104 | abort: Permission denied: bogusdir |
|
104 | abort: Permission denied: bogusdir | |
105 | % should succeed |
|
105 | % should succeed | |
106 | initializing destination bogusdir repository |
|
106 | initializing destination bogusdir repository | |
107 | scanning source... |
|
107 | scanning source... | |
108 | sorting... |
|
108 | sorting... | |
109 | converting... |
|
109 | converting... | |
110 | 4 a |
|
110 | 4 a | |
111 | 3 b |
|
111 | 3 b | |
112 | 2 c |
|
112 | 2 c | |
113 | 1 d |
|
113 | 1 d | |
114 | 0 e |
|
114 | 0 e | |
|
115 | % test pre and post conversion actions | |||
|
116 | run hg source pre-conversion action | |||
|
117 | run hg sink pre-conversion action | |||
|
118 | run hg sink post-conversion action | |||
|
119 | run hg source post-conversion action |
General Comments 0
You need to be logged in to leave comments.
Login now