Dulwich.io dulwich / 73f42cc
Move shallow implementation into BaseRepo. Jelmer Vernooń≥ 1 year, 14 days ago
1 changed file(s) with 13 addition(s) and 19 deletion(s). Raw diff Collapse all Expand all
465465
466466 :return: Set of shallow commits.
467467 """
468 return set()
468 f = self.get_named_file('shallow')
469 if f is None:
470 return set()
471 with f:
472 return set(l.strip() for l in f)
469473
470474 def update_shallow(self, new_shallow, new_unshallow):
471475 """Update the list of shallow objects.
473477 :param new_shallow: Newly shallow objects
474478 :param new_unshallow: Newly no longer shallow objects
475479 """
476 raise NotImplementedError(self.update_shallow)
480 shallow = self.get_shallow()
481 if new_shallow:
482 shallow.update(new_shallow)
483 if new_unshallow:
484 shallow.difference_update(new_unshallow)
485 self._put_named_file(
486 'shallow',
487 b''.join([sha + b'\n' for sha in shallow]))
477488
478489 def get_peeled(self, ref):
479490 """Get the peeled value of a ref.
935946 return None
936947 raise
937948
938 def get_shallow(self):
939 f = self.get_named_file('shallow')
940 if f is None:
941 return set()
942 with f:
943 return set(l.strip() for l in f)
944
945 def update_shallow(self, new_shallow, new_unshallow):
946 shallow = self.get_shallow()
947 if new_shallow:
948 shallow.update(new_shallow)
949 if new_unshallow:
950 shallow.difference_update(new_unshallow)
951 self._put_named_file(
952 'shallow',
953 b''.join([sha + b'\n' for sha in shallow]))
954
955949 def index_path(self):
956950 """Return path to the index file."""
957951 return os.path.join(self.controldir(), INDEX_FILENAME)