~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/rules.py

  • Committer: John Arbash Meinel
  • Date: 2009-11-18 15:47:16 UTC
  • mto: This revision was merged to the branch mainline in revision 4810.
  • Revision ID: john@arbash-meinel.com-20091118154716-meiszr5ej7ohas3v
Move all the stat comparison and platform checkning code to assertEqualStat.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2008 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
19
19
See ``bzr help rules`` for details.
20
20
"""
21
21
 
22
 
from __future__ import absolute_import
23
 
 
24
22
from bzrlib import (
25
23
    config,
26
 
    cmdline,
 
24
    commands,
27
25
    errors,
28
26
    globbing,
29
27
    osutils,
66
64
        """
67
65
        raise NotImplementedError(self.get_selected_items)
68
66
 
69
 
    def get_single_value(self, path, preference_name):
70
 
        """Get a single preference for a single file.
71
 
        
72
 
        :returns: The string preference value, or None.
73
 
        """
74
 
        for key, value in self.get_selected_items(path, [preference_name]):
75
 
            return value
76
 
        return None
77
 
 
78
67
 
79
68
class _IniBasedRulesSearcher(_RulesSearcher):
80
69
 
85
74
 
86
75
        :param inifile: the name of the file or a sequence of lines.
87
76
        """
88
 
        self._cfg = configobj.ConfigObj(inifile, encoding='utf-8')
 
77
        options = {'encoding': 'utf-8'}
 
78
        self._cfg = configobj.ConfigObj(inifile, options=options)
89
79
        sections = self._cfg.keys()
90
80
        patterns = []
91
81
        self.pattern_to_section = {}
92
82
        for s in sections:
93
83
            if s.startswith(FILE_PREFS_PREFIX):
94
 
                file_patterns = cmdline.split(s[FILE_PREFS_PREFIX_LEN:])
 
84
                file_patterns = commands.shlex_split_unicode(
 
85
                    s[FILE_PREFS_PREFIX_LEN:])
95
86
                patterns.extend(file_patterns)
96
87
                for fp in file_patterns:
97
88
                    self.pattern_to_section[fp] = s