diff mercurial/commands.py @ 19306:59cdd3a7e281

merge with stable
author Matt Mackall <mpm@selenic.com>
date Fri, 07 Jun 2013 16:59:59 -0500
parents 043abd6a91d1 b500a663a2c7
children 0cfb62e043e8
line wrap: on
line diff
--- a/mercurial/commands.py	Fri Jun 07 16:04:11 2013 -0500
+++ b/mercurial/commands.py	Fri Jun 07 16:59:59 2013 -0500
@@ -1334,12 +1334,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'):