instable, to check
This commit is contained in:
parent
66c9cbcbd9
commit
f2ed6de92e
@ -291,6 +291,51 @@ class Manager():
|
||||
remote_mount_point = self.get_remote_mount_point(node)
|
||||
return agent.copy_dir(absolute_local_path, remote_mount_point)
|
||||
|
||||
def ___(node, version_kept):
|
||||
'''
|
||||
before copying the node we expect:
|
||||
1. last_hash of remote is equal to node['last_hash'] -> this means in local we modified the server version
|
||||
2. if there is a conflict remote_hash is None if file is not in remote
|
||||
|
||||
'''
|
||||
rstatus = self.get_rnode_status(node)
|
||||
rfile_buf, rhash, rexists = map(rstatus.get, ['iobuffer', 'hash', 'exists'])
|
||||
|
||||
if not rexists and version_kept == 'keep_local':
|
||||
return True, 'You push local version on remote'
|
||||
|
||||
remote_hash = node['remote_hash']
|
||||
|
||||
if not (remote_hash == rhash):
|
||||
unmerged = self.load_unmerged_diff()
|
||||
name = node['name']
|
||||
path = node['rel_path']
|
||||
|
||||
unmerged = self.load_unmerged_diff()
|
||||
|
||||
found = {}
|
||||
for n, unode in enumerate(unmerged):
|
||||
if unode['name'] == name and unode['rel_path'] == path:
|
||||
found = unode
|
||||
break
|
||||
else:
|
||||
n = -1
|
||||
|
||||
if n == -1:
|
||||
return 'No node conflicting'
|
||||
|
||||
print(f'remote hash changed you...generate a new conflict')
|
||||
## update the conflicting node by index
|
||||
(cur_hash, cur_buf) = _genlocal.generate_file_hash(self.get_absolute_local_path(found))
|
||||
found['cur_hash'] = cur_hash
|
||||
found['last_hash'] = found['remote_hash']
|
||||
found['remote_hash'] = rhash
|
||||
found['remote_file_buf'] = rfile_buf
|
||||
self.store_unmerged_diff(unmerged)
|
||||
## store diff in diffs path
|
||||
self.store_fdiff(found)
|
||||
return False, 'Generate conflict'
|
||||
|
||||
|
||||
def show_conflicts(self):
|
||||
unmerged = self.load_unmerged_diff()
|
||||
@ -317,6 +362,7 @@ class Manager():
|
||||
absolute_local_path = colors.CYAN(self.get_absolute_local_path(unode))
|
||||
absolute_remote_path = colors.CYAN(self.get_absolute_remote_path(unode))
|
||||
if version_kept == 'keep_local':
|
||||
# before copy check the remote
|
||||
## copy node to remote
|
||||
print(f'Push local node: {absolute_local_path} to remote path: {absolute_remote_path}')
|
||||
self.copy_node_to_remote(unode)
|
||||
@ -362,7 +408,7 @@ class Manager():
|
||||
print(f'remote hash changed you...generate a new conflict')
|
||||
## update the conflicting node by index
|
||||
(cur_hash, cur_buf) = _genlocal.generate_file_hash(self.get_absolute_local_path(found))
|
||||
found['cur_hash'] = self.get_absolute_local_path(found)
|
||||
found['cur_hash'] = cur_hash
|
||||
found['last_hash'] = found['remote_hash']
|
||||
found['remote_hash'] = rhash
|
||||
found['remote_file_buf'] = rfile_buf
|
||||
|
Loading…
x
Reference in New Issue
Block a user