Skip to content

Commit 747ea46

Browse files
committed
black
prevent conflcted copy fix
1 parent 57e854b commit 747ea46

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

mergin/cli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ def pull(ctx):
468468
except Exception as e:
469469
_print_unhandled_exception()
470470

471+
471472
@cli.command()
472473
@click.pass_context
473474
def sync(ctx):
@@ -478,6 +479,7 @@ def sync(ctx):
478479
directory = os.getcwd()
479480
upload_job = None
480481
try:
482+
481483
def on_progress(increment, push_job):
482484
nonlocal upload_job
483485
upload_job = push_job

mergin/editor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def filter_changes(mc, project_role: str, changes: Dict[str, List[dict]]) -> Dic
5656
return _apply_editor_filters(changes)
5757

5858

59-
def prevent_conflicted_copy(path: str, mc, project_info: dict) -> bool:
59+
def prevent_conflicted_copy(path: str, mc, project_role: str) -> bool:
6060
"""
6161
Decides whether a file path should be blocked from creating a conflicted copy.
6262
Note: This is used when the editor is active and attempting to modify files (e.g., .ggs) that are also updated on the server, preventing unnecessary conflict files creation.
@@ -69,4 +69,4 @@ def prevent_conflicted_copy(path: str, mc, project_info: dict) -> bool:
6969
Returns:
7070
bool: True if the file path should be prevented from ceating conflicted copy, False otherwise.
7171
"""
72-
return is_editor_enabled(mc, project_info) and any([is_qgis_file(path)])
72+
return is_editor_enabled(mc, project_role) and any([is_qgis_file(path)])

mergin/merginproject.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
except (ImportError, ModuleNotFoundError):
3535
import pygeodiff
3636

37+
3738
class MerginProject:
3839
"""Base class for Mergin Maps local projects.
3940
@@ -155,7 +156,7 @@ def workspace_name(self) -> str:
155156
full_name = self.project_full_name()
156157
slash_index = full_name.index("/")
157158
return full_name[:slash_index]
158-
159+
159160
def project_role(self) -> str:
160161
self._read_metadata()
161162
return self._metadata.get("role")
@@ -555,7 +556,7 @@ def apply_pull_changes(self, changes, temp_dir, server_project, mc):
555556
if (
556557
path in modified_local_paths
557558
and item["checksum"] != local_files_map[path]["checksum"]
558-
and not prevent_conflicted_copy(path, mc, server_project)
559+
and not prevent_conflicted_copy(path, mc, server_project.get("role"))
559560
):
560561
conflict = self.create_conflicted_copy(path, mc.username())
561562
conflicts.append(conflict)

mergin/test/test_client.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ def test_push_pull_changes(mc):
406406
f_conflict_checksum = generate_checksum(os.path.join(project_dir_2, f_updated))
407407

408408
# not at latest server version
409-
with pytest.raises(ClientError, match="Please update your local copy"):
409+
with pytest.raises(ClientError, match="Version mismatch"):
410410
mc.push_project(project_dir_2)
411411

412412
# check changes in project_dir_2 before applied
@@ -3172,9 +3172,7 @@ def test_client_project_sync_retry(mc):
31723172
mc.sync_project(project_dir)
31733173
assert mock_push_project_finalize.call_count == 1
31743174

3175-
with patch("mergin.client.push_project_async") as mock_push_project_async, patch(
3176-
"mergin.client.PUSH_ATTEMPTS", 2
3177-
):
3175+
with patch("mergin.client.push_project_async") as mock_push_project_async, patch("mergin.client.PUSH_ATTEMPTS", 2):
31783176
mock_push_project_async.side_effect = ClientError(
31793177
detail="",
31803178
server_code=ErrorCode.AnotherUploadRunning.value,
@@ -3184,9 +3182,7 @@ def test_client_project_sync_retry(mc):
31843182
assert mock_push_project_async.call_count == 2
31853183

31863184
# for v1 endpoints we are rising retry just from push start
3187-
with patch("mergin.client.push_project_async") as mock_push_project_async, patch(
3188-
"mergin.client.PUSH_ATTEMPTS", 2
3189-
):
3185+
with patch("mergin.client.push_project_async") as mock_push_project_async, patch("mergin.client.PUSH_ATTEMPTS", 2):
31903186
mock_push_project_async.side_effect = ClientError(
31913187
detail="Another process is running. Please try later.",
31923188
http_error=400,

mergin/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ def bytes_to_human_size(bytes: int):
295295
return f"{round( bytes / 1024.0 / 1024.0 / 1024.0, precision )} GB"
296296
else:
297297
return f"{round( bytes / 1024.0 / 1024.0 / 1024.0 / 1024.0, precision )} TB"
298-
298+
299+
299300
def get_data_checksum(data: ByteString) -> str:
300301
"""
301302
Generate sha1 checksum for given data.

0 commit comments

Comments
 (0)