comparison hgext/gpg.py @ 10517:13448eab08ca stable

gpg: do not call status on the whole repository, only on '.hgsigs'
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Sat, 20 Feb 2010 15:18:59 +0100
parents f77f3383c666
children e4a8ae4659d3
comparison
equal deleted inserted replaced
10516:80a1161bc3b5 10517:13448eab08ca
4 # GNU General Public License version 2 or any later version. 4 # GNU General Public License version 2 or any later version.
5 5
6 '''commands to sign and verify changesets''' 6 '''commands to sign and verify changesets'''
7 7
8 import os, tempfile, binascii 8 import os, tempfile, binascii
9 from mercurial import util, commands, match 9 from mercurial import util, commands, match, cmdutil
10 from mercurial import node as hgnode 10 from mercurial import node as hgnode
11 from mercurial.i18n import _ 11 from mercurial.i18n import _
12 12
13 class gpg(object): 13 class gpg(object):
14 def __init__(self, path, key=None): 14 def __init__(self, path, key=None):
235 # write it 235 # write it
236 if opts['local']: 236 if opts['local']:
237 repo.opener("localsigs", "ab").write(sigmessage) 237 repo.opener("localsigs", "ab").write(sigmessage)
238 return 238 return
239 239
240 for x in repo.status(unknown=True)[:5]: 240 msigs = cmdutil.matchfiles(repo, ['.hgsigs'])
241 if ".hgsigs" in x and not opts["force"]: 241 s = repo.status(match=msigs, unknown=True, ignored=True)[:6]
242 raise util.Abort(_("working copy of .hgsigs is changed " 242 if util.any(s) and not opts["force"]:
243 "(please commit .hgsigs manually " 243 raise util.Abort(_("working copy of .hgsigs is changed "
244 "or use --force)")) 244 "(please commit .hgsigs manually "
245 "or use --force)"))
245 246
246 repo.wfile(".hgsigs", "ab").write(sigmessage) 247 repo.wfile(".hgsigs", "ab").write(sigmessage)
247 248
248 if '.hgsigs' not in repo.dirstate: 249 if '.hgsigs' not in repo.dirstate:
249 repo.add([".hgsigs"]) 250 repo.add([".hgsigs"])
256 # we don't translate commit messages 257 # we don't translate commit messages
257 message = "\n".join(["Added signature for changeset %s" 258 message = "\n".join(["Added signature for changeset %s"
258 % hgnode.short(n) 259 % hgnode.short(n)
259 for n in nodes]) 260 for n in nodes])
260 try: 261 try:
261 m = match.exact(repo.root, '', ['.hgsigs']) 262 repo.commit(message, opts['user'], opts['date'], match=msigs)
262 repo.commit(message, opts['user'], opts['date'], match=m)
263 except ValueError, inst: 263 except ValueError, inst:
264 raise util.Abort(str(inst)) 264 raise util.Abort(str(inst))
265 265
266 def node2txt(repo, node, ver): 266 def node2txt(repo, node, ver):
267 """map a manifest into some text""" 267 """map a manifest into some text"""