Make 'hg sign' behave like other commands: Default to current parent.
authorThomas Arendsen Hein <thomas@intevation.de>
Sat, 16 Dec 2006 23:11:16 +0100
changeset 3916 b1806b211910
parent 3915 3c82ab166eea
child 3917 645e1dd4b8ae
Make 'hg sign' behave like other commands: Default to current parent.
hgext/gpg.py
--- a/hgext/gpg.py	Sat Dec 16 22:58:10 2006 +0100
+++ b/hgext/gpg.py	Sat Dec 16 23:11:16 2006 +0100
@@ -194,14 +194,25 @@
         return user
 
 def sign(ui, repo, *revs, **opts):
-    """add a signature for the current tip or a given revision"""
+    """add a signature for the current or given revision
+
+    If no revision is given, the parent of the working directory is used,
+    or tip if no revision is checked out.
+    """
+
     mygpg = newgpg(ui, **opts)
     sigver = "0"
     sigmessage = ""
     if revs:
         nodes = [repo.lookup(n) for n in revs]
     else:
-        nodes = [repo.changelog.tip()]
+        nodes = [node for node in repo.dirstate.parents()
+                 if node != hgnode.nullid]
+        if len(nodes) > 1:
+            raise util.Abort(_('uncommitted merge - please provide a '
+                               'specific revision'))
+        if not nodes:
+            nodes = [repo.changelog.tip()]
 
     for n in nodes:
         hexnode = hgnode.hex(n)