Anonymous avatar Anonymous committed 6fb1dff

combine: disallow combine of public phase changesets

Comments (0)

Files changed (3)

repoman/commands.py

 import mercurial.url
 import mercurial.changegroup
 import mercurial.discovery
+import mercurial.phases
 from mercurial.i18n import _
 from mercurial.node import nullid, short
 
     tctx = repo[rev]
     trev = tctx.rev()
 
-    # Detect foreign merges and build graph set.
-    cl = repo.changelog
-    stack = [cl.rev(n) for n in repo.dirstate.parents() if n != nullid]
+    # Detect foreign merges and phases and build graph set.
+    stack = [repo[n] for n in repo.dirstate.parents() if n != nullid]
     graph = set()
     while stack:
-        r = stack.pop()
+        ctx = stack.pop()
+        r = ctx.rev()
         if r < trev:
             raise util.Abort('foreign merges in changesets or non-ancestral revision given')
+        if ctx.phase() <= mercurial.phases.public:
+            raise util.Abort('public changesets may not be combined')
         graph.add(r)
         if r > trev:
-            stack.extend(p for p in cl.parentrevs(r) if p != -1)
+            stack.extend(ctx.parents())
 
     # Detect unrelated children.
+    cl = repo.changelog
     for r in xrange(len(cl) - 1, trev, -1):
         if r not in graph:
             parents = cl.parentrevs(r)

tests/output/combine.py

     os.system('hg -q ci -d "0 0" -m merge')
     run('combine -kC 3')
 
+    print '\n* combine complete branchy graph with public phases (fail)'
+    os.system('hg phase -p 2')
+    run('combine -kC 1')
+
     print '\n* combine complete branchy graph (ok)'
+    os.system('hg phase -fd 0')
     run('combine -kC 1')
     sitrep(5)
     os.system('hg -q up -C 3')

tests/output/combine.py.out

 * combine linear sub-graph of branchy graph (fail)
 abort: foreign merges in changesets or non-ancestral revision given
 
+* combine complete branchy graph with public phases (fail)
+abort: public changesets may not be combined
+
 * combine complete branchy graph (ok)
 0:d70be7e56464
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.