Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
96b91b70d6 | ||
|
|
a775dc2292 | ||
|
|
2a51f56787 | ||
|
|
66772ffcca | ||
|
|
aca00ffd03 | ||
|
|
5a80af56a7 | ||
|
|
fb5f548f0a | ||
|
|
6c9746a307 | ||
|
|
c1b259c906 |
No files matched your search
@@ -1,5 +1,45 @@
|
||||
# CHANGELOG
|
||||
|
||||
## v0.4.2 (2024-08-26)
|
||||
|
||||
### Fix
|
||||
|
||||
* fix: bug capure log ([`a775dc2`](https://github.com/LoopsCreativeStudio/ayon-perforce/commit/a775dc22923016166691dc0221b60f7d018eeea4))
|
||||
|
||||
## v0.4.1 (2024-08-19)
|
||||
|
||||
### Fix
|
||||
|
||||
* fix: resolve for opened file with revert before sync force (#8) ([`66772ff`](https://github.com/LoopsCreativeStudio/ayon-perforce/commit/66772ffcca326ce99e219b6596013ede248b3029))
|
||||
|
||||
* fix: re match patterns adjustment ([`aca00ff`](https://github.com/LoopsCreativeStudio/ayon-perforce/commit/aca00ffd032975a05812d43cc13b5561ff81c468))
|
||||
|
||||
## v0.4.0 (2024-08-01)
|
||||
|
||||
### Feature
|
||||
|
||||
* feat: resolve sync button to force resync in popup warning (#6) ([`fb5f548`](https://github.com/LoopsCreativeStudio/ayon-perforce/commit/fb5f548f0af47e8eb89b14e8a862921cd52983f8))
|
||||
|
||||
## v0.3.0 (2024-07-26)
|
||||
|
||||
### Feature
|
||||
|
||||
* feat: Add popup message on sync error or warning (#3) ([`c1b259c`](https://github.com/LoopsCreativeStudio/ayon-perforce/commit/c1b259c90649b3d4bd775880305f3e7f3f2f8bc6))
|
||||
|
||||
### Fix
|
||||
|
||||
* fix: err typos missing ([`df7381f`](https://github.com/LoopsCreativeStudio/ayon-perforce/commit/df7381f679097064dc06430c35abd633b4506976))
|
||||
|
||||
* fix: err typos missing ([`649f605`](https://github.com/LoopsCreativeStudio/ayon-perforce/commit/649f605a27c2626d3d2faa4297be25f1c7f3d512))
|
||||
|
||||
* fix: protected branch ([`f1706ed`](https://github.com/LoopsCreativeStudio/ayon-perforce/commit/f1706ed0ac6c88a17dc95a0ae107d6fc4a465b02))
|
||||
|
||||
* fix: protected branch ([`da6af24`](https://github.com/LoopsCreativeStudio/ayon-perforce/commit/da6af24e82ac96359013c5b30cdc227e1d79c2d3))
|
||||
|
||||
* fix: err typos missing ([`ddfda45`](https://github.com/LoopsCreativeStudio/ayon-perforce/commit/ddfda458b81ddfeb20f68f454dfaea3553596bd8))
|
||||
|
||||
* fix: add token to bypass release ([`5a71a1d`](https://github.com/LoopsCreativeStudio/ayon-perforce/commit/5a71a1da1f0bddc7c195fcc4879ac13c38d1802c))
|
||||
|
||||
## v0.2.0 (2024-07-10)
|
||||
|
||||
### Documentation
|
||||
|
||||
@@ -3,10 +3,11 @@ import re
|
||||
import subprocess
|
||||
from typing import Optional, Union, Dict
|
||||
|
||||
from qtpy.QtWidgets import QLabel
|
||||
from qtpy.QtWidgets import QApplication, QLabel, QPushButton
|
||||
from qtpy.QtGui import QIcon
|
||||
from qtpy.QtCore import Qt
|
||||
|
||||
from ayon_core.lib import Logger
|
||||
from ayon_core.resources import get_ayon_icon_filepath
|
||||
from ayon_core.style import load_stylesheet
|
||||
from ayon_core.tools.utils import ErrorMessageBox
|
||||
@@ -26,11 +27,29 @@ class PerforceErrorMessageBox(ErrorMessageBox):
|
||||
self._p4settings = p4settings
|
||||
self._exc_msg = exc_msg
|
||||
self._msg_type = msg_type
|
||||
super().__init__(f"Perforce {self._msg_type}", None)
|
||||
self.log = Logger.get_logger("PerforceResolve")
|
||||
super().__init__(
|
||||
f"Perforce {self._msg_type}", QApplication.activeWindow(),
|
||||
)
|
||||
self.setModal(True)
|
||||
self.setWindowIcon(QIcon(get_ayon_icon_filepath()))
|
||||
self.setStyleSheet(load_stylesheet())
|
||||
|
||||
# get ok button
|
||||
footer_layout = self._footer_widget.layout()
|
||||
self.ok_btn = footer_layout.itemAt(2).widget()
|
||||
self.ok_btn.setText("Skip")
|
||||
|
||||
# create resolve button
|
||||
self.resolve_btn = QPushButton("Resolve", self)
|
||||
self.resolve_btn.clicked.connect(self.resolve_warning)
|
||||
self.resolve_btn.hide()
|
||||
footer_layout.addWidget(self.resolve_btn, 0)
|
||||
|
||||
if msg_type == "Warning":
|
||||
self.ok_btn.setText("Skip")
|
||||
self.resolve_btn.show()
|
||||
|
||||
def _create_top_widget(self, parent_widget) -> QLabel:
|
||||
label_widget = QLabel(parent_widget)
|
||||
top_msg = (
|
||||
@@ -56,6 +75,94 @@ class PerforceErrorMessageBox(ErrorMessageBox):
|
||||
content_label.setCursor(Qt.IBeamCursor)
|
||||
content_layout.addWidget(content_label)
|
||||
|
||||
def revert_file(self, depot_file:str) -> subprocess.CompletedProcess:
|
||||
"""Do a Perforce revert for the give depot file.
|
||||
|
||||
Args:
|
||||
depot_file (str): the depot file to revert.
|
||||
|
||||
Returns:
|
||||
subprocess.CompletedProcess: The process result.
|
||||
"""
|
||||
return subprocess.run(
|
||||
['p4', 'revert', depot_file],
|
||||
shell=True,
|
||||
text=True,
|
||||
check=False,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
errors='replace',
|
||||
)
|
||||
|
||||
def force_sync(self, depot_file:str) -> subprocess.CompletedProcess:
|
||||
"""Force Perforce sync for the give depot file.
|
||||
|
||||
Args:
|
||||
depot_file (str): the depot file to update.
|
||||
|
||||
Returns:
|
||||
subprocess.CompletedProcess: The process result.
|
||||
"""
|
||||
return subprocess.run(
|
||||
['p4', 'sync', '-f', f'{depot_file}#head'],
|
||||
shell=True,
|
||||
text=True,
|
||||
check=False,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
errors='replace',
|
||||
)
|
||||
|
||||
def resolve_warning(self) -> None:
|
||||
"""Resolve Perforce sync warning.
|
||||
"""
|
||||
result_html = ["<span style='font-size:14pt;'>Resolve Result:</span>"]
|
||||
result_failed = False
|
||||
for line in self._exc_msg.splitlines():
|
||||
wrn_match = re.match(
|
||||
r"(?P<depotfile>\/\/.*)#\d+"
|
||||
r" - (?P<opened>is opened for add and )?can't "
|
||||
r"(overwrite existing file|update modified file|be replaced)"
|
||||
r"(?P<localfile>.*)$",
|
||||
line,
|
||||
)
|
||||
if not wrn_match:
|
||||
continue
|
||||
depot_file = wrn_match.group("depotfile")
|
||||
# revert if needed
|
||||
if wrn_match.group("opened"):
|
||||
self.log.info(f"p4 revert {depot_file}")
|
||||
revert_result = self.revert_file(depot_file)
|
||||
self.log.info(f">>> {revert_result.stdout.strip()}")
|
||||
# force sync
|
||||
self.log.info(f"p4 sync -f {depot_file}")
|
||||
result = self.force_sync(depot_file)
|
||||
stdout_result = result.stdout.strip()
|
||||
# check sync result
|
||||
if re.match(r".+ - (refreshing|updating|added) .+", stdout_result):
|
||||
self.log.info(f">>> {stdout_result}")
|
||||
color_result = "YellowGreen"
|
||||
else:
|
||||
self.log.info(f"!!! {stdout_result}")
|
||||
color_result = "Orange"
|
||||
result_failed = True
|
||||
|
||||
result_html.append(
|
||||
f"<span style='color:{color_result};'>"
|
||||
f"{self.convert_text_for_html(stdout_result)}</span>"
|
||||
)
|
||||
|
||||
resolve_label = QLabel("<br>".join(result_html), self)
|
||||
resolve_label.setTextInteractionFlags(Qt.TextSelectableByMouse)
|
||||
resolve_label.setCursor(Qt.IBeamCursor)
|
||||
content_layout = self._content_widget.layout()
|
||||
content_layout.insertWidget(2, self._create_line())
|
||||
content_layout.insertWidget(3, resolve_label)
|
||||
if not result_failed:
|
||||
self.resolve_btn.hide()
|
||||
self.ok_btn.setText("Ok")
|
||||
else:
|
||||
self.resolve_btn.setDisabled(True)
|
||||
|
||||
class PerforceSync(PreLaunchHook):
|
||||
"""Run Perforce Sync for the given project config.
|
||||
@@ -132,7 +239,9 @@ class PerforceSync(PreLaunchHook):
|
||||
|
||||
percent_match = re.search(r"(\d{1,3}%|finishing)", capture_log)
|
||||
warning_match = re.search(
|
||||
r"(.* can't overwrite existing .*)\n", capture_log, re.M
|
||||
r"(\/\/.+ can't (overwrite|update|be replaced).*)\n",
|
||||
capture_log,
|
||||
re.M,
|
||||
)
|
||||
if percent_match:
|
||||
current_percent = percent_match.group(1)
|
||||
@@ -141,12 +250,14 @@ class PerforceSync(PreLaunchHook):
|
||||
last_percent = current_percent
|
||||
capture_log = ""
|
||||
elif warning_match:
|
||||
self.log.info(f"*** WRN: {warning_match.group(1)}")
|
||||
complete_log += capture_log
|
||||
warning_message = warning_match.group(1).strip()
|
||||
self.log.info(f"*** WRN: {warning_message}")
|
||||
complete_log += warning_message + "\n"
|
||||
capture_log = ""
|
||||
elif capture_log.endswith("\n"):
|
||||
if capture_log.strip():
|
||||
complete_log += capture_log.strip() + "\n"
|
||||
capture_log = capture_log.strip().strip("/|-\\")
|
||||
if capture_log:
|
||||
complete_log += capture_log + "\n"
|
||||
capture_log = ""
|
||||
elif capture_log == "sync ":
|
||||
capture_log = ""
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
[tool.poetry]
|
||||
name = "ayon-perforce"
|
||||
description = "perforce addon for ayon"
|
||||
version = "0.2.0"
|
||||
version = "0.4.2"
|
||||
authors = ["LoopsCreativeStudio <tech@loopscreativestudio.com>"]
|
||||
license = "Apache-2.0"
|
||||
readme = "README.md"
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Package declaring addon version."""
|
||||
__version__ = "0.2.0"
|
||||
__version__ = "0.4.2"
|
||||
Reference in new issue
Block a user