##// END OF EJS Templates
rust-config: add config getters that don't fall back to defaults...
rust-config: add config getters that don't fall back to defaults This is useful in cases where we access config items that are more... lenient with their types than a fresh new system would allow. For now there is only a single use of this, but we might get more later.

File last commit:

r50932:46883d91 default
r51657:8ff187fb default
Show More
gpg.py
391 lines | 11.0 KiB | text/x-python | PythonLexer
Benoit Boissinot
fixes for gpg.py extension...
r1681 # Copyright 2005, 2006 Benoit Boissinot <benoit.boissinot@ens-lyon.org>
#
Martin Geisler
updated license to be explicit about GPL version 2
r8225 # This software may be used and distributed according to the terms of the
Matt Mackall
Update license to GPLv2+
r10263 # GNU General Public License version 2 or any later version.
Benoit Boissinot
fixes for gpg.py extension...
r1681
Dirkjan Ochtman
extensions: change descriptions for extensions providing a few commands
r8934 '''commands to sign and verify changesets'''
Dirkjan Ochtman
help: add/fix docstrings for a bunch of extensions
r8873
Pulkit Goyal
py3: make hgext/gpg.py use absolute_import
r29124
import binascii
import os
Yuya Nishihara
py3: move up symbol imports to enforce import-checker rules...
r29205
from mercurial.i18n import _
Joerg Sonnenberger
node: import symbols explicitly...
r46729 from mercurial.node import (
bin,
hex,
short,
)
Pulkit Goyal
py3: make hgext/gpg.py use absolute_import
r29124 from mercurial import (
cmdutil,
error,
rdamazio@google.com
help: assigning categories to existing commands...
r40329 help,
Pulkit Goyal
py3: make hgext/gpg.py use absolute_import
r29124 match,
Pulkit Goyal
py3: convert the mode argument of os.fdopen to unicodes (2 of 2)
r30925 pycompat,
Yuya Nishihara
registrar: move cmdutil.command to registrar module (API)...
r32337 registrar,
Pulkit Goyal
py3: make hgext/gpg.py use absolute_import
r29124 )
Yuya Nishihara
procutil: bulk-replace function calls to point to new module
r37138 from mercurial.utils import (
dateutil,
procutil,
)
Benoit Boissinot
gpg signing extension for hg...
r1592
Martin Geisler
gpg: use cmdutil.command decorator
r14299 cmdtable = {}
Yuya Nishihara
registrar: move cmdutil.command to registrar module (API)...
r32337 command = registrar.command(cmdtable)
Augie Fackler
extensions: change magic "shipped with hg" string...
r29841 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
Augie Fackler
extensions: document that `testedwith = 'internal'` is special...
r25186 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
# be specifying the version(s) of Mercurial they are tested with, or
# leave the attribute unspecified.
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 testedwith = b'ships-with-hg-core'
Martin Geisler
gpg: use cmdutil.command decorator
r14299
Boris Feld
configitems: register the 'gpg.cmd' config
r34502 configtable = {}
configitem = registrar.configitem(configtable)
Augie Fackler
formatting: blacken the codebase...
r43346 configitem(
Augie Fackler
formating: upgrade to black 20.8b1...
r46554 b'gpg',
b'cmd',
default=b'gpg',
Boris Feld
configitems: register the 'gpg.cmd' config
r34502 )
Augie Fackler
formatting: blacken the codebase...
r43346 configitem(
Augie Fackler
formating: upgrade to black 20.8b1...
r46554 b'gpg',
b'key',
default=None,
Boris Feld
configitems: register the 'gpg.key' config
r34503 )
Augie Fackler
formatting: blacken the codebase...
r43346 configitem(
Augie Fackler
formating: upgrade to black 20.8b1...
r46554 b'gpg',
b'.*',
default=None,
generic=True,
Boris Feld
configitems: register the 'gpg' arbitraty key section
r34771 )
Boris Feld
configitems: register the 'gpg.cmd' config
r34502
rdamazio@google.com
help: assigning categories to existing commands...
r40329 # Custom help category
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _HELP_CATEGORY = b'gpg'
Sietse Brouwer
help: register the 'gpg' command category and give it a description...
r42421 help.CATEGORY_ORDER.insert(
Augie Fackler
formatting: blacken the codebase...
r43346 help.CATEGORY_ORDER.index(registrar.command.CATEGORY_HELP), _HELP_CATEGORY
Sietse Brouwer
help: register the 'gpg' command category and give it a description...
r42421 )
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 help.CATEGORY_NAMES[_HELP_CATEGORY] = b'Signing changes (GPG)'
rdamazio@google.com
help: assigning categories to existing commands...
r40329
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
py3: use class X: instead of class X(object):...
r49801 class gpg:
Benoit Boissinot
gpg signing extension for hg...
r1592 def __init__(self, path, key=None):
self.path = path
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self.key = (key and b" --local-user \"%s\"" % key) or b""
Benoit Boissinot
gpg signing extension for hg...
r1592
def sign(self, data):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 gpgcmd = b"%s --sign --detach-sign%s" % (self.path, self.key)
Yuya Nishihara
procutil: bulk-replace function calls to point to new module
r37138 return procutil.filter(data, gpgcmd)
Benoit Boissinot
gpg signing extension for hg...
r1592
def verify(self, data, sig):
Kyle Lippincott
black: make codebase compatible with black v21.4b2 and v20.8b1...
r47856 """returns of the good and bad signatures"""
Thomas Arendsen Hein
gpg extension: Always remove temporary files created by 'hg sigcheck'.
r2231 sigfile = datafile = None
Benoit Boissinot
gpg signing extension for hg...
r1592 try:
Benoit Boissinot
fixes for gpg.py extension...
r1681 # create temporary files
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 fd, sigfile = pycompat.mkstemp(prefix=b"hg-gpg-", suffix=b".sig")
Augie Fackler
cleanup: remove pointless r-prefixes on single-quoted strings...
r43906 fp = os.fdopen(fd, 'wb')
Benoit Boissinot
gpg signing extension for hg...
r1592 fp.write(sig)
fp.close()
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 fd, datafile = pycompat.mkstemp(prefix=b"hg-gpg-", suffix=b".txt")
Augie Fackler
cleanup: remove pointless r-prefixes on single-quoted strings...
r43906 fp = os.fdopen(fd, 'wb')
Benoit Boissinot
gpg signing extension for hg...
r1592 fp.write(data)
fp.close()
formatting: run black version 19.10b0 on the codebase...
r43663 gpgcmd = (
b"%s --logger-fd 1 --status-fd 1 --verify \"%s\" \"%s\""
Augie Fackler
formating: upgrade to black 20.8b1...
r46554 % (
self.path,
sigfile,
datafile,
)
Augie Fackler
formatting: blacken the codebase...
r43346 )
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ret = procutil.filter(b"", gpgcmd)
Thomas Arendsen Hein
gpg extension: Always remove temporary files created by 'hg sigcheck'.
r2231 finally:
Benoit Boissinot
gpg signing extension for hg...
r1592 for f in (sigfile, datafile):
try:
Matt Mackall
many, many trivial check-code fixups
r10282 if f:
os.unlink(f)
Brodie Rao
cleanup: replace naked excepts with more specific ones
r16688 except OSError:
Matt Mackall
many, many trivial check-code fixups
r10282 pass
Benoit Boissinot
gpg signing extension for hg...
r1592 keys = []
key, fingerprint = None, None
for l in ret.splitlines():
# see DETAILS in the gnupg documentation
# filter the logger output
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if not l.startswith(b"[GNUPG:]"):
Benoit Boissinot
gpg signing extension for hg...
r1592 continue
l = l[9:]
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if l.startswith(b"VALIDSIG"):
Benoit Boissinot
gpg signing extension for hg...
r1592 # fingerprint of the primary key
fingerprint = l.split()[10]
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 elif l.startswith(b"ERRSIG"):
key = l.split(b" ", 3)[:2]
key.append(b"")
Wei, Elson
gpg: treat "ERRSIG" as a valid key id but no fingerprint
r19441 fingerprint = None
Augie Fackler
formatting: blacken the codebase...
r43346 elif (
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 l.startswith(b"GOODSIG")
or l.startswith(b"EXPSIG")
or l.startswith(b"EXPKEYSIG")
or l.startswith(b"BADSIG")
Augie Fackler
formatting: blacken the codebase...
r43346 ):
Benoit Boissinot
gpg signing extension for hg...
r1592 if key is not None:
keys.append(key + [fingerprint])
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 key = l.split(b" ", 2)
Benoit Boissinot
gpg signing extension for hg...
r1592 fingerprint = None
if key is not None:
keys.append(key + [fingerprint])
Wei, Elson
gpg: getkeys() removes unused returning value "err"
r19442 return keys
Benoit Boissinot
gpg signing extension for hg...
r1592
Augie Fackler
formatting: blacken the codebase...
r43346
Benoit Boissinot
gpg signing extension for hg...
r1592 def newgpg(ui, **opts):
Benoit Boissinot
fixes for gpg.py extension...
r1681 """create a new gpg instance"""
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 gpgpath = ui.config(b"gpg", b"cmd")
Augie Fackler
cleanup: remove pointless r-prefixes on single-quoted strings...
r43906 gpgkey = opts.get('key')
Benoit Boissinot
gpg signing extension for hg...
r1592 if not gpgkey:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 gpgkey = ui.config(b"gpg", b"key")
Benoit Boissinot
gpg signing extension for hg...
r1592 return gpg(gpgpath, gpgkey)
Augie Fackler
formatting: blacken the codebase...
r43346
Benoit Boissinot
fixes for gpg.py extension...
r1681 def sigwalk(repo):
"""
walk over every sigs, yields a couple
((node, version, sig), (filename, linenumber))
"""
Augie Fackler
formatting: blacken the codebase...
r43346
Benoit Boissinot
fixes for gpg.py extension...
r1681 def parsefile(fileiter, context):
ln = 1
for l in fileiter:
if not l:
continue
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 yield (l.split(b" ", 2), (context, ln))
Benoit Boissinot
fix coding style (reported by pylint)
r10394 ln += 1
Benoit Boissinot
fixes for gpg.py extension...
r1681
Matt Mackall
replace various uses of list.reverse()
r8210 # read the heads
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 fl = repo.file(b".hgsigs")
Matt Mackall
replace various uses of list.reverse()
r8210 for r in reversed(fl.heads()):
Joerg Sonnenberger
node: import symbols explicitly...
r46729 fn = b".hgsigs|%s" % short(r)
Benoit Boissinot
fixes for gpg.py extension...
r1681 for item in parsefile(fl.read(r).splitlines(), fn):
yield item
try:
# read local signatures
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 fn = b"localsigs"
Angel Ezquerra
localrepo: remove all external users of localrepo.opener...
r23877 for item in parsefile(repo.vfs(fn), fn):
Benoit Boissinot
fixes for gpg.py extension...
r1681 yield item
except IOError:
pass
Augie Fackler
formatting: blacken the codebase...
r43346
Benoit Boissinot
fixes for gpg.py extension...
r1681 def getkeys(ui, repo, mygpg, sigdata, context):
"""get the keys who signed a data"""
fn, ln = context
node, version, sig = sigdata
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 prefix = b"%s:%d" % (fn, ln)
Joerg Sonnenberger
node: import symbols explicitly...
r46729 node = bin(node)
Benoit Boissinot
fixes for gpg.py extension...
r1681
data = node2txt(repo, node, version)
sig = binascii.a2b_base64(sig)
Wei, Elson
gpg: getkeys() removes unused returning value "err"
r19442 keys = mygpg.verify(data, sig)
Benoit Boissinot
fixes for gpg.py extension...
r1681
validkeys = []
# warn for expired key and/or sigs
for key in keys:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if key[0] == b"ERRSIG":
ui.write(_(b"%s Unknown key ID \"%s\"\n") % (prefix, key[1]))
Wei, Elson
gpg: show "Unknown key ID xxxxxxxx" when the status is ERRSIG
r19444 continue
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if key[0] == b"BADSIG":
ui.write(_(b"%s Bad signature from \"%s\"\n") % (prefix, key[2]))
Benoit Boissinot
fixes for gpg.py extension...
r1681 continue
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if key[0] == b"EXPSIG":
Augie Fackler
formatting: blacken the codebase...
r43346 ui.write(
Martin von Zweigbergk
cleanup: join string literals that are already on one line...
r43387 _(b"%s Note: Signature has expired (signed by: \"%s\")\n")
Augie Fackler
formatting: blacken the codebase...
r43346 % (prefix, key[2])
)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 elif key[0] == b"EXPKEYSIG":
Augie Fackler
formatting: blacken the codebase...
r43346 ui.write(
Martin von Zweigbergk
cleanup: join string literals that are already on one line...
r43387 _(b"%s Note: This key has expired (signed by: \"%s\")\n")
Augie Fackler
formatting: blacken the codebase...
r43346 % (prefix, key[2])
)
Benoit Boissinot
fixes for gpg.py extension...
r1681 validkeys.append((key[1], key[2], key[3]))
return validkeys
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 @command(b"sigs", [], _(b'hg sigs'), helpcategory=_HELP_CATEGORY)
Benoit Boissinot
fixes for gpg.py extension...
r1681 def sigs(ui, repo):
"""list signed changesets"""
mygpg = newgpg(ui)
revs = {}
for data, context in sigwalk(repo):
node, version, sig = data
fn, ln = context
try:
n = repo.lookup(node)
except KeyError:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.warn(_(b"%s:%d node does not exist\n") % (fn, ln))
Benoit Boissinot
fixes for gpg.py extension...
r1681 continue
r = repo.changelog.rev(n)
keys = getkeys(ui, repo, mygpg, data, context)
if not keys:
continue
revs.setdefault(r, [])
revs[r].extend(keys)
Martin Geisler
gpg: use reverse kwarg to sort sigs in reversed order
r8303 for rev in sorted(revs, reverse=True):
Benoit Boissinot
fix an exception in gpg.py with multiples sigs for the same cset...
r1682 for k in revs[rev]:
Joerg Sonnenberger
node: import symbols explicitly...
r46729 r = b"%5d:%s" % (rev, hex(repo.changelog.node(rev)))
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.write(b"%-30s %s\n" % (keystr(ui, k), r))
Benoit Boissinot
fixes for gpg.py extension...
r1681
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 @command(b"sigcheck", [], _(b'hg sigcheck REV'), helpcategory=_HELP_CATEGORY)
timeless
gpg: rename sigcheck function...
r27117 def sigcheck(ui, repo, rev):
Benoit Boissinot
gpg signing extension for hg...
r1592 """verify all the signatures there may be for a particular revision"""
mygpg = newgpg(ui)
rev = repo.lookup(rev)
Joerg Sonnenberger
node: import symbols explicitly...
r46729 hexrev = hex(rev)
Benoit Boissinot
gpg signing extension for hg...
r1592 keys = []
Benoit Boissinot
fixes for gpg.py extension...
r1681 for data, context in sigwalk(repo):
node, version, sig = data
if node == hexrev:
k = getkeys(ui, repo, mygpg, data, context)
if k:
keys.extend(k)
Benoit Boissinot
gpg signing extension for hg...
r1592
if not keys:
Joerg Sonnenberger
node: import symbols explicitly...
r46729 ui.write(_(b"no valid signature for %s\n") % short(rev))
Benoit Boissinot
gpg signing extension for hg...
r1592 return
Benoit Boissinot
fixes for gpg.py extension...
r1681
Benoit Boissinot
gpg signing extension for hg...
r1592 # print summary
Joerg Sonnenberger
node: import symbols explicitly...
r46729 ui.write(_(b"%s is signed by:\n") % short(rev))
Benoit Boissinot
fixes for gpg.py extension...
r1681 for key in keys:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.write(b" %s\n" % keystr(ui, key))
Benoit Boissinot
gpg signing extension for hg...
r1592
Augie Fackler
formatting: blacken the codebase...
r43346
Benoit Boissinot
fixes for gpg.py extension...
r1681 def keystr(ui, key):
"""associate a string to a key (username, comment)"""
keyid, user, fingerprint = key
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 comment = ui.config(b"gpg", fingerprint)
Benoit Boissinot
fixes for gpg.py extension...
r1681 if comment:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 return b"%s (%s)" % (user, comment)
Benoit Boissinot
fixes for gpg.py extension...
r1681 else:
return user
Benoit Boissinot
gpg signing extension for hg...
r1592
Augie Fackler
formatting: blacken the codebase...
r43346
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"sign",
Augie Fackler
formatting: blacken the codebase...
r43346 [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'l', b'local', None, _(b'make the signature local')),
(b'f', b'force', None, _(b'sign even if the sigfile is modified')),
(
b'',
b'no-commit',
None,
_(b'do not commit the sigfile after signing'),
),
(b'k', b'key', b'', _(b'the key id to sign with'), _(b'ID')),
(b'm', b'message', b'', _(b'use text as commit message'), _(b'TEXT')),
(b'e', b'edit', False, _(b'invoke editor on commit messages')),
Augie Fackler
formatting: blacken the codebase...
r43346 ]
+ cmdutil.commitopts2,
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'hg sign [OPTION]... [REV]...'),
Augie Fackler
formatting: blacken the codebase...
r43346 helpcategory=_HELP_CATEGORY,
)
Benoit Boissinot
gpg signing extension for hg...
r1592 def sign(ui, repo, *revs, **opts):
Thomas Arendsen Hein
Make 'hg sign' behave like other commands: Default to current parent.
r3916 """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.
Thomas Arendsen Hein
Document log date ranges and mention 'hg help dates' for all commands (issue998)
r6163
Matt Mackall
gpg: mention undocumented options
r25791 The ``gpg.cmd`` config setting can be used to specify the command
to run. A default key can be specified with ``gpg.key``.
Martin Geisler
Use our custom hg reStructuredText role some more...
r11193 See :hg:`help dates` for a list of formats valid for -d/--date.
Thomas Arendsen Hein
Make 'hg sign' behave like other commands: Default to current parent.
r3916 """
Bryan O'Sullivan
with: use context manager for wlock in sign
r27814 with repo.wlock():
FUJIWARA Katsunori
gpg: make sign acquire wlock before processing...
r27196 return _dosign(ui, repo, *revs, **opts)
Thomas Arendsen Hein
Make 'hg sign' behave like other commands: Default to current parent.
r3916
Augie Fackler
formatting: blacken the codebase...
r43346
FUJIWARA Katsunori
gpg: make sign acquire wlock before processing...
r27196 def _dosign(ui, repo, *revs, **opts):
Benoit Boissinot
gpg signing extension for hg...
r1592 mygpg = newgpg(ui, **opts)
Pulkit Goyal
py3: handle keyword arguments in hgext/gpg.py...
r34979 opts = pycompat.byteskwargs(opts)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 sigver = b"0"
sigmessage = b""
Thomas Arendsen Hein
Fix bad behaviour when specifying an invalid date (issue700)...
r6139
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 date = opts.get(b'date')
Thomas Arendsen Hein
Fix bad behaviour when specifying an invalid date (issue700)...
r6139 if date:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 opts[b'date'] = dateutil.parsedate(date)
Thomas Arendsen Hein
Fix bad behaviour when specifying an invalid date (issue700)...
r6139
Benoit Boissinot
gpg signing extension for hg...
r1592 if revs:
nodes = [repo.lookup(n) for n in revs]
else:
Joerg Sonnenberger
node: replace nullid and friends with nodeconstants class...
r47771 nodes = [
node for node in repo.dirstate.parents() if node != repo.nullid
]
Thomas Arendsen Hein
Make 'hg sign' behave like other commands: Default to current parent.
r3916 if len(nodes) > 1:
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Martin von Zweigbergk
cleanup: join string literals that are already on one line...
r43387 _(b'uncommitted merge - please provide a specific revision')
Augie Fackler
formatting: blacken the codebase...
r43346 )
Thomas Arendsen Hein
Make 'hg sign' behave like other commands: Default to current parent.
r3916 if not nodes:
nodes = [repo.changelog.tip()]
Benoit Boissinot
gpg signing extension for hg...
r1592
for n in nodes:
Joerg Sonnenberger
node: import symbols explicitly...
r46729 hexnode = hex(n)
ui.write(_(b"signing %d:%s\n") % (repo.changelog.rev(n), short(n)))
Benoit Boissinot
gpg signing extension for hg...
r1592 # build data
data = node2txt(repo, n, sigver)
sig = mygpg.sign(data)
if not sig:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b"error while signing"))
Benoit Boissinot
gpg signing extension for hg...
r1592 sig = binascii.b2a_base64(sig)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 sig = sig.replace(b"\n", b"")
sigmessage += b"%s %s %s\n" % (hexnode, sigver, sig)
Benoit Boissinot
gpg signing extension for hg...
r1592
# write it
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts[b'local']:
repo.vfs.append(b"localsigs", sigmessage)
Benoit Boissinot
gpg signing extension for hg...
r1592 return
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if not opts[b"force"]:
msigs = match.exact([b'.hgsigs'])
Augie Fackler
cleanup: use __builtins__.any instead of util.any...
r25149 if any(repo.status(match=msigs, unknown=True, ignored=True)):
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b"working copy of .hgsigs is changed "),
hint=_(b"please commit .hgsigs manually"),
Augie Fackler
formatting: blacken the codebase...
r43346 )
Benoit Boissinot
gpg signing extension for hg...
r1592
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 sigsfile = repo.wvfs(b".hgsigs", b"ab")
Dan Villiom Podlaski Christiansen
explicitly close files...
r13400 sigsfile.write(sigmessage)
sigsfile.close()
Benoit Boissinot
gpg signing extension for hg...
r1592
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if b'.hgsigs' not in repo.dirstate:
dirstate: use `dirstate.change_files` to scope the change in `gpg`...
r50932 with repo.dirstate.changing_files(repo):
repo[None].add([b".hgsigs"])
Benoit Boissinot
gpg signing extension for hg...
r1592
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts[b"no_commit"]:
Benoit Boissinot
gpg signing extension for hg...
r1592 return
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 message = opts[b'message']
Benoit Boissinot
gpg signing extension for hg...
r1592 if not message:
Martin Geisler
do not translate commit messages...
r9183 # we don't translate commit messages
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 message = b"\n".join(
Joerg Sonnenberger
node: import symbols explicitly...
r46729 [b"Added signature for changeset %s" % short(n) for n in nodes]
Augie Fackler
formatting: blacken the codebase...
r43346 )
Benoit Boissinot
gpg signing extension for hg...
r1592 try:
Augie Fackler
formatting: blacken the codebase...
r43346 editor = cmdutil.getcommiteditor(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 editform=b'gpg.sign', **pycompat.strkwargs(opts)
Augie Fackler
formatting: blacken the codebase...
r43346 )
repo.commit(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 message, opts[b'user'], opts[b'date'], match=msigs, editor=editor
Augie Fackler
formatting: blacken the codebase...
r43346 )
Gregory Szorc
global: mass rewrite to use modern exception syntax...
r25660 except ValueError as inst:
Pulkit Goyal
py3: use pycompat.bytestr() to convert error messages to bytes...
r36671 raise error.Abort(pycompat.bytestr(inst))
Benoit Boissinot
gpg signing extension for hg...
r1592
Augie Fackler
formatting: blacken the codebase...
r43346
Benoit Boissinot
gpg signing extension for hg...
r1592 def node2txt(repo, node, ver):
"""map a manifest into some text"""
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if ver == b"0":
Joerg Sonnenberger
node: import symbols explicitly...
r46729 return b"%s\n" % hex(node)
Benoit Boissinot
gpg signing extension for hg...
r1592 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b"unknown signature version"))
rdamazio@google.com
help: assigning categories to existing commands...
r40329
Augie Fackler
formatting: blacken the codebase...
r43346
rdamazio@google.com
help: assigning categories to existing commands...
r40329 def extsetup(ui):
# Add our category before "Repository maintenance".
help.CATEGORY_ORDER.insert(
Augie Fackler
formatting: blacken the codebase...
r43346 help.CATEGORY_ORDER.index(command.CATEGORY_MAINTENANCE), _HELP_CATEGORY
)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 help.CATEGORY_NAMES[_HELP_CATEGORY] = b'GPG signing'