Commits

Pierre-Yves David committed 1fab364

forbid unfreezing tag related changeset.

update test to catch a bug when the new frozen heads is anot a direct descendant
from the other.

  • Participants
  • Parent commits 9d03f63

Comments (0)

Files changed (2)

     return 0
 
 cmdtable = {
+    'freeze':  (cmdfreeze,   [], _('<revset>')),
     'debugfreeze':  (cmdfreeze,   [], _('<revset>')),
     'debugmelt':  (cmdmelt,   [], _('<revset>')),
     }
 
             olds = self._frozenheads[:]
             meltpoints = map(node.hex, meltpoints)
-            revset = "heads(::frozenheads() and !((%s)::))" % ' + '.join(meltpoints)
-            self._frozenheads[:] = noderange(repo, [revset])
-            self._frozenheads[:].sort()
+            revset = "heads(::frozenheads() and not ((%s)::))" % ' + '.join(meltpoints)
+            nodes = noderange(repo, [revset])
+            if nodes:
+                self._frozenheads[:] = nodes
+                self._frozenheads[:].sort()
+                revset = '(tag() + file(".hgtags")) - (::frozenheads())'
+            dangerous = noderange(repo, [revset])
+            if dangerous:
+                for i in dangerous:
+                    ctx = repo[i]
+                    tags = ctx.tags()
+                    if tags:
+                        msg = _("Can't unfreeze %s: tagged by %s\n")
+                        ui.warn(msg % (ctx, ', '.join(tags)))
+                    else:
+                        msg = _("Can't unfreeze %s: this changeset tag another\n")
+                        ui.warn(msg % ctx)
+                self._frozenheads[:] = olds
+                raise util.Abort("Can not unfreeze tag related changeset\n")
             if olds != self._frozenheads:
                 self._writefrozen()
+            
 
         def freeze(self, fheads):
             """freeze targets changeset and it's ancestors.
             self._frozenheads[:] = set(self._frozenheads)
             self._frozenheads.sort()
             if olds != self._frozenheads:
-                self._frozenheads[:] = noderange(repo, ["heads(frozenheads())"])
+                self._frozenheads[:] = noderange(repo, ["heads(::frozenheads())"])
                 self._frozenheads.sort()
             if olds != self._frozenheads:
                 self._writefrozen()

File tests/test-liquidhg.t

 
   $ hg init alpha
   $ cd alpha
+  $ mkcommit z
   $ mkcommit a
   $ mkcommit b
   $ mkcommit c
   $ hg debugfreeze 1
   $ hg log --graph
-  @  changeset:   2:4538525df7e2
+  @  changeset:   3:090483935bca
   |  tag:         tip
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     add c
   |
-  o  changeset:   1:7c3bad9141dc
+  o  changeset:   2:720fd97246d7
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     add b
   |
-  o  changeset:   0:1f0dee641bb7
+  o  changeset:   1:7a344d213ee2
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     add a
+  |
+  o  changeset:   0:d32fd17cb041
      user:        test
      date:        Thu Jan 01 00:00:00 1970 +0000
-     summary:     add a
+     summary:     add z
   
   $ cat .hg/frozenheads
-  7c3bad9141dcb46ff89abf5f61856facd56e476c
+  7a344d213ee2eb3359d94630d4e076460d59dbf0
 
 frozenheads() should return only revision 1:
   $ hg log -r 'frozenheads()' --graph
-  o  changeset:   1:7c3bad9141dc
+  o  changeset:   1:7a344d213ee2
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     add b
+  |  summary:     add a
   |
 
 ancestors of frozenheads shows all frozen revisions:
   $ hg log -r '::frozenheads()' --graph
-  o  changeset:   1:7c3bad9141dc
+  o  changeset:   1:7a344d213ee2
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     add b
+  |  summary:     add a
   |
-  o  changeset:   0:1f0dee641bb7
+  o  changeset:   0:d32fd17cb041
      user:        test
      date:        Thu Jan 01 00:00:00 1970 +0000
-     summary:     add a
+     summary:     add z
   
   $ cd ..
   $ hg init beta
   adding changesets
   adding manifests
   adding file changes
-  added 3 changesets with 3 changes to 3 files
-  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  added 4 changesets with 4 changes to 4 files
+  4 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg log --graph -r 'frozenheads()'
-  o  changeset:   1:7c3bad9141dc
+  o  changeset:   1:7a344d213ee2
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     add b
+  |  summary:     add a
   |
 
 Freeze in beta and push to alpha:
-  $ hg debugfreeze 2
+  $ hg debugfreeze 3
   $ mkcommit d
   $ hg push ../alpha
   pushing to ../alpha
   added 1 changesets with 1 changes to 1 files
   $ cd ../alpha
   $ hg debugrevspec 'frozenheads()'
-  2
+  3
   $ hg log --graph -r 'frozenheads()'
-  @  changeset:   2:4538525df7e2
+  @  changeset:   3:090483935bca
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     add c
   |
 
   $ hg log -r tip
-  changeset:   3:47d2a3944de8
+  changeset:   4:fb98f3f5bba0
   tag:         tip
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   
   $ mkcommit e
   created new head
-  $ hg up -C 3
+  $ hg up -C 4
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ hg tag -fr tip babar
   $ hg log -r 'frozenheads()'
-  changeset:   4:332c4963205e
+  changeset:   5:cdaaa31e4239
   tag:         babar
-  parent:      2:4538525df7e2
+  parent:      3:090483935bca
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     add e
   
-  changeset:   5:d97ce228dfd2
+  changeset:   6:bd66bf1525ee
   tag:         tip
-  parent:      3:47d2a3944de8
+  parent:      4:fb98f3f5bba0
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     Added tag babar for changeset 332c4963205e
+  summary:     Added tag babar for changeset cdaaa31e4239
   
 Try the debug melt feature
   $ hg merge
   $ hg commit -m 'merge'
   $ hg debugfreeze tip
   $ hg log -r 'frozenheads()'
-  changeset:   6:6168b285f921
+  changeset:   7:26631d82e09e
   tag:         tip
-  parent:      5:d97ce228dfd2
-  parent:      4:332c4963205e
+  parent:      6:bd66bf1525ee
+  parent:      5:cdaaa31e4239
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     merge
   
   $ hg debugmelt tip
   $ hg log -r 'frozenheads()'
-  changeset:   4:332c4963205e
+  changeset:   5:cdaaa31e4239
   tag:         babar
-  parent:      2:4538525df7e2
+  parent:      3:090483935bca
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     add e
   
-  changeset:   5:d97ce228dfd2
-  parent:      3:47d2a3944de8
+  changeset:   6:bd66bf1525ee
+  parent:      4:fb98f3f5bba0
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     Added tag babar for changeset 332c4963205e
+  summary:     Added tag babar for changeset cdaaa31e4239
   
+  $ hg debugmelt tip
+  $ hg debugmelt babar
+  Can't unfreeze cdaaa31e4239: tagged by babar
+  abort: Can not unfreeze tag related changeset
+  
+  [255]
+  $ hg debugmelt 6
+  Can't unfreeze bd66bf1525ee: this changeset tag another
+  abort: Can not unfreeze tag related changeset
+  
+  [255]