##// END OF EJS Templates
convert: make filemap prune useless branch closing revs (issue2774)...
Patrick Mezard -
r13968:82845434 stable
parent child Browse files
Show More
@@ -209,6 +209,11 b' class filemap_source(converter_source):'
209 self.children[p] = self.children.get(p, 0) + 1
209 self.children[p] = self.children.get(p, 0) + 1
210 return c
210 return c
211
211
212 def _cachedcommit(self, rev):
213 if rev in self.commits:
214 return self.commits[rev]
215 return self.base.getcommit(rev)
216
212 def _discard(self, *revs):
217 def _discard(self, *revs):
213 for r in revs:
218 for r in revs:
214 if r is None:
219 if r is None:
@@ -308,7 +313,14 b' class filemap_source(converter_source):'
308
313
309 self.origparents[rev] = parents
314 self.origparents[rev] = parents
310
315
311 closed = 'close' in self.commits[rev].extra
316 closed = False
317 if 'close' in self.commits[rev].extra:
318 # A branch closing revision is only useful if one of its
319 # parents belong to the branch being closed
320 branch = self.commits[rev].branch
321 pbranches = [self._cachedcommit(p).branch for p in mparents]
322 if branch in pbranches:
323 closed = True
312
324
313 if len(mparents) < 2 and not closed and not self.wanted(rev, wp):
325 if len(mparents) < 2 and not closed and not self.wanted(rev, wp):
314 # We don't want this revision.
326 # We don't want this revision.
@@ -282,3 +282,83 b' filemap errors'
282 errors.fmap:5: path to exclude is missing
282 errors.fmap:5: path to exclude is missing
283 abort: errors in filemap
283 abort: errors in filemap
284 [255]
284 [255]
285
286 test branch closing revision pruning if branch is pruned
287
288 $ hg init branchpruning
289 $ cd branchpruning
290 $ hg branch foo
291 marked working directory as branch foo
292 $ echo a > a
293 $ hg ci -Am adda
294 adding a
295 $ hg ci --close-branch -m closefoo
296 $ hg up 0
297 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
298 $ hg branch empty
299 marked working directory as branch empty
300 $ hg ci -m emptybranch
301 $ hg ci --close-branch -m closeempty
302 $ hg up 0
303 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
304 $ hg branch default
305 marked working directory as branch default
306 $ echo b > b
307 $ hg ci -Am addb
308 adding b
309 $ hg ci --close-branch -m closedefault
310 $ cat > filemap <<EOF
311 > include b
312 > EOF
313 $ cd ..
314 $ hg convert branchpruning branchpruning-hg1
315 initializing destination branchpruning-hg1 repository
316 scanning source...
317 sorting...
318 converting...
319 5 adda
320 4 closefoo
321 3 emptybranch
322 2 closeempty
323 1 addb
324 0 closedefault
325 $ glog -R branchpruning-hg1
326 o 5 "closedefault" files:
327 |
328 o 4 "addb" files: b
329 |
330 | o 3 "closeempty" files:
331 | |
332 | o 2 "emptybranch" files:
333 |/
334 | o 1 "closefoo" files:
335 |/
336 o 0 "adda" files: a
337
338
339 exercise incremental conversion at the same time
340
341 $ hg convert -r0 --filemap branchpruning/filemap branchpruning branchpruning-hg2
342 initializing destination branchpruning-hg2 repository
343 scanning source...
344 sorting...
345 converting...
346 0 adda
347 $ hg convert -r4 --filemap branchpruning/filemap branchpruning branchpruning-hg2
348 scanning source...
349 sorting...
350 converting...
351 0 addb
352 $ hg convert --filemap branchpruning/filemap branchpruning branchpruning-hg2
353 scanning source...
354 sorting...
355 converting...
356 3 closefoo
357 2 emptybranch
358 1 closeempty
359 0 closedefault
360 $ glog -R branchpruning-hg2
361 o 1 "closedefault" files:
362 |
363 o 0 "addb" files: b
364
@@ -32,24 +32,18 b''
32 created new head
32 created new head
33 $ chmod +x baz
33 $ chmod +x baz
34 $ hg ci -m 'mark baz executable' -d '5 0'
34 $ hg ci -m 'mark baz executable' -d '5 0'
35 $ hg branch foo
36 marked working directory as branch foo
37 $ hg ci -m 'branch foo' -d '6 0'
38 $ hg ci --close-branch -m 'close' -d '7 0'
39 $ cd ..
35 $ cd ..
40 $ hg convert --datesort orig new 2>&1 | grep -v 'subversion python bindings could not be loaded'
36 $ hg convert --datesort orig new 2>&1 | grep -v 'subversion python bindings could not be loaded'
41 initializing destination new repository
37 initializing destination new repository
42 scanning source...
38 scanning source...
43 sorting...
39 sorting...
44 converting...
40 converting...
45 7 add foo bar
41 5 add foo bar
46 6 change foo
42 4 change foo
47 5 make bar and baz copies of foo
43 3 make bar and baz copies of foo
48 4 merge local copy
44 2 merge local copy
49 3 merge remote copy
45 1 merge remote copy
50 2 mark baz executable
46 0 mark baz executable
51 1 branch foo
52 0 close
53 $ cd new
47 $ cd new
54 $ hg out ../orig
48 $ hg out ../orig
55 comparing with ../orig
49 comparing with ../orig
General Comments 0
You need to be logged in to leave comments. Login now