~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Martin Pool
  • Date: 2005-04-15 02:34:07 UTC
  • Revision ID: mbp@sourcefrog.net-20050415023407-986a296162e726d7
- Take email from ~/.bzr.conf/email

Show diffs side-by-side

added added

removed removed

Lines of Context:
129
129
            'sha1': s.hexdigest()}
130
130
 
131
131
 
 
132
def config_dir():
 
133
    """Return per-user configuration directory.
 
134
 
 
135
    By default this is ~/.bzr.conf/
 
136
    
 
137
    TODO: Global option --config-dir to override this.
 
138
    """
 
139
    return os.path.expanduser("~/.bzr.conf")
 
140
 
 
141
 
132
142
def _auto_user_id():
133
143
    """Calculate automatic user identification.
134
144
 
166
176
 
167
177
 
168
178
def _get_user_id():
 
179
    """Return the full user id from a file or environment variable.
 
180
 
 
181
    TODO: Allow taking this from a file in the branch directory too
 
182
    for per-branch ids."""
169
183
    v = os.environ.get('BZREMAIL')
170
184
    if v:
171
185
        return v.decode(bzrlib.user_encoding)
172
186
    
173
187
    try:
174
 
        return (open(os.path.expanduser("~/.bzr.email"))
 
188
        return (open(os.path.join(config_dir(), "email"))
175
189
                .read()
176
190
                .decode(bzrlib.user_encoding)
177
191
                .rstrip("\r\n"))
192
206
    Something similar to 'Martin Pool <mbp@sourcefrog.net>'
193
207
 
194
208
    TODO: Check it's reasonably well-formed.
195
 
 
196
 
    TODO: Allow taking it from a dotfile to help people on windows
197
 
           who can't easily set variables.
198
209
    """
199
210
    v = _get_user_id()
200
211
    if v: