Show More
@@ -17,7 +17,7 b' import os, time' | |||
|
17 | 17 | from mercurial.i18n import _ |
|
18 | 18 | from mercurial.repo import RepoError |
|
19 | 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 | 22 | from common import NoRepo, commit, converter_source, converter_sink |
|
23 | 23 | |
@@ -54,11 +54,9 b' class mercurial_sink(converter_sink):' | |||
|
54 | 54 | self.ui.debug(_('run hg sink pre-conversion action\n')) |
|
55 | 55 | self.wlock = self.repo.wlock() |
|
56 | 56 | self.lock = self.repo.lock() |
|
57 | self.repo.dirstate.clear() | |
|
58 | 57 | |
|
59 | 58 | def after(self): |
|
60 | 59 | self.ui.debug(_('run hg sink post-conversion action\n')) |
|
61 | self.repo.dirstate.invalidate() | |
|
62 | 60 | self.lock = None |
|
63 | 61 | self.wlock = None |
|
64 | 62 | |
@@ -111,30 +109,18 b' class mercurial_sink(converter_sink):' | |||
|
111 | 109 | self.before() |
|
112 | 110 | |
|
113 | 111 | def putcommit(self, files, copies, parents, commit, source): |
|
114 | # Apply changes to working copy | |
|
115 |
f |
|
|
116 | try: | |
|
112 | ||
|
113 | files = dict(files) | |
|
114 | def getfilectx(repo, memctx, f): | |
|
115 | v = files[f] | |
|
117 | 116 |
|
|
118 | except IOError, inst: | |
|
119 | try: | |
|
120 | util.unlink(self.repo.wjoin(f)) | |
|
121 | except OSError: | |
|
122 | pass | |
|
123 | else: | |
|
124 | 117 |
|
|
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] | |
|
118 | return context.memfilectx(f, data, 'l' in e, 'x' in e, copies.get(f)) | |
|
131 | 119 | |
|
132 | seen = {} | |
|
133 | 120 | pl = [] |
|
134 | 121 | for p in parents: |
|
135 |
if p not in |
|
|
122 | if p not in pl: | |
|
136 | 123 | pl.append(p) |
|
137 | seen[p] = 1 | |
|
138 | 124 | parents = pl |
|
139 | 125 | nparents = len(parents) |
|
140 | 126 | if self.filemapmode and nparents == 1: |
@@ -155,9 +141,9 b' class mercurial_sink(converter_sink):' | |||
|
155 | 141 | while parents: |
|
156 | 142 | p1 = p2 |
|
157 | 143 | p2 = parents.pop(0) |
|
158 | a = self.repo.rawcommit(files, text, commit.author, commit.date, | |
|
159 |
|
|
|
160 |
self.repo. |
|
|
144 | ctx = context.memctx(self.repo, (p1, p2), text, files.keys(), getfilectx, | |
|
145 | commit.author, commit.date, extra) | |
|
146 | a = self.repo.commitctx(ctx) | |
|
161 | 147 | text = "(octopus merge fixup)\n" |
|
162 | 148 | p2 = hex(self.repo.changelog.tip()) |
|
163 | 149 | |
@@ -166,42 +152,41 b' class mercurial_sink(converter_sink):' | |||
|
166 | 152 | mnode = self.repo.changelog.read(bin(p2))[0] |
|
167 | 153 | if not man.cmp(m1node, man.revision(mnode)): |
|
168 | 154 | self.repo.rollback() |
|
169 | self.repo.dirstate.clear() | |
|
170 | 155 | return parent |
|
171 | 156 | return p2 |
|
172 | 157 | |
|
173 | 158 | def puttags(self, tags): |
|
174 | 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 | 168 | oldlines = old.splitlines(1) |
|
177 | 169 | oldlines.sort() |
|
178 | 170 | except: |
|
179 | 171 | oldlines = [] |
|
180 | 172 | |
|
181 | k = tags.keys() | |
|
182 | k.sort() | |
|
183 | newlines = [] | |
|
184 | for tag in k: | |
|
185 | newlines.append("%s %s\n" % (tags[tag], tag)) | |
|
186 | ||
|
173 | newlines = [("%s %s\n" % (tags[tag], tag)) for tag in tags.keys()] | |
|
187 | 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 |
|
|
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 |
|
|
196 | extra = {} | |
|
197 | if self.tagsbranch != 'default': | |
|
198 | extra['branch'] = self.tagsbranch | |
|
199 | try: | |
|
200 | tagparent = self.repo.changectx(self.tagsbranch).node() | |
|
201 | except RepoError, inst: | |
|
202 | tagparent = nullid | |
|
203 | self.repo.rawcommit([".hgtags"], "update tags", "convert-repo", | |
|
204 | date, tagparent, nullid, extra=extra) | |
|
185 | extra = {'branch': self.tagsbranch} | |
|
186 | ctx = context.memctx(self.repo, (tagparent, None), "update tags", | |
|
187 | [".hgtags"], getfilectx, "convert-repo", date, | |
|
188 | extra) | |
|
189 | self.repo.commitctx(ctx) | |
|
205 | 190 |
|
|
206 | 191 | |
|
207 | 192 | def setfilemapmode(self, active): |
@@ -7,6 +7,11 b' cvscall()' | |||
|
7 | 7 | cvs -f $@ |
|
8 | 8 | } |
|
9 | 9 | |
|
10 | hgcat() | |
|
11 | { | |
|
12 | hg --cwd src-hg cat -r tip "$1" | |
|
13 | } | |
|
14 | ||
|
10 | 15 | echo "[extensions]" >> $HGRCPATH |
|
11 | 16 | echo "convert = " >> $HGRCPATH |
|
12 | 17 | |
@@ -45,13 +50,13 b' cd ..' | |||
|
45 | 50 | |
|
46 | 51 | echo % convert fresh repo |
|
47 | 52 | hg convert src src-hg | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g' |
|
48 | cat src-hg/a | |
|
49 |
cat |
|
|
53 | hgcat a | |
|
54 | hgcat b/c | |
|
50 | 55 | |
|
51 | 56 | echo % convert fresh repo with --filemap |
|
52 | 57 | echo include b/c > filemap |
|
53 | 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 | 60 | hg -R src-filemap log --template '#rev# #desc# files: #files#\n' |
|
56 | 61 | |
|
57 | 62 | echo % commit new file revisions |
@@ -64,12 +69,12 b' cd ..' | |||
|
64 | 69 | |
|
65 | 70 | echo % convert again |
|
66 | 71 | hg convert src src-hg | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g' |
|
67 | cat src-hg/a | |
|
68 |
cat |
|
|
72 | hgcat a | |
|
73 | hgcat b/c | |
|
69 | 74 | |
|
70 | 75 | echo % convert again with --filemap |
|
71 | 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 | 78 | hg -R src-filemap log --template '#rev# #desc# files: #files#\n' |
|
74 | 79 | |
|
75 | 80 | echo % commit branch |
@@ -84,12 +89,12 b' cd ..' | |||
|
84 | 89 | |
|
85 | 90 | echo % convert again |
|
86 | 91 | hg convert src src-hg | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g' |
|
87 | cat src-hg/a | |
|
88 |
cat |
|
|
92 | hgcat a | |
|
93 | hgcat b/c | |
|
89 | 94 | |
|
90 | 95 | echo % convert again with --filemap |
|
91 | 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 | 98 | hg -R src-filemap log --template '#rev# #desc# files: #files#\n' |
|
94 | 99 | |
|
95 | 100 | echo "graphlog = " >> $HGRCPATH |
@@ -7,6 +7,11 b' cvscall()' | |||
|
7 | 7 | cvs -f "$@" |
|
8 | 8 | } |
|
9 | 9 | |
|
10 | hgcat() | |
|
11 | { | |
|
12 | hg --cwd src-hg cat -r tip "$1" | |
|
13 | } | |
|
14 | ||
|
10 | 15 | echo "[extensions]" >> $HGRCPATH |
|
11 | 16 | echo "convert = " >> $HGRCPATH |
|
12 | 17 | echo "graphlog = " >> $HGRCPATH |
@@ -48,13 +53,13 b' cd ..' | |||
|
48 | 53 | |
|
49 | 54 | echo % convert fresh repo |
|
50 | 55 | hg convert src src-hg | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g' |
|
51 | cat src-hg/a | |
|
52 |
cat |
|
|
56 | hgcat a | |
|
57 | hgcat b/c | |
|
53 | 58 | |
|
54 | 59 | echo % convert fresh repo with --filemap |
|
55 | 60 | echo include b/c > filemap |
|
56 | 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 | 63 | hg -R src-filemap log --template '#rev# #desc# files: #files#\n' |
|
59 | 64 | |
|
60 | 65 | echo % commit new file revisions |
@@ -67,12 +72,12 b' cd ..' | |||
|
67 | 72 | |
|
68 | 73 | echo % convert again |
|
69 | 74 | hg convert src src-hg | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g' |
|
70 | cat src-hg/a | |
|
71 |
cat |
|
|
75 | hgcat a | |
|
76 | hgcat b/c | |
|
72 | 77 | |
|
73 | 78 | echo % convert again with --filemap |
|
74 | 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 | 81 | hg -R src-filemap log --template '#rev# #desc# files: #files#\n' |
|
77 | 82 | |
|
78 | 83 | echo % commit branch |
@@ -87,12 +92,12 b' cd ..' | |||
|
87 | 92 | |
|
88 | 93 | echo % convert again |
|
89 | 94 | hg convert src src-hg | sed -e 's/connecting to.*cvsrepo/connecting to cvsrepo/g' |
|
90 | cat src-hg/a | |
|
91 |
cat |
|
|
95 | hgcat a | |
|
96 | hgcat b/c | |
|
92 | 97 | |
|
93 | 98 | echo % convert again with --filemap |
|
94 | 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 | 101 | hg -R src-filemap log --template '#rev# #desc# files: #files#\n' |
|
97 | 102 | |
|
98 | 103 | echo "graphlog = " >> $HGRCPATH |
General Comments 0
You need to be logged in to leave comments.
Login now