mercurial/commands.py
branchstable
changeset 19305 b500a663a2c7
parent 19253 e078ea9b4ce4
child 19306 59cdd3a7e281
--- a/mercurial/commands.py	Thu Jun 06 14:05:03 2013 -0400
+++ b/mercurial/commands.py	Thu May 02 19:36:47 2013 +0300
@@ -1319,12 +1319,19 @@
         raise util.Abort(_('cannot commit an interrupted graft operation'),
                          hint=_('use "hg graft -c" to continue graft'))
 
+    branch = repo[None].branch()
+    bheads = repo.branchheads(branch)
+
     extra = {}
     if opts.get('close_branch'):
         extra['close'] = 1
 
-    branch = repo[None].branch()
-    bheads = repo.branchheads(branch)
+        if not bheads:
+            raise util.Abort(_('can only close branch heads'))
+        elif opts.get('amend'):
+            if repo.parents()[0].p1().branch() != branch and \
+                    repo.parents()[0].p2().branch() != branch:
+                raise util.Abort(_('can only close branch heads'))
 
     if opts.get('amend'):
         if ui.configbool('ui', 'commitsubrepos'):