/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 breezy/plugins/fastimport/helpers.py

  • Committer: Jelmer Vernooij
  • Date: 2020-03-22 01:35:14 UTC
  • mfrom: (7490.7.6 work)
  • mto: This revision was merged to the branch mainline in revision 7499.
  • Revision ID: jelmer@jelmer.uk-20200322013514-7vw1ntwho04rcuj3
merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
"""Miscellaneous useful stuff."""
17
17
 
18
 
from __future__ import absolute_import
19
 
 
20
18
import stat
21
19
 
22
20
from ... import (
54
52
    """
55
53
    # Based on code from breezy/info.py ...
56
54
    repo_format = repo._format
57
 
    candidates  = []
 
55
    candidates = []
58
56
    non_aliases = set(controldir.format_registry.keys())
59
57
    non_aliases.difference_update(controldir.format_registry.aliases())
60
58
    for key in non_aliases:
97
95
        contents = os.listdir(location)
98
96
        if contents:
99
97
            errors.BzrCommandError("Destination must have a .bzr directory, "
100
 
                " not yet exist or be empty - files found in %s" % (location,))
 
98
                                   " not yet exist or be empty - files found in %s" % (location,))
101
99
    else:
102
100
        try:
103
101
            os.mkdir(location)
104
102
        except IOError as ex:
105
 
            errors.BzrCommandError("Unable to create %s: %s" %
106
 
                (location, ex))
 
103
            raise errors.BzrCommandError(
 
104
                "Unable to create %s: %s" % (location, ex))
107
105
 
108
106
    # Create a repository for the nominated format.
109
107
    trace.note("Creating destination repository ...")
121
119
 
122
120
def kind_to_mode(kind, executable):
123
121
    if kind == "file":
124
 
        if executable == True:
 
122
        if executable is True:
125
123
            return stat.S_IFREG | 0o755
126
 
        elif executable == False:
 
124
        elif executable is False:
127
125
            return stat.S_IFREG | 0o644
128
126
        else:
129
127
            raise AssertionError("Executable %r invalid" % executable)
178
176
        return single
179
177
    else:
180
178
        return plural
181
 
 
182
 
 
183
 
def invert_dictset(d):
184
 
    """Invert a dictionary with keys matching a set of values, turned into lists."""
185
 
    # Based on recipe from ASPN
186
 
    result = {}
187
 
    for k, c in d.items():
188
 
        for v in c:
189
 
            keys = result.setdefault(v, [])
190
 
            keys.append(k)
191
 
    return result
192
 
 
193
 
 
194
 
def invert_dict(d):
195
 
    """Invert a dictionary with keys matching each value turned into a list."""
196
 
    # Based on recipe from ASPN
197
 
    result = {}
198
 
    for k, v in d.items():
199
 
        keys = result.setdefault(v, [])
200
 
        keys.append(k)
201
 
    return result
202
 
 
203