47 |
47 |
48 /// Returns a `(dirstate_map, parents)` tuple |
48 /// Returns a `(dirstate_map, parents)` tuple |
49 @staticmethod |
49 @staticmethod |
50 def new_v1( |
50 def new_v1( |
51 on_disk: PyBytes, |
51 on_disk: PyBytes, |
|
52 identity: Option<u64>, |
52 ) -> PyResult<PyObject> { |
53 ) -> PyResult<PyObject> { |
53 let on_disk = PyBytesDeref::new(py, on_disk); |
54 let on_disk = PyBytesDeref::new(py, on_disk); |
54 let (map, parents) = OwningDirstateMap::new_v1(on_disk) |
55 let (map, parents) = OwningDirstateMap::new_v1(on_disk, identity) |
55 .map_err(|e| dirstate_error(py, e))?; |
56 .map_err(|e| dirstate_error(py, e))?; |
56 let map = Self::create_instance(py, map)?; |
57 let map = Self::create_instance(py, map)?; |
57 let p1 = PyBytes::new(py, parents.p1.as_bytes()); |
58 let p1 = PyBytes::new(py, parents.p1.as_bytes()); |
58 let p2 = PyBytes::new(py, parents.p2.as_bytes()); |
59 let p2 = PyBytes::new(py, parents.p2.as_bytes()); |
59 let parents = (p1, p2); |
60 let parents = (p1, p2); |
65 def new_v2( |
66 def new_v2( |
66 on_disk: PyBytes, |
67 on_disk: PyBytes, |
67 data_size: usize, |
68 data_size: usize, |
68 tree_metadata: PyBytes, |
69 tree_metadata: PyBytes, |
69 uuid: PyBytes, |
70 uuid: PyBytes, |
|
71 identity: Option<u64>, |
70 ) -> PyResult<PyObject> { |
72 ) -> PyResult<PyObject> { |
71 let dirstate_error = |e: DirstateError| { |
73 let dirstate_error = |e: DirstateError| { |
72 PyErr::new::<exc::OSError, _>(py, format!("Dirstate error: {:?}", e)) |
74 PyErr::new::<exc::OSError, _>(py, format!("Dirstate error: {:?}", e)) |
73 }; |
75 }; |
74 let on_disk = PyBytesDeref::new(py, on_disk); |
76 let on_disk = PyBytesDeref::new(py, on_disk); |
75 let uuid = uuid.data(py); |
77 let uuid = uuid.data(py); |
76 let map = OwningDirstateMap::new_v2( |
78 let map = OwningDirstateMap::new_v2( |
77 on_disk, data_size, tree_metadata.data(py), uuid.to_owned(), |
79 on_disk, |
|
80 data_size, |
|
81 tree_metadata.data(py), |
|
82 uuid.to_owned(), |
|
83 identity, |
78 ).map_err(dirstate_error)?; |
84 ).map_err(dirstate_error)?; |
79 let map = Self::create_instance(py, map)?; |
85 let map = Self::create_instance(py, map)?; |
80 Ok(map.into_object()) |
86 Ok(map.into_object()) |
81 } |
87 } |
82 |
88 |