/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 brzlib/config.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-21 18:06:19 UTC
  • mto: This revision was merged to the branch mainline in revision 6623.
  • Revision ID: jelmer@jelmer.uk-20170521180619-5qoo0470asgdnljt
Fix more tests (all?)

Show diffs side-by-side

added added

removed removed

Lines of Context:
586
586
 
587
587
    def get_bzr_remote_path(self):
588
588
        try:
589
 
            return os.environ['BRZ_REMOTE_PATH']
 
589
            return os.environ['BZR_REMOTE_PATH']
590
590
        except KeyError:
591
 
            path = self.get_user_option("brz_remote_path")
 
591
            path = self.get_user_option("bzr_remote_path")
592
592
            if path is None:
593
593
                path = 'bzr'
594
594
            return path
609
609
    def get_merge_tools(self):
610
610
        tools = {}
611
611
        for (oname, value, section, conf_id, parser) in self._get_options():
612
 
            if oname.startswith('brz.mergetool.'):
613
 
                tool_name = oname[len('brz.mergetool.'):]
 
612
            if oname.startswith('bzr.mergetool.'):
 
613
                tool_name = oname[len('bzr.mergetool.'):]
614
614
                tools[tool_name] = self.get_user_option(oname, False)
615
615
        trace.mutter('loaded merge tools: %r' % tools)
616
616
        return tools
620
620
        # be found in the known_merge_tools if it's not found in the config.
621
621
        # This should be done through the proposed config defaults mechanism
622
622
        # when it becomes available in the future.
623
 
        command_line = (self.get_user_option('brz.mergetool.%s' % name,
 
623
        command_line = (self.get_user_option('bzr.mergetool.%s' % name,
624
624
                                             expand=False)
625
625
                        or mergetools.known_merge_tools.get(name, None))
626
626
        return command_line
1484
1484
        osutils.copy_ownership_from_path(path)
1485
1485
 
1486
1486
 
1487
 
def config_dir():
 
1487
def bazaar_config_dir():
1488
1488
    """Return per-user configuration directory as unicode string
1489
1489
 
1490
1490
    By default this is %APPDATA%/bazaar/2.0 on Windows, ~/.bazaar on Mac OS X
1493
1493
 
1494
1494
    TODO: Global option --config-dir to override this.
1495
1495
    """
1496
 
    base = osutils.path_from_environ('BRZ_HOME')
 
1496
    base = osutils.path_from_environ('BZR_HOME')
1497
1497
    if sys.platform == 'win32':
1498
1498
        if base is None:
1499
1499
            base = win32utils.get_appdata_location()
1515
1515
    return osutils.pathjoin(base, ".bazaar")
1516
1516
 
1517
1517
 
 
1518
def config_dir():
 
1519
    """Return per-user configuration directory as unicode string
 
1520
 
 
1521
    By default this is %APPDATA%/breezy on Windows, $XDG_CONFIG_HOME/breezy on
 
1522
    Mac OS X and Linux. If the breezy config directory doesn't exist but
 
1523
    the bazaar one (see bazaar_config_dir()) does, use that instead.
 
1524
 
 
1525
    TODO: Global option --config-dir to override this.
 
1526
    """
 
1527
    base = osutils.path_from_environ('BRZ_HOME')
 
1528
    if sys.platform == 'win32':
 
1529
        if base is None:
 
1530
            base = win32utils.get_appdata_location()
 
1531
        if base is None:
 
1532
            base = win32utils.get_home_location()
 
1533
        # GZ 2012-02-01: Really the two level subdirs only make sense inside
 
1534
        #                APPDATA, but hard to move. See bug 348640 for more.
 
1535
    if base is None:
 
1536
        base = osutils.path_from_environ('XDG_CONFIG_HOME')
 
1537
        if base is None:
 
1538
            base = osutils.pathjoin(osutils._get_home_dir(), ".config")
 
1539
    breezy_dir = osutils.pathjoin(base, 'breezy')
 
1540
    if osutils.isdir(breezy_dir):
 
1541
        return breezy_dir
 
1542
    # If the breezy directory doesn't exist, but the bazaar one does, use that:
 
1543
    bazaar_dir = bazaar_config_dir()
 
1544
    if osutils.isdir(bazaar_dir):
 
1545
        trace.mutter(
 
1546
            "Using Bazaar configuration directory (%s)", bazaar_dir)
 
1547
        return bazaar_dir
 
1548
    return breezy_dir
 
1549
 
 
1550
 
1518
1551
def config_filename():
1519
1552
    """Return per-user configuration ini file filename."""
1520
1553
    return osutils.pathjoin(config_dir(), 'bazaar.conf')