diff -ur v2/fsyn.py v3/fsyn.py --- v2/fsyn.py 2020-04-19 15:43:08.000000000 +0900 +++ v3/fsyn.py 2020-04-22 22:24:17.000000000 +0900 @@ -353,6 +353,40 @@ push_to( get_curr() ) + def pull(from_path): + (fsyn_DIR, fsyn_BASE) = os.path.split( fsyn_path() ) + + def copy(id, name, force=False): + fn = path_join( fsyn_BASE, id, name ) + if not path_exists( path_join( from_path, fn ) ): + return # no src + if not path_exists( path_join( fsyn_DIR, fn ) ) or force: + cmd = 'tar cf - -C {} {} | tar xf - -C {}'.format( from_path, fn, fsyn_DIR ) + cmd_call( cmd ) + + def pull_id(id): + copy( id, 'snap' ) + copy( id, 'update.tgz' ) + + link = get_link( id, from_path ) + link_d = get_link( id ) + link_d.from_ = link.from_ + for s in link.to: + if s not in link_d.to: + link_d.to.append( s ) + put_link( id, link_d ) + + def pull_from(id): + pull_id( id ) + link = get_link( id, from_path ) + for s in link.to: + pull_from( s ) + + id = get_curr() + if path_exists( path_join( from_path, fsyn_BASE, id ) ): + pull_from( id ) + + return empty.new( locals() ) @@ -370,6 +404,7 @@ cmd_new( 'check', comment='show dirty' ), cmd_new( 'fixlink', comment='fix link info' ), cmd_new( 'push', [ 'to_path' ] ), + cmd_new( 'pull', [ 'from_path' ] ), ] dic = dict( map( lambda cmd: ( cmd.name, cmd ), cmds ) )