Method
path_from
(self, node)
Source from the content-addressed store, hash-verified
| 287 | return cur |
| 288 | |
| 289 | def path_from(self, node): |
| 290 | c1 = self |
| 291 | c2 = node |
| 292 | c1h = c1.height() |
| 293 | c2h = c2.height() |
| 294 | lst = [] |
| 295 | up = 0 |
| 296 | while c1h > c2h: |
| 297 | lst.append(c1.name) |
| 298 | c1 = c1.parent |
| 299 | c1h -= 1 |
| 300 | while c2h > c1h: |
| 301 | up += 1 |
| 302 | c2 = c2.parent |
| 303 | c2h -= 1 |
| 304 | while not c1 is c2: |
| 305 | lst.append(c1.name) |
| 306 | up += 1 |
| 307 | c1 = c1.parent |
| 308 | c2 = c2.parent |
| 309 | if c1.parent: |
| 310 | lst.extend(['..'] * up) |
| 311 | lst.reverse() |
| 312 | return os.sep.join(lst) or '.' |
| 313 | else: |
| 314 | return self.abspath() |
| 315 | |
| 316 | def abspath(self): |
| 317 | try: |