key names, conventions
This commit is contained in:
@ -25,6 +25,7 @@ def decode_snap():
|
||||
|
||||
def recursive_diff_snap(last_tree, current_tree, path='./', bres={}):
|
||||
'''
|
||||
XXX: use key names convention specified in lib/repr/node.py
|
||||
snapshot is a tree represented by dictionary {k, val} when k can be folder or file name
|
||||
and val can be a dictionary or an hash
|
||||
|
||||
@ -42,9 +43,9 @@ def recursive_diff_snap(last_tree, current_tree, path='./', bres={}):
|
||||
print(f'file {path}{key_added} subtree added in current snapshot')
|
||||
item = {
|
||||
'name' : key_added,
|
||||
'path' : '%s' % (path,),
|
||||
'type' : 'd' if isinstance(current_tree[key_added], dict) else 'f',
|
||||
'hash' : current_tree[key_added],
|
||||
'rel_path' : '%s' % (path,),
|
||||
'cur_type' : 'd' if isinstance(current_tree[key_added], dict) else 'f',
|
||||
'cur_hash' : current_tree[key_added],
|
||||
}
|
||||
added.append(item)
|
||||
|
||||
@ -55,7 +56,7 @@ def recursive_diff_snap(last_tree, current_tree, path='./', bres={}):
|
||||
|
||||
item = {
|
||||
'name' : name_last,
|
||||
'path' : path,
|
||||
'rel_path' : path,
|
||||
# 'last_hash' : hsh_last,
|
||||
}
|
||||
|
||||
@ -63,8 +64,8 @@ def recursive_diff_snap(last_tree, current_tree, path='./', bres={}):
|
||||
## the name in not founded in current snapshot - Subtree removed (or moved)
|
||||
print(f'{path}{name_last} present in last_tree but removed in current_tree, subtree {name_last} removed in current_tree')
|
||||
item.update({
|
||||
'type' : last_type,
|
||||
'hash' : hsh_last,
|
||||
'last_type' : last_type,
|
||||
'last_hash' : hsh_last,
|
||||
})
|
||||
removed.append(item)
|
||||
continue
|
||||
@ -75,7 +76,7 @@ def recursive_diff_snap(last_tree, current_tree, path='./', bres={}):
|
||||
print(f'{path}{name_last} changed his type in {current_type}')
|
||||
item.update({
|
||||
'last_type' : last_type,
|
||||
'current_type' : current_type,
|
||||
'cur_type' : current_type,
|
||||
})
|
||||
changed.append(item)
|
||||
continue
|
||||
@ -86,7 +87,7 @@ def recursive_diff_snap(last_tree, current_tree, path='./', bres={}):
|
||||
print(f'file {path}{name_last} changed his hash')
|
||||
item.update({
|
||||
'last_type' : last_type,
|
||||
'current_type' : current_type,
|
||||
'cur_type' : current_type,
|
||||
'cur_hash' : hsh_current,
|
||||
'last_hash' : hsh_last,
|
||||
})
|
||||
|
@ -112,7 +112,7 @@ class Manager():
|
||||
# node_path = node['path']
|
||||
# node_name = node['name']
|
||||
# return tree_diff_path
|
||||
return node['path'].replace('.%s' % (os.sep), tree_diff_path)
|
||||
return node['rel_path'].replace('.%s' % (os.sep), tree_diff_path)
|
||||
|
||||
def dump_local_hash(self, hsh=None):
|
||||
# local_path = self.local_path
|
||||
@ -134,21 +134,21 @@ class Manager():
|
||||
return snapshot
|
||||
|
||||
def get_unmerged_local_path(self, node):
|
||||
node_path = node['path']
|
||||
node_path = node['rel_path']
|
||||
node_name = node['name']
|
||||
unmerged_local_file_path = '%s%s' % (node_path, node_name)
|
||||
unmerged_file_path = unmerged_local_file_path.replace('.%s' % (os.sep), self.get_unmerged_path())
|
||||
return unmerged_file_path
|
||||
|
||||
def get_absolute_local_path(self, node):
|
||||
node_path = node['path']
|
||||
node_path = node['rel_path']
|
||||
node_name = node['name']
|
||||
local_file_path = '%s%s' % (node_path, node_name)
|
||||
local_file_path = local_file_path.replace('.%s' % (os.sep), self.local_path)
|
||||
return local_file_path
|
||||
|
||||
def get_absolute_remote_path(self, node):
|
||||
node_path = node['path']
|
||||
node_path = node['rel_path']
|
||||
node_name = node['name']
|
||||
remote_file_path = '%s%s' % (node_path, node_name)
|
||||
remote_file_path = remote_file_path.replace('.%s' % (os.sep), self.remote_path)
|
||||
@ -264,7 +264,7 @@ class Manager():
|
||||
pass
|
||||
# node_type = node['type']
|
||||
# node_name = node['name']
|
||||
# node_path = node['path']
|
||||
# node_path = node['rel_path']
|
||||
#
|
||||
# agent = self.get_agent()
|
||||
#
|
||||
@ -275,7 +275,7 @@ class Manager():
|
||||
unmerged = self.load_unmerged_diff()
|
||||
for n, unode in enumerate(unmerged):
|
||||
i = n+1
|
||||
path = unode['path']
|
||||
path = unode['rel_path']
|
||||
name = unode['name']
|
||||
remote_hash = unode['remote_hash']
|
||||
last_type = unode['last_type']
|
||||
@ -283,13 +283,13 @@ class Manager():
|
||||
|
||||
def mark_conflicting_node_as_solved(self, node):
|
||||
name = node['name']
|
||||
path = node['path']
|
||||
path = node['rel_path']
|
||||
|
||||
unmerged = self.load_unmerged_diff()
|
||||
|
||||
found = {}
|
||||
for n, unode in enumerate(unmerged):
|
||||
if unode['name'] == name and unode['path'] == path:
|
||||
if unode['name'] == name and unode['rel_path'] == path:
|
||||
found = unode
|
||||
break
|
||||
else:
|
||||
|
Reference in New Issue
Block a user