/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/rename_map.py

  • Committer: Jelmer Vernooij
  • Date: 2017-06-08 00:00:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6672.
  • Revision ID: jelmer@jelmer.uk-20170608000028-e3ggtt4wjbcjh91j
Drop pycurl support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
 
18
 
from cStringIO import StringIO
19
 
 
20
 
from bzrlib import (
 
17
from __future__ import absolute_import
 
18
 
 
19
 
 
20
from . import (
21
21
    osutils,
22
22
    progress,
23
23
    trace,
24
 
)
25
 
from bzrlib.ui import ui_factory
26
 
 
 
24
    )
 
25
from .i18n import gettext
 
26
from .sixish import (
 
27
    BytesIO,
 
28
    viewitems,
 
29
    )
 
30
from .ui import ui_factory
27
31
 
28
32
class RenameMap(object):
29
33
    """Determine a mapping of renames."""
65
69
        try:
66
70
            for num, (file_id, contents) in enumerate(
67
71
                tree.iter_files_bytes(desired_files)):
68
 
                task.update('Calculating hashes', num, len(file_ids))
69
 
                s = StringIO()
 
72
                task.update(gettext('Calculating hashes'), num, len(file_ids))
 
73
                s = BytesIO()
70
74
                s.writelines(contents)
71
75
                s.seek(0)
72
76
                self.add_edge_hashes(s.readlines(), file_id)
103
107
        task = ui_factory.nested_progress_bar()
104
108
        try:
105
109
            for num, path in enumerate(paths):
106
 
                task.update('Determining hash hits', num, len(paths))
 
110
                task.update(gettext('Determining hash hits'), num, len(paths))
107
111
                hits = self.hitcounts(self.tree.get_file_lines(None,
108
112
                                                               path=path))
109
 
                all_hits.extend((v, path, k) for k, v in hits.items())
 
113
                all_hits.extend((v, path, k) for k, v in viewitems(hits))
110
114
        finally:
111
115
            task.finished()
112
116
        return all_hits
147
151
                    break
148
152
                required_parents.setdefault(path, []).append(child)
149
153
        require_ids = {}
150
 
        for parent, children in required_parents.iteritems():
 
154
        for parent, children in viewitems(required_parents):
151
155
            child_file_ids = set()
152
156
            for child in children:
153
157
                file_id = matches.get(child)
164
168
        parent directories.
165
169
        """
166
170
        all_hits = []
167
 
        for file_id, file_id_children in missing_parents.iteritems():
168
 
            for path, path_children in required_parents.iteritems():
 
171
        for file_id, file_id_children in viewitems(missing_parents):
 
172
            for path, path_children in viewitems(required_parents):
169
173
                hits = len(path_children.intersection(file_id_children))
170
174
                if hits > 0:
171
175
                    all_hits.append((hits, path, file_id))
238
242
            pp.next_phase()
239
243
            delta = rn._make_inventory_delta(matches)
240
244
            for old, new, file_id, entry in delta:
241
 
                trace.note("%s => %s", old, new)
 
245
                trace.note( gettext("{0} => {1}").format(old, new) )
242
246
            if not dry_run:
243
247
                tree.add(required_parents)
244
248
                tree.apply_inventory_delta(delta)
247
251
 
248
252
    def _make_inventory_delta(self, matches):
249
253
        delta = []
250
 
        file_id_matches = dict((f, p) for p, f in matches.items())
251
 
        for old_path, entry in self.tree.iter_entries_by_dir(matches.values()):
 
254
        file_id_matches = dict((f, p) for p, f in viewitems(matches))
 
255
        for old_path, entry in self.tree.iter_entries_by_dir(file_id_matches):
252
256
            new_path = file_id_matches[entry.file_id]
253
257
            parent_path, new_name = osutils.split(new_path)
254
258
            parent_id = matches.get(parent_path)