##// END OF EJS Templates
convert/bzr: correctly handle divergent nested renames (issue3089)...
Patrick Mezard -
r15461:6ba2fc0a stable
parent child Browse files
Show More
@@ -173,8 +173,14 b' class bzr_source(converter_source):'
173 revid = current._revision_id
173 revid = current._revision_id
174 changes = []
174 changes = []
175 renames = {}
175 renames = {}
176 seen = set()
177 # Process the entries by reverse lexicographic name order to
178 # handle nested renames correctly, most specific first.
179 curchanges = sorted(current.iter_changes(origin),
180 key=lambda c: c[1][0] or c[1][1],
181 reverse=True)
176 for (fileid, paths, changed_content, versioned, parent, name,
182 for (fileid, paths, changed_content, versioned, parent, name,
177 kind, executable) in current.iter_changes(origin):
183 kind, executable) in curchanges:
178
184
179 if paths[0] == u'' or paths[1] == u'':
185 if paths[0] == u'' or paths[1] == u'':
180 # ignore changes to tree root
186 # ignore changes to tree root
@@ -188,7 +194,8 b' class bzr_source(converter_source):'
188 # so it can be removed.
194 # so it can be removed.
189 changes.append((self.recode(paths[0]), revid))
195 changes.append((self.recode(paths[0]), revid))
190
196
191 if None not in paths and paths[0] != paths[1]:
197 if kind[0] == 'directory' and None not in paths:
198 renaming = paths[0] != paths[1]
192 # neither an add nor an delete - a move
199 # neither an add nor an delete - a move
193 # rename all directory contents manually
200 # rename all directory contents manually
194 subdir = origin.inventory.path2id(paths[0])
201 subdir = origin.inventory.path2id(paths[0])
@@ -198,6 +205,16 b' class bzr_source(converter_source):'
198 if entry.kind == 'directory':
205 if entry.kind == 'directory':
199 continue
206 continue
200 frompath = self.recode(paths[0] + '/' + name)
207 frompath = self.recode(paths[0] + '/' + name)
208 if frompath in seen:
209 # Already handled by a more specific change entry
210 # This is important when you have:
211 # a => b
212 # a/c => a/c
213 # Here a/c must not be renamed into b/c
214 continue
215 seen.add(frompath)
216 if not renaming:
217 continue
201 topath = self.recode(paths[1] + '/' + name)
218 topath = self.recode(paths[1] + '/' + name)
202 # register the files as changed
219 # register the files as changed
203 changes.append((frompath, revid))
220 changes.append((frompath, revid))
@@ -215,6 +232,7 b' class bzr_source(converter_source):'
215
232
216 # we got unicode paths, need to convert them
233 # we got unicode paths, need to convert them
217 path, topath = [self.recode(part) for part in paths]
234 path, topath = [self.recode(part) for part in paths]
235 seen.add(path or topath)
218
236
219 if topath is None:
237 if topath is None:
220 # file deleted
238 # file deleted
@@ -149,3 +149,45 b' directory replace'
149 644 second/something
149 644 second/something
150 644 third/dummy
150 644 third/dummy
151 $ cd ..
151 $ cd ..
152
153 divergent nested renames (issue3089)
154
155 $ mkdir test-divergent-renames
156 $ cd test-divergent-renames
157 $ bzr init -q source
158 $ cd source
159 $ mkdir -p a/c
160 $ echo a > a/fa
161 $ echo c > a/c/fc
162 $ bzr add -q a
163 $ bzr commit -q -m 'Initial layout'
164 $ bzr mv a b
165 a => b
166 $ mkdir a
167 $ bzr add a
168 adding a
169 $ bzr mv b/c a/c
170 b/c => a/c
171 $ bzr status
172 added:
173 a/
174 renamed:
175 a/ => b/
176 a/c/ => a/c/
177 $ bzr commit -q -m 'Divergent renames'
178 $ cd ..
179 $ hg convert source source-hg
180 initializing destination source-hg repository
181 scanning source...
182 sorting...
183 converting...
184 1 Initial layout
185 0 Divergent renames
186 $ hg -R source-hg st -C --change 1
187 A b/fa
188 a/fa
189 R a/fa
190 $ hg -R source-hg manifest -r 1
191 a/c/fc
192 b/fa
193 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now