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

  • Committer: Jelmer Vernooij
  • Date: 2020-08-22 22:46:24 UTC
  • mfrom: (7490.40.105 work)
  • mto: This revision was merged to the branch mainline in revision 7521.
  • Revision ID: jelmer@jelmer.uk-20200822224624-om4a4idsr7cn8jew
merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
class NoFinalPath(BzrError):
66
66
 
67
67
    _fmt = ("No final name for trans_id %(trans_id)r\n"
68
 
            "file-id: %(file_id)r\n"
69
68
            "root trans-id: %(root_trans_id)r\n")
70
69
 
71
70
    def __init__(self, trans_id, transform):
72
71
        self.trans_id = trans_id
73
 
        self.file_id = transform.final_file_id(trans_id)
74
72
        self.root_trans_id = transform.root
75
73
 
76
74
 
235
233
 
236
234
    def create_path(self, name, parent):
237
235
        """Assign a transaction id to a new path"""
238
 
        trans_id = self._assign_id()
 
236
        trans_id = self.assign_id()
239
237
        unique_add(self._new_name, trans_id, name)
240
238
        unique_add(self._new_parent, trans_id, parent)
241
239
        return trans_id
244
242
        """Change the path that is assigned to a transaction id."""
245
243
        if parent is None:
246
244
            raise ValueError("Parent trans-id may not be None")
247
 
        if trans_id == self._new_root:
 
245
        if trans_id == self.root:
248
246
            raise CantMoveRoot
249
247
        self._new_name[trans_id] = name
250
248
        self._new_parent[trans_id] = parent
273
271
        """
274
272
        raise NotImplementedError(self.fixup_new_roots)
275
273
 
276
 
    def _assign_id(self):
 
274
    def assign_id(self):
277
275
        """Produce a new tranform id"""
278
276
        new_id = "new-%s" % self._id_number
279
277
        self._id_number += 1
283
281
        """Determine (and maybe set) the transaction ID for a tree path."""
284
282
        path = self.canonical_path(path)
285
283
        if path not in self._tree_path_ids:
286
 
            self._tree_path_ids[path] = self._assign_id()
 
284
            self._tree_path_ids[path] = self.assign_id()
287
285
            self._tree_id_paths[self._tree_path_ids[path]] = path
288
286
        return self._tree_path_ids[path]
289
287
 
350
348
            contents insertion command)
351
349
        """
352
350
        if trans_id in self._new_contents:
 
351
            if trans_id in self._new_reference_revision:
 
352
                return 'tree-reference'
353
353
            return self._new_contents[trans_id]
354
354
        elif trans_id in self._removed_contents:
355
355
            return None
620
620
        self.transform = transform
621
621
 
622
622
    def _determine_path(self, trans_id):
623
 
        if (trans_id == self.transform.root or trans_id == ROOT_PARENT):
 
623
        if trans_id == self.transform.root or trans_id == ROOT_PARENT:
624
624
            return u""
625
625
        name = self.transform.final_name(trans_id)
626
626
        parent_id = self.transform.final_parent(trans_id)
1233
1233
def resolve_non_directory_parent(tt, path_tree, c_type, parent_id):
1234
1234
    parent_parent = tt.final_parent(parent_id)
1235
1235
    parent_name = tt.final_name(parent_id)
1236
 
    parent_file_id = tt.final_file_id(parent_id)
 
1236
    # TODO(jelmer): Make this code transform-specific
 
1237
    if tt._tree.supports_setting_file_ids():
 
1238
        parent_file_id = tt.final_file_id(parent_id)
 
1239
    else:
 
1240
        parent_file_id = b'DUMMY'
1237
1241
    new_parent_id = tt.new_directory(parent_name + '.new',
1238
1242
                                     parent_parent, parent_file_id)
1239
1243
    _reparent_transform_children(tt, parent_id, new_parent_id)
1354
1358
        self._all_children_cache = {}
1355
1359
        self._final_name_cache = {}
1356
1360
 
 
1361
    def supports_setting_file_ids(self):
 
1362
        raise NotImplementedError(self.supports_setting_file_ids)
 
1363
 
1357
1364
    @property
1358
1365
    def _by_parent(self):
1359
1366
        if self.__by_parent is None:
1380
1387
        pass
1381
1388
 
1382
1389
    def _path2trans_id(self, path):
 
1390
        """Look up the trans id associated with a path.
 
1391
 
 
1392
        :param path: path to look up, None when the path does not exist
 
1393
        :return: trans_id
 
1394
        """
1383
1395
        # We must not use None here, because that is a valid value to store.
1384
1396
        trans_id = self._path2trans_id_cache.get(path, object)
1385
1397
        if trans_id is not object: