~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/config.py

  • Committer: John Arbash Meinel
  • Date: 2005-12-01 19:57:43 UTC
  • mto: (1185.50.19 bzr-jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1532.
  • Revision ID: john@arbash-meinel.com-20051201195743-57aefc694d237938
Reintroduced ensure_config_dir_exists() for sftp

Show diffs side-by-side

added added

removed removed

Lines of Context:
351
351
        # FIXME: RBC 20051029 This should refresh the parser and also take a
352
352
        # file lock on branches.conf.
353
353
        conf_dir = os.path.dirname(self._get_filename())
354
 
        if not os.path.isdir(conf_dir):
355
 
            if sys.platform == 'win32':
356
 
                parent_dir = os.path.dirname(conf_dir)
357
 
                if not os.path.isdir(parent_dir):
358
 
                    mutter('creating config parent directory: %r', parent_dir)
359
 
                os.mkdir(parent_dir)
360
 
            mutter('creating config directory: %r', conf_dir)
361
 
            os.mkdir(conf_dir)
 
354
        ensure_config_dir_exists(conf_dir)
362
355
        location = self.location
363
356
        if location.endswith('/'):
364
357
            location = location[:-1]
417
410
        return self._get_location_config()._post_commit()
418
411
 
419
412
 
 
413
def ensure_config_dir_exists(path=None):
 
414
    """Make sure a configuration directory exists.
 
415
    This makes sure that the directory exists.
 
416
    On windows, since configuration directories are 2 levels deep,
 
417
    it makes sure both the directory and the parent directory exists.
 
418
    """
 
419
    if path is None:
 
420
        path = config_dir()
 
421
    if not os.path.isdir(path):
 
422
        if sys.platform == 'win32':
 
423
            parent_dir = os.path.dirname(path)
 
424
            if not os.path.isdir(parent_dir):
 
425
                mutter('creating config parent directory: %r', parent_dir)
 
426
            os.mkdir(parent_dir)
 
427
        mutter('creating config directory: %r', path)
 
428
        os.mkdir(path)
 
429
 
420
430
def config_dir():
421
431
    """Return per-user configuration directory.
422
432