merge with stable
authorPatrick Mezard <pmezard@gmail.com>
Wed, 20 Apr 2011 23:30:07 +0200
changeset 13969 336bb8b53ad0
parent 13967 f85c9b0fdb32 (current diff)
parent 13968 82845434e974 (diff)
child 13970 d13913355390
merge with stable
tests/test-convert-hg-source.t
--- a/hgext/convert/filemap.py	Wed Apr 20 14:28:40 2011 -0500
+++ b/hgext/convert/filemap.py	Wed Apr 20 23:30:07 2011 +0200
@@ -209,6 +209,11 @@
             self.children[p] = self.children.get(p, 0) + 1
         return c
 
+    def _cachedcommit(self, rev):
+        if rev in self.commits:
+            return self.commits[rev]
+        return self.base.getcommit(rev)
+
     def _discard(self, *revs):
         for r in revs:
             if r is None:
@@ -308,7 +313,14 @@
 
         self.origparents[rev] = parents
 
-        closed = 'close' in self.commits[rev].extra
+        closed = False
+        if 'close' in self.commits[rev].extra:
+            # A branch closing revision is only useful if one of its
+            # parents belong to the branch being closed
+            branch = self.commits[rev].branch
+            pbranches = [self._cachedcommit(p).branch for p in mparents]
+            if branch in pbranches:
+                closed = True
 
         if len(mparents) < 2 and not closed and not self.wanted(rev, wp):
             # We don't want this revision.
--- a/tests/test-convert-filemap.t	Wed Apr 20 14:28:40 2011 -0500
+++ b/tests/test-convert-filemap.t	Wed Apr 20 23:30:07 2011 +0200
@@ -282,3 +282,83 @@
   errors.fmap:5: path to exclude is missing
   abort: errors in filemap
   [255]
+
+test branch closing revision pruning if branch is pruned
+
+  $ hg init branchpruning
+  $ cd branchpruning
+  $ hg branch foo
+  marked working directory as branch foo
+  $ echo a > a
+  $ hg ci -Am adda
+  adding a
+  $ hg ci --close-branch -m closefoo
+  $ hg up 0
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg branch empty
+  marked working directory as branch empty
+  $ hg ci -m emptybranch
+  $ hg ci --close-branch -m closeempty
+  $ hg up 0
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg branch default
+  marked working directory as branch default
+  $ echo b > b
+  $ hg ci -Am addb
+  adding b
+  $ hg ci --close-branch -m closedefault
+  $ cat > filemap <<EOF
+  > include b
+  > EOF
+  $ cd ..
+  $ hg convert branchpruning branchpruning-hg1
+  initializing destination branchpruning-hg1 repository
+  scanning source...
+  sorting...
+  converting...
+  5 adda
+  4 closefoo
+  3 emptybranch
+  2 closeempty
+  1 addb
+  0 closedefault
+  $ glog -R branchpruning-hg1
+  o  5 "closedefault" files:
+  |
+  o  4 "addb" files: b
+  |
+  | o  3 "closeempty" files:
+  | |
+  | o  2 "emptybranch" files:
+  |/
+  | o  1 "closefoo" files:
+  |/
+  o  0 "adda" files: a
+  
+
+exercise incremental conversion at the same time
+
+  $ hg convert -r0 --filemap branchpruning/filemap branchpruning branchpruning-hg2
+  initializing destination branchpruning-hg2 repository
+  scanning source...
+  sorting...
+  converting...
+  0 adda
+  $ hg convert -r4 --filemap branchpruning/filemap branchpruning branchpruning-hg2
+  scanning source...
+  sorting...
+  converting...
+  0 addb
+  $ hg convert --filemap branchpruning/filemap branchpruning branchpruning-hg2
+  scanning source...
+  sorting...
+  converting...
+  3 closefoo
+  2 emptybranch
+  1 closeempty
+  0 closedefault
+  $ glog -R branchpruning-hg2
+  o  1 "closedefault" files:
+  |
+  o  0 "addb" files: b
+  
--- a/tests/test-convert-hg-source.t	Wed Apr 20 14:28:40 2011 -0500
+++ b/tests/test-convert-hg-source.t	Wed Apr 20 23:30:07 2011 +0200
@@ -34,24 +34,18 @@
   created new head
   $ chmod +x baz
   $ hg ci -m 'mark baz executable' -d '5 0'
-  $ hg branch foo
-  marked working directory as branch foo
-  $ hg ci -m 'branch foo' -d '6 0'
-  $ hg ci --close-branch -m 'close' -d '7 0'
   $ cd ..
   $ hg convert --datesort orig new 2>&1 | grep -v 'subversion python bindings could not be loaded'
   initializing destination new repository
   scanning source...
   sorting...
   converting...
-  7 add foo bar
-  6 change foo
-  5 make bar and baz copies of foo
-  4 merge local copy
-  3 merge remote copy
-  2 mark baz executable
-  1 branch foo
-  0 close
+  5 add foo bar
+  4 change foo
+  3 make bar and baz copies of foo
+  2 merge local copy
+  1 merge remote copy
+  0 mark baz executable
   updating bookmarks
   $ cd new
   $ hg out ../orig
@@ -61,7 +55,7 @@
   [1]
   $ hg bookmarks
      premerge1                 3:973ef48a98a4
-     premerge2                 7:0d18d1112f1d
+     premerge2                 5:13d9b87cf8f8
   $ cd ..
 
 check shamap LF and CRLF handling