hgext/gpg.py
changeset 3915 b1806b211910
parent 2874 3d6efcbbd1c9
child 3919 b12eae71382d
equal deleted inserted replaced
3914:3c82ab166eea 3915:b1806b211910
   192         return "%s (%s)" % (user, comment)
   192         return "%s (%s)" % (user, comment)
   193     else:
   193     else:
   194         return user
   194         return user
   195 
   195 
   196 def sign(ui, repo, *revs, **opts):
   196 def sign(ui, repo, *revs, **opts):
   197     """add a signature for the current tip or a given revision"""
   197     """add a signature for the current or given revision
       
   198 
       
   199     If no revision is given, the parent of the working directory is used,
       
   200     or tip if no revision is checked out.
       
   201     """
       
   202 
   198     mygpg = newgpg(ui, **opts)
   203     mygpg = newgpg(ui, **opts)
   199     sigver = "0"
   204     sigver = "0"
   200     sigmessage = ""
   205     sigmessage = ""
   201     if revs:
   206     if revs:
   202         nodes = [repo.lookup(n) for n in revs]
   207         nodes = [repo.lookup(n) for n in revs]
   203     else:
   208     else:
   204         nodes = [repo.changelog.tip()]
   209         nodes = [node for node in repo.dirstate.parents()
       
   210                  if node != hgnode.nullid]
       
   211         if len(nodes) > 1:
       
   212             raise util.Abort(_('uncommitted merge - please provide a '
       
   213                                'specific revision'))
       
   214         if not nodes:
       
   215             nodes = [repo.changelog.tip()]
   205 
   216 
   206     for n in nodes:
   217     for n in nodes:
   207         hexnode = hgnode.hex(n)
   218         hexnode = hgnode.hex(n)
   208         ui.write("Signing %d:%s\n" % (repo.changelog.rev(n),
   219         ui.write("Signing %d:%s\n" % (repo.changelog.rev(n),
   209                                       hgnode.short(n)))
   220                                       hgnode.short(n)))