def keys(self): if not self._is_locked(): raise errors.ObjectNotLocked(self) relpaths = set() for quoted_relpath in self._transport.iter_files_recursive(): relpath = urllib.unquote(quoted_relpath) path, ext = os.path.splitext(relpath) if ext == '.gz': relpath = path if '.sig' not in relpath: relpaths.add(relpath) paths = list(relpaths) return set([self._mapper.unmap(path) for path in paths])
def add_lines(self, key, parents, lines): """Add a revision to the store.""" if not self._is_locked(): raise errors.ObjectNotLocked(self) if not self._can_write(): raise errors.ReadOnlyError(self) if '/' in key[-1]: raise ValueError('bad idea to put / in %r' % (key, )) text = ''.join(lines) if self._compressed: text = bytes_to_gzip(text) path = self._map(key) self._transport.put_bytes_non_atomic(path, text, create_parent_dir=True)
def _load_text(self, key): if not self._is_locked(): raise errors.ObjectNotLocked(self) path = self._map(key) try: text = self._transport.get_bytes(path) compressed = self._compressed except errors.NoSuchFile: if self._compressed: # try without the .gz path = path[:-3] try: text = self._transport.get_bytes(path) compressed = False except errors.NoSuchFile: return None else: return None if compressed: text = GzipFile(mode='rb', fileobj=StringIO(text)).read() return text