/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

Some improvements for transform and tests for GitTransform.

Merged from https://code.launchpad.net/~jelmer/brz/transform-1/+merge/389367

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
class NoFinalPath(BzrError):
73
73
 
74
74
    _fmt = ("No final name for trans_id %(trans_id)r\n"
75
 
            "file-id: %(file_id)r\n"
76
75
            "root trans-id: %(root_trans_id)r\n")
77
76
 
78
77
    def __init__(self, trans_id, transform):
79
78
        self.trans_id = trans_id
80
 
        self.file_id = transform.final_file_id(trans_id)
81
79
        self.root_trans_id = transform.root
82
80
 
83
81
 
242
240
 
243
241
    def create_path(self, name, parent):
244
242
        """Assign a transaction id to a new path"""
245
 
        trans_id = self._assign_id()
 
243
        trans_id = self.assign_id()
246
244
        unique_add(self._new_name, trans_id, name)
247
245
        unique_add(self._new_parent, trans_id, parent)
248
246
        return trans_id
251
249
        """Change the path that is assigned to a transaction id."""
252
250
        if parent is None:
253
251
            raise ValueError("Parent trans-id may not be None")
254
 
        if trans_id == self._new_root:
 
252
        if trans_id == self.root:
255
253
            raise CantMoveRoot
256
254
        self._new_name[trans_id] = name
257
255
        self._new_parent[trans_id] = parent
280
278
        """
281
279
        raise NotImplementedError(self.fixup_new_roots)
282
280
 
283
 
    def _assign_id(self):
 
281
    def assign_id(self):
284
282
        """Produce a new tranform id"""
285
283
        new_id = "new-%s" % self._id_number
286
284
        self._id_number += 1
290
288
        """Determine (and maybe set) the transaction ID for a tree path."""
291
289
        path = self.canonical_path(path)
292
290
        if path not in self._tree_path_ids:
293
 
            self._tree_path_ids[path] = self._assign_id()
 
291
            self._tree_path_ids[path] = self.assign_id()
294
292
            self._tree_id_paths[self._tree_path_ids[path]] = path
295
293
        return self._tree_path_ids[path]
296
294
 
627
625
        self.transform = transform
628
626
 
629
627
    def _determine_path(self, trans_id):
630
 
        if (trans_id == self.transform.root or trans_id == ROOT_PARENT):
 
628
        if trans_id == self.transform.root or trans_id == ROOT_PARENT:
631
629
            return u""
632
630
        name = self.transform.final_name(trans_id)
633
631
        parent_id = self.transform.final_parent(trans_id)
1387
1385
        pass
1388
1386
 
1389
1387
    def _path2trans_id(self, path):
 
1388
        """Look up the trans id associated with a path.
 
1389
 
 
1390
        :param path: path to look up, None when the path does not exist
 
1391
        :return: trans_id
 
1392
        """
1390
1393
        # We must not use None here, because that is a valid value to store.
1391
1394
        trans_id = self._path2trans_id_cache.get(path, object)
1392
1395
        if trans_id is not object: