/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/gpg.py

  • Committer: Robert Collins
  • Date: 2006-09-07 08:46:18 UTC
  • mto: (1991.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1992.
  • Revision ID: robertc@robertcollins.net-20060907084618-fae5efc1ca3c108d
When an entire subtree has been deleted, commit will now report that
just the top of the subtree has been deleted, rather than reporting
all the individual items. (Robert Collins)

Commit performs one less XML parse. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 Canonical Ltd
 
1
# Copyright (C) 2005 by Canonical Ltd
2
2
#   Authors: Robert Collins <robert.collins@canonical.com>
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
13
13
#
14
14
# You should have received a copy of the GNU General Public License
15
15
# along with this program; if not, write to the Free Software
16
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
17
 
18
18
"""GPG signing and checking logic."""
19
19
 
 
20
import errno
20
21
import os
21
 
import sys
22
 
 
23
 
from bzrlib.lazy_import import lazy_import
24
 
lazy_import(globals(), """
25
 
import errno
26
22
import subprocess
27
23
 
28
24
from bzrlib import (
30
26
    trace,
31
27
    ui,
32
28
    )
33
 
""")
34
29
 
35
30
 
36
31
class DisabledGPGStrategy(object):
50
45
        """Real strategies take a configuration."""
51
46
 
52
47
    def sign(self, content):
53
 
        return ("-----BEGIN PSEUDO-SIGNED CONTENT-----\n" + content +
54
 
                "-----END PSEUDO-SIGNED CONTENT-----\n")
 
48
        return content
55
49
 
56
50
 
57
51
def _set_gpg_tty():
69
63
 
70
64
class GPGStrategy(object):
71
65
    """GPG Signing and checking facilities."""
72
 
 
 
66
        
73
67
    def _command_line(self):
74
68
        return [self._config.gpg_signing_command(), '--clearsign']
75
69
 
77
71
        self._config = config
78
72
 
79
73
    def sign(self, content):
80
 
        if isinstance(content, unicode):
81
 
            raise errors.BzrBadParameterUnicode('content')
82
74
        ui.ui_factory.clear_term()
83
 
 
84
 
        preexec_fn = _set_gpg_tty
85
 
        if sys.platform == 'win32':
86
 
            # Win32 doesn't support preexec_fn, but wouldn't support TTY anyway.
87
 
            preexec_fn = None
88
75
        try:
89
76
            process = subprocess.Popen(self._command_line(),
90
77
                                       stdin=subprocess.PIPE,
91
78
                                       stdout=subprocess.PIPE,
92
 
                                       preexec_fn=preexec_fn)
 
79
                                       preexec_fn=_set_gpg_tty)
93
80
            try:
94
81
                result = process.communicate(content)[0]
95
82
                if process.returncode is None: