gitfs
@vtemian
gitfs - Pytim #7
$whoami
gitfs - Pytim #7
gitfs - Pytim #7
the problem
CHAOS!
gitfs - Pytim #7
gitfs - Pytim #7
gitfs - Pytim #7
introducing gitfs
gitfs - Pytim #7
gitfs
what is it?
gitfs - Pytim #7
demo
gitfs - Pytim #7
easy!
as 1,2,3
gitfs - Pytim #7
gitfs - Pytim #7
open-source
gitfs - Pytim #7
how was it made?
gitfs - Pytim #7
research
gitfs - Pytim #7
for git
gitfs - Pytim #7
git=pygit2
gitfs - Pytim #7
from pygit2 import clone_repository, Keypair
gitfs - Pytim #7
from pygit2 import clone_repository, Keypair
credentials = Keypair("git", "/home/wok/.ssh/
unsafe_key.pub","/home/wok/.ssh/unsafe_key", "")
gitfs - Pytim #7
from pygit2 import clone_repository, Keypair
credentials = Keypair("git", "/home/wok/.ssh/
unsafe_key.pub","/home/wok/.ssh/unsafe_key", "")
repository = clone_repository("git@github.
com:vtemian/gitfs-demo","/home/wok/gitfs-demo",
credentials=credentials)
gitfs - Pytim #7
from pygit2 import clone_repository, Keypair
credentials = Keypair("git", "/home/wok/.ssh/
unsafe_key.pub","/home/wok/.ssh/unsafe_key", "")
repository = clone_repository("git@github.
com:vtemian/gitfs-demo","/home/wok/gitfs-demo",
credentials=credentials)
remote = [remote for remote in repo.remotes
if remote.name == "origin"]
remote[0].credentials = credentials
gitfs - Pytim #7
from pygit2 import clone_repository, Keypair
credentials = Keypair("git", "/home/wok/.ssh/
unsafe_key.pub","/home/wok/.ssh/unsafe_key", "")
repository = clone_repository("git@github.
com:vtemian/gitfs-demo","/home/wok/gitfs-demo",
credentials=credentials)
remote = [remote for remote in repo.remotes
if remote.name == "origin"]
remote[0].credentials = credentials
remote[0].push("refs/heads/master")
gitfs - Pytim #7
for the file system
gitfs - Pytim #7
file system=fusepy
gitfs - Pytim #7
class Memory(Operations):
gitfs - Pytim #7
class Memory(Operations):
def open(self, path, flags):
self.fd += 1
return self.fd
gitfs - Pytim #7
class Memory(Operations):
def open(self, path, flags):
self.fd += 1
return self.fd
def read(self, path, size, offset, fh):
return self.data[path][offset:offset + size]
gitfs - Pytim #7
class Memory(Operations):
def open(self, path, flags):
self.fd += 1
return self.fd
def read(self, path, size, offset, fh):
return self.data[path][offset:offset + size]
def rename(self, old, new):
self.files[new] = self.files.pop(old)
gitfs - Pytim #7
class Memory(Operations):
def open(self, path, flags):
self.fd += 1
return self.fd
def read(self, path, size, offset, fh):
return self.data[path][offset:offset + size]
def rename(self, old, new):
self.files[new] = self.files.pop(old)
def rmdir(self, path):
self.files.pop(path)
self.files['/']['st_nlink'] -= 1
gitfs - Pytim #7
class Memory(Operations):
def open(self, path, flags):
self.fd += 1
return self.fd
def read(self, path, size, offset, fh):
return self.data[path][offset:offset + size]
def rename(self, old, new):
self.files[new] = self.files.pop(old)
def rmdir(self, path):
self.files.pop(path)
self.files['/']['st_nlink'] -= 1
def write(self, path, data, offset, fh):
self.data[path] = self.data[path][:offset] +data
				 self.files[path]['st_size'] = len(self.data[path])
return len(data)
gitfs - Pytim #7
first iteration
gitfs - Pytim #7
very dirty
def rename(self, old, new):
if "history" in old or new:
# raise EROFS
elif old == "/" or new == "/":
# raise EROFS
else:
# do the actual rename
gitfs - Pytim #7
second iteration
gitfs - Pytim #7
read()
Router
CurrentView HistoryView CommitView IndexView
gitfs - Pytim #7
read('/history/2014-10-18/14-01-04-fg34asc4/Readme.md')
CommitView
gitfs - Pytim #7
upstream
synchronization
gitfs - Pytim #7
solve conflicts
gitfs - Pytim #7
solve conflicts
1 2 3
7 8
4 5 6
remote
local
gitfs - Pytim #7
solve conflicts
1 2 3 4 5 6
merging_remote
1 2 3 7 8
merging_local
gitfs - Pytim #7
1 2 3 4 5 7'6 8'
local
solve conflicts
gitfs - Pytim #7
third iteration
gitfs - Pytim #7
cache
gitfs - Pytim #7
upstream
synchronization
gitfs - Pytim #7
Fuse threads
gitfs - Pytim #7
commits
Fuse threads
gitfs - Pytim #7
Commit queue
commits
Fuse threads
gitfs - Pytim #7
Sync worker
Commit queue
commits
Fuse threads
gitfs - Pytim #7
want to sync
don't open for write
Commit queue
Sync worker
commits
Fuse threads
gitfs - Pytim #7
commit
want to sync
don't open for write
Commit queue
Sync worker
commits
Fuse threads
gitfs - Pytim #7
commit
sync done
want to sync
don't open for write
Commit queue Fetch worker
Sync worker
fetch
fetch
fetch
commits
Fuse threads
gitfs - Pytim #7
pytest
gitfs - Pytim #7
			 $ sudo add-apt-repository ppa:presslabs/gitfs
			 $ sudo apt-get update
			 $ sudo apt-get install gitfs
gitfs - Pytim #7
	 commits 	 forks
	stars 	releases
868 27
606 11
gitfs - Pytim #7
github.com/PressLabs/gitfs
gitfs - Pytim #7
Q/A?
gitfs - Pytim #7
thank you
gitfs - Pytim #7

gitfs

  • 1.
  • 2.
    gitfs - Pytim#7 $whoami
  • 3.
  • 4.
    gitfs - Pytim#7 the problem
  • 5.
  • 6.
  • 7.
    gitfs - Pytim#7 introducing gitfs
  • 8.
    gitfs - Pytim#7 gitfs what is it?
  • 9.
  • 10.
    gitfs - Pytim#7 easy! as 1,2,3
  • 11.
  • 12.
    gitfs - Pytim#7 open-source
  • 13.
    gitfs - Pytim#7 how was it made?
  • 14.
    gitfs - Pytim#7 research
  • 15.
    gitfs - Pytim#7 for git
  • 16.
    gitfs - Pytim#7 git=pygit2
  • 17.
    gitfs - Pytim#7 from pygit2 import clone_repository, Keypair
  • 18.
    gitfs - Pytim#7 from pygit2 import clone_repository, Keypair credentials = Keypair("git", "/home/wok/.ssh/ unsafe_key.pub","/home/wok/.ssh/unsafe_key", "")
  • 19.
    gitfs - Pytim#7 from pygit2 import clone_repository, Keypair credentials = Keypair("git", "/home/wok/.ssh/ unsafe_key.pub","/home/wok/.ssh/unsafe_key", "") repository = clone_repository("git@github. com:vtemian/gitfs-demo","/home/wok/gitfs-demo", credentials=credentials)
  • 20.
    gitfs - Pytim#7 from pygit2 import clone_repository, Keypair credentials = Keypair("git", "/home/wok/.ssh/ unsafe_key.pub","/home/wok/.ssh/unsafe_key", "") repository = clone_repository("git@github. com:vtemian/gitfs-demo","/home/wok/gitfs-demo", credentials=credentials) remote = [remote for remote in repo.remotes if remote.name == "origin"] remote[0].credentials = credentials
  • 21.
    gitfs - Pytim#7 from pygit2 import clone_repository, Keypair credentials = Keypair("git", "/home/wok/.ssh/ unsafe_key.pub","/home/wok/.ssh/unsafe_key", "") repository = clone_repository("git@github. com:vtemian/gitfs-demo","/home/wok/gitfs-demo", credentials=credentials) remote = [remote for remote in repo.remotes if remote.name == "origin"] remote[0].credentials = credentials remote[0].push("refs/heads/master")
  • 22.
    gitfs - Pytim#7 for the file system
  • 23.
    gitfs - Pytim#7 file system=fusepy
  • 24.
    gitfs - Pytim#7 class Memory(Operations):
  • 25.
    gitfs - Pytim#7 class Memory(Operations): def open(self, path, flags): self.fd += 1 return self.fd
  • 26.
    gitfs - Pytim#7 class Memory(Operations): def open(self, path, flags): self.fd += 1 return self.fd def read(self, path, size, offset, fh): return self.data[path][offset:offset + size]
  • 27.
    gitfs - Pytim#7 class Memory(Operations): def open(self, path, flags): self.fd += 1 return self.fd def read(self, path, size, offset, fh): return self.data[path][offset:offset + size] def rename(self, old, new): self.files[new] = self.files.pop(old)
  • 28.
    gitfs - Pytim#7 class Memory(Operations): def open(self, path, flags): self.fd += 1 return self.fd def read(self, path, size, offset, fh): return self.data[path][offset:offset + size] def rename(self, old, new): self.files[new] = self.files.pop(old) def rmdir(self, path): self.files.pop(path) self.files['/']['st_nlink'] -= 1
  • 29.
    gitfs - Pytim#7 class Memory(Operations): def open(self, path, flags): self.fd += 1 return self.fd def read(self, path, size, offset, fh): return self.data[path][offset:offset + size] def rename(self, old, new): self.files[new] = self.files.pop(old) def rmdir(self, path): self.files.pop(path) self.files['/']['st_nlink'] -= 1 def write(self, path, data, offset, fh): self.data[path] = self.data[path][:offset] +data self.files[path]['st_size'] = len(self.data[path]) return len(data)
  • 30.
    gitfs - Pytim#7 first iteration
  • 31.
    gitfs - Pytim#7 very dirty def rename(self, old, new): if "history" in old or new: # raise EROFS elif old == "/" or new == "/": # raise EROFS else: # do the actual rename
  • 32.
    gitfs - Pytim#7 second iteration
  • 33.
    gitfs - Pytim#7 read() Router CurrentView HistoryView CommitView IndexView
  • 34.
    gitfs - Pytim#7 read('/history/2014-10-18/14-01-04-fg34asc4/Readme.md') CommitView
  • 35.
    gitfs - Pytim#7 upstream synchronization
  • 36.
    gitfs - Pytim#7 solve conflicts
  • 37.
    gitfs - Pytim#7 solve conflicts 1 2 3 7 8 4 5 6 remote local
  • 38.
    gitfs - Pytim#7 solve conflicts 1 2 3 4 5 6 merging_remote 1 2 3 7 8 merging_local
  • 39.
    gitfs - Pytim#7 1 2 3 4 5 7'6 8' local solve conflicts
  • 40.
    gitfs - Pytim#7 third iteration
  • 41.
    gitfs - Pytim#7 cache
  • 42.
    gitfs - Pytim#7 upstream synchronization
  • 43.
    gitfs - Pytim#7 Fuse threads
  • 44.
    gitfs - Pytim#7 commits Fuse threads
  • 45.
    gitfs - Pytim#7 Commit queue commits Fuse threads
  • 46.
    gitfs - Pytim#7 Sync worker Commit queue commits Fuse threads
  • 47.
    gitfs - Pytim#7 want to sync don't open for write Commit queue Sync worker commits Fuse threads
  • 48.
    gitfs - Pytim#7 commit want to sync don't open for write Commit queue Sync worker commits Fuse threads
  • 49.
    gitfs - Pytim#7 commit sync done want to sync don't open for write Commit queue Fetch worker Sync worker fetch fetch fetch commits Fuse threads
  • 50.
    gitfs - Pytim#7 pytest
  • 51.
    gitfs - Pytim#7 $ sudo add-apt-repository ppa:presslabs/gitfs $ sudo apt-get update $ sudo apt-get install gitfs
  • 52.
    gitfs - Pytim#7 commits forks stars releases 868 27 606 11
  • 53.
    gitfs - Pytim#7 github.com/PressLabs/gitfs
  • 54.
  • 55.
    gitfs - Pytim#7 thank you
  • 56.