~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/config.py

[merge] robert

Show diffs side-by-side

added added

removed removed

Lines of Context:
348
348
            return hook
349
349
        return self._get_global_config()._post_commit()
350
350
 
 
351
    def set_user_option(self, option, value):
 
352
        """Save option and its value in the configuration."""
 
353
        # FIXME: RBC 20051029 This should refresh the parser and also take a
 
354
        # file lock on branches.conf.
 
355
        if not os.path.isdir(os.path.dirname(self._get_filename())):
 
356
            os.mkdir(os.path.dirname(self._get_filename()))
 
357
        location = self.location
 
358
        if location.endswith('/'):
 
359
            location = location[:-1]
 
360
        if (not location in self._get_parser() and
 
361
            not location + '/' in self._get_parser()):
 
362
            self._get_parser()[location]={}
 
363
        elif location + '/' in self._get_parser():
 
364
            location = location + '/'
 
365
        self._get_parser()[location][option]=value
 
366
        self._get_parser().write()
 
367
 
351
368
 
352
369
class BranchConfig(Config):
353
370
    """A configuration object giving the policy for a branch."""