Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions flit/vcs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from flit.common import VCSError
from . import hg
from . import git
from . import fsl

def identify_vcs(directory: Path):
directory = directory.resolve()
Expand All @@ -11,5 +12,8 @@ def identify_vcs(directory: Path):
return git
if (p / '.hg').is_dir():
return hg
if ((p / '.fslckout').is_file()
or (p / '_FOSSIL_').is_file()):
return fsl

raise VCSError("Directory does not appear to be in a VCS", directory)
32 changes: 32 additions & 0 deletions flit/vcs/fsl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import os
from subprocess import check_output

name = 'fossil'

def find_repo_root(directory):
for p in [directory] + list(directory.parents):
if ((p / '.fslckout').is_file()
or (p / '_FOSSIL_').is_file()):
return p

def _repo_paths_to_directory_paths(paths, directory):
# 'fossil ls' gives paths from repo root, which may not be our directory.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may need to add the

directory = directory.resolve()

that was included in hg.py, just to be consistent, but other than that, this still works.

repo = find_repo_root(directory)
if directory != repo:
directory_in_repo = str(directory.relative_to(repo)) + os.sep
ix = len(directory_in_repo)
paths = [p[ix:] for p in paths
if os.path.normpath(p).startswith(directory_in_repo)]
return paths


def list_tracked_files(directory):
outb = check_output(['fossil', 'ls'], cwd=str(directory))
paths = [os.fsdecode(l) for l in outb.strip().splitlines()]
return _repo_paths_to_directory_paths(paths, directory)


def list_untracked_deleted_files(directory):
outb = check_output(['fossil', 'extra'], cwd=str(directory))
paths = [os.fsdecode(l) for l in outb.strip().splitlines()]
return _repo_paths_to_directory_paths(paths, directory)