Show More
@@ -17,7 +17,7 b' 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 | |||
@@ -54,11 +54,9 b' class mercurial_sink(converter_sink):' | |||||
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 | |||
@@ -111,30 +109,18 b' class mercurial_sink(converter_sink):' | |||||
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 |
|
112 | ||
115 |
f |
|
113 | files = dict(files) | |
116 | try: |
|
114 | def getfilectx(repo, memctx, f): | |
|
115 | v = files[f] | |||
117 |
|
|
116 | 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 |
|
|
117 | e = source.getmode(f, v) | |
125 | self.repo.wwrite(f, data, e) |
|
118 | return context.memfilectx(f, data, 'l' in e, 'x' in e, copies.get(f)) | |
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 |
|
119 | |||
132 | seen = {} |
|
|||
133 | pl = [] |
|
120 | pl = [] | |
134 | for p in parents: |
|
121 | for p in parents: | |
135 |
if p not in |
|
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: | |
@@ -155,9 +141,9 b' class mercurial_sink(converter_sink):' | |||||
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 |
|
|
145 | commit.author, commit.date, extra) | |
160 |
self.repo. |
|
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 | |||
@@ -166,42 +152,41 b' class mercurial_sink(converter_sink):' | |||||
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) | |
|
161 | tagparent = parentctx.node() | |||
|
162 | except RepoError, inst: | |||
|
163 | parentctx = None | |||
|
164 | tagparent = nullid | |||
|
165 | ||||
|
166 | try: | |||
|
167 | old = parentctx.filectx(".hgtags").data() | |||
176 | oldlines = old.splitlines(1) |
|
168 | oldlines = old.splitlines(1) | |
177 | oldlines.sort() |
|
169 | oldlines.sort() | |
178 | except: |
|
170 | except: | |
179 | oldlines = [] |
|
171 | oldlines = [] | |
180 |
|
172 | |||
181 | k = tags.keys() |
|
173 | newlines = [("%s %s\n" % (tags[tag], tag)) for tag in tags.keys()] | |
182 | k.sort() |
|
|||
183 | newlines = [] |
|
|||
184 | for tag in k: |
|
|||
185 | newlines.append("%s %s\n" % (tags[tag], tag)) |
|
|||
186 |
|
||||
187 | newlines.sort() |
|
174 | newlines.sort() | |
188 |
|
175 | |||
189 |
if newlines |
|
176 | if newlines == oldlines: | |
|
177 | return None | |||
|
178 | data = "".join(newlines) | |||
|
179 | ||||
|
180 | def getfilectx(repo, memctx, f): | |||
|
181 | return context.memfilectx(f, data, False, False, None) | |||
|
182 | ||||
190 |
|
|
183 | self.ui.status("updating tags\n") | |
191 | f = self.repo.wfile(".hgtags", "w") |
|
|||
192 | f.write("".join(newlines)) |
|
|||
193 | f.close() |
|
|||
194 | if not oldlines: self.repo.add([".hgtags"]) |
|
|||
195 |
|
|
184 | date = "%s 0" % int(time.mktime(time.gmtime())) | |
196 | extra = {} |
|
185 | extra = {'branch': self.tagsbranch} | |
197 | if self.tagsbranch != 'default': |
|
186 | ctx = context.memctx(self.repo, (tagparent, None), "update tags", | |
198 | extra['branch'] = self.tagsbranch |
|
187 | [".hgtags"], getfilectx, "convert-repo", date, | |
199 | try: |
|
188 | extra) | |
200 | tagparent = self.repo.changectx(self.tagsbranch).node() |
|
189 | self.repo.commitctx(ctx) | |
201 | except RepoError, inst: |
|
|||
202 | tagparent = nullid |
|
|||
203 | self.repo.rawcommit([".hgtags"], "update tags", "convert-repo", |
|
|||
204 | date, tagparent, nullid, extra=extra) |
|
|||
205 |
|
|
190 | return hex(self.repo.changelog.tip()) | |
206 |
|
191 | |||
207 | def setfilemapmode(self, active): |
|
192 | def setfilemapmode(self, active): |
@@ -7,6 +7,11 b' cvscall()' | |||||
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 | |||
@@ -45,13 +50,13 b' 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 |
|
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 |
|
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 | |
@@ -64,12 +69,12 b' 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 |
|
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 |
|
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 | |
@@ -84,12 +89,12 b' 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 |
|
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 |
|
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 |
@@ -7,6 +7,11 b' cvscall()' | |||||
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 | |
@@ -48,13 +53,13 b' 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 |
|
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 |
|
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 | |
@@ -67,12 +72,12 b' 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 |
|
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 |
|
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 | |
@@ -87,12 +92,12 b' 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 |
|
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 |
|
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 |
General Comments 0
You need to be logged in to leave comments.
Login now