scmrepo 3.3.4__py3-none-any.whl → 3.3.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of scmrepo might be problematic. Click here for more details.
- scmrepo/git/backend/pygit2/__init__.py +53 -76
- {scmrepo-3.3.4.dist-info → scmrepo-3.3.5.dist-info}/METADATA +1 -1
- {scmrepo-3.3.4.dist-info → scmrepo-3.3.5.dist-info}/RECORD +6 -6
- {scmrepo-3.3.4.dist-info → scmrepo-3.3.5.dist-info}/LICENSE +0 -0
- {scmrepo-3.3.4.dist-info → scmrepo-3.3.5.dist-info}/WHEEL +0 -0
- {scmrepo-3.3.4.dist-info → scmrepo-3.3.5.dist-info}/top_level.txt +0 -0
|
@@ -34,6 +34,7 @@ logger = logging.getLogger(__name__)
|
|
|
34
34
|
if TYPE_CHECKING:
|
|
35
35
|
from pygit2 import Commit, Oid, Signature
|
|
36
36
|
from pygit2.config import Config as _Pygit2Config
|
|
37
|
+
from pygit2.enums import CheckoutStrategy
|
|
37
38
|
from pygit2.remotes import Remote
|
|
38
39
|
from pygit2.repository import Repository
|
|
39
40
|
|
|
@@ -246,17 +247,15 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
246
247
|
)
|
|
247
248
|
|
|
248
249
|
@staticmethod
|
|
249
|
-
def _get_checkout_strategy(
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
GIT_CHECKOUT_SKIP_LOCKED_DIRECTORIES,
|
|
254
|
-
)
|
|
250
|
+
def _get_checkout_strategy(
|
|
251
|
+
strategy: Optional["CheckoutStrategy"] = None,
|
|
252
|
+
) -> "CheckoutStrategy":
|
|
253
|
+
from pygit2.enums import CheckoutStrategy
|
|
255
254
|
|
|
256
255
|
if strategy is None:
|
|
257
|
-
strategy =
|
|
256
|
+
strategy = CheckoutStrategy.SAFE | CheckoutStrategy.RECREATE_MISSING
|
|
258
257
|
if os.name == "nt":
|
|
259
|
-
strategy |=
|
|
258
|
+
strategy |= CheckoutStrategy.SKIP_LOCKED_DIRECTORIES
|
|
260
259
|
return strategy
|
|
261
260
|
|
|
262
261
|
# Workaround to force git_backend_odb_pack to release open file handles
|
|
@@ -343,9 +342,12 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
343
342
|
force: bool = False,
|
|
344
343
|
**kwargs,
|
|
345
344
|
):
|
|
346
|
-
from pygit2 import
|
|
345
|
+
from pygit2 import GitError
|
|
346
|
+
from pygit2.enums import CheckoutStrategy
|
|
347
347
|
|
|
348
|
-
strategy = self._get_checkout_strategy(
|
|
348
|
+
strategy = self._get_checkout_strategy(
|
|
349
|
+
CheckoutStrategy.FORCE if force else None
|
|
350
|
+
)
|
|
349
351
|
|
|
350
352
|
with self.release_odb_handles():
|
|
351
353
|
if create_new:
|
|
@@ -613,7 +615,7 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
613
615
|
force: bool = False,
|
|
614
616
|
on_diverged: Optional[Callable[[str, str], bool]] = None,
|
|
615
617
|
) -> SyncStatus:
|
|
616
|
-
import
|
|
618
|
+
from pygit2.enums import MergeAnalysis
|
|
617
619
|
|
|
618
620
|
rh_rev = self.resolve_rev(rh)
|
|
619
621
|
|
|
@@ -627,16 +629,16 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
627
629
|
self.set_ref(lh, rh_rev)
|
|
628
630
|
return SyncStatus.SUCCESS
|
|
629
631
|
|
|
630
|
-
if merge_result &
|
|
632
|
+
if merge_result & MergeAnalysis.UP_TO_DATE:
|
|
631
633
|
return SyncStatus.UP_TO_DATE
|
|
632
|
-
if merge_result &
|
|
634
|
+
if merge_result & MergeAnalysis.FASTFORWARD:
|
|
633
635
|
self.set_ref(lh, rh_rev)
|
|
634
636
|
return SyncStatus.SUCCESS
|
|
635
|
-
if merge_result &
|
|
637
|
+
if merge_result & MergeAnalysis.NORMAL:
|
|
636
638
|
if on_diverged and on_diverged(lh, rh_rev):
|
|
637
639
|
return SyncStatus.SUCCESS
|
|
638
640
|
return SyncStatus.DIVERGED
|
|
639
|
-
logger.debug("Unexpected merge result: %s",
|
|
641
|
+
logger.debug("Unexpected merge result: %s", MergeAnalysis.NORMAL)
|
|
640
642
|
raise SCMError("Unknown merge analysis result")
|
|
641
643
|
|
|
642
644
|
@contextmanager
|
|
@@ -779,7 +781,8 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
779
781
|
skip_conflicts: bool = False,
|
|
780
782
|
**kwargs,
|
|
781
783
|
):
|
|
782
|
-
from pygit2 import
|
|
784
|
+
from pygit2 import GitError
|
|
785
|
+
from pygit2.enums import CheckoutStrategy
|
|
783
786
|
|
|
784
787
|
from scmrepo.git import Stash
|
|
785
788
|
|
|
@@ -788,7 +791,7 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
788
791
|
self.repo.index.read(False)
|
|
789
792
|
strategy = self._get_checkout_strategy()
|
|
790
793
|
if skip_conflicts:
|
|
791
|
-
strategy |=
|
|
794
|
+
strategy |= CheckoutStrategy.ALLOW_CONFLICTS
|
|
792
795
|
self.repo.stash_apply(
|
|
793
796
|
index, strategy=strategy, reinstate_index=reinstate_index
|
|
794
797
|
)
|
|
@@ -834,7 +837,8 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
834
837
|
raise NotImplementedError
|
|
835
838
|
|
|
836
839
|
def reset(self, hard: bool = False, paths: Optional[Iterable[str]] = None):
|
|
837
|
-
from pygit2 import
|
|
840
|
+
from pygit2 import IndexEntry
|
|
841
|
+
from pygit2.enums import ResetMode
|
|
838
842
|
|
|
839
843
|
self.repo.index.read(False)
|
|
840
844
|
if paths is not None:
|
|
@@ -847,9 +851,9 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
847
851
|
self.repo.index.add(IndexEntry(rel, obj.id, obj.filemode))
|
|
848
852
|
self.repo.index.write()
|
|
849
853
|
elif hard:
|
|
850
|
-
self.repo.reset(self.repo.head.target,
|
|
854
|
+
self.repo.reset(self.repo.head.target, ResetMode.HARD)
|
|
851
855
|
else:
|
|
852
|
-
self.repo.reset(self.repo.head.target,
|
|
856
|
+
self.repo.reset(self.repo.head.target, ResetMode.MIXED)
|
|
853
857
|
|
|
854
858
|
def checkout_index(
|
|
855
859
|
self,
|
|
@@ -858,22 +862,17 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
858
862
|
ours: bool = False,
|
|
859
863
|
theirs: bool = False,
|
|
860
864
|
):
|
|
861
|
-
from pygit2 import
|
|
862
|
-
GIT_CHECKOUT_ALLOW_CONFLICTS,
|
|
863
|
-
GIT_CHECKOUT_FORCE,
|
|
864
|
-
GIT_CHECKOUT_RECREATE_MISSING,
|
|
865
|
-
GIT_CHECKOUT_SAFE,
|
|
866
|
-
)
|
|
865
|
+
from pygit2.enums import CheckoutStrategy
|
|
867
866
|
|
|
868
867
|
assert not (ours and theirs)
|
|
869
|
-
strategy =
|
|
868
|
+
strategy = CheckoutStrategy.RECREATE_MISSING
|
|
870
869
|
if force or ours or theirs:
|
|
871
|
-
strategy |=
|
|
870
|
+
strategy |= CheckoutStrategy.FORCE
|
|
872
871
|
else:
|
|
873
|
-
strategy |=
|
|
872
|
+
strategy |= CheckoutStrategy.SAFE
|
|
874
873
|
|
|
875
874
|
if ours or theirs:
|
|
876
|
-
strategy |=
|
|
875
|
+
strategy |= CheckoutStrategy.ALLOW_CONFLICTS
|
|
877
876
|
strategy = self._get_checkout_strategy(strategy)
|
|
878
877
|
|
|
879
878
|
index = self.repo.index
|
|
@@ -910,18 +909,7 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
910
909
|
def status(
|
|
911
910
|
self, ignored: bool = False, untracked_files: str = "all"
|
|
912
911
|
) -> tuple[Mapping[str, Iterable[str]], Iterable[str], Iterable[str]]:
|
|
913
|
-
from pygit2 import
|
|
914
|
-
GIT_STATUS_IGNORED,
|
|
915
|
-
GIT_STATUS_INDEX_DELETED,
|
|
916
|
-
GIT_STATUS_INDEX_MODIFIED,
|
|
917
|
-
GIT_STATUS_INDEX_NEW,
|
|
918
|
-
GIT_STATUS_WT_DELETED,
|
|
919
|
-
GIT_STATUS_WT_MODIFIED,
|
|
920
|
-
GIT_STATUS_WT_NEW,
|
|
921
|
-
GIT_STATUS_WT_RENAMED,
|
|
922
|
-
GIT_STATUS_WT_TYPECHANGE,
|
|
923
|
-
GIT_STATUS_WT_UNREADABLE,
|
|
924
|
-
)
|
|
912
|
+
from pygit2.enums import FileStatus
|
|
925
913
|
|
|
926
914
|
staged: Mapping[str, list[str]] = {
|
|
927
915
|
"add": [],
|
|
@@ -932,19 +920,19 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
932
920
|
untracked: list[str] = []
|
|
933
921
|
|
|
934
922
|
states = {
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
923
|
+
FileStatus.WT_NEW: untracked,
|
|
924
|
+
FileStatus.WT_MODIFIED: unstaged,
|
|
925
|
+
FileStatus.WT_TYPECHANGE: staged["modify"],
|
|
926
|
+
FileStatus.WT_DELETED: staged["modify"],
|
|
927
|
+
FileStatus.WT_RENAMED: staged["modify"],
|
|
928
|
+
FileStatus.INDEX_NEW: staged["add"],
|
|
929
|
+
FileStatus.INDEX_MODIFIED: staged["modify"],
|
|
930
|
+
FileStatus.INDEX_DELETED: staged["delete"],
|
|
931
|
+
FileStatus.WT_UNREADABLE: untracked,
|
|
944
932
|
}
|
|
945
933
|
|
|
946
934
|
if untracked_files != "no" and ignored:
|
|
947
|
-
states[
|
|
935
|
+
states[FileStatus.IGNORED] = untracked
|
|
948
936
|
|
|
949
937
|
for file, state in self.repo.status(
|
|
950
938
|
untracked_files=untracked_files, ignored=ignored
|
|
@@ -963,22 +951,15 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
963
951
|
def iter_remote_refs(self, url: str, base: Optional[str] = None, **kwargs):
|
|
964
952
|
raise NotImplementedError
|
|
965
953
|
|
|
966
|
-
def merge( # noqa: C901
|
|
954
|
+
def merge( # noqa: C901, PLR0912
|
|
967
955
|
self,
|
|
968
956
|
rev: str,
|
|
969
957
|
commit: bool = True,
|
|
970
958
|
msg: Optional[str] = None,
|
|
971
959
|
squash: bool = False,
|
|
972
960
|
) -> Optional[str]:
|
|
973
|
-
from pygit2 import
|
|
974
|
-
|
|
975
|
-
GIT_MERGE_ANALYSIS_NONE,
|
|
976
|
-
GIT_MERGE_ANALYSIS_UNBORN,
|
|
977
|
-
GIT_MERGE_ANALYSIS_UP_TO_DATE,
|
|
978
|
-
GIT_MERGE_PREFERENCE_FASTFORWARD_ONLY,
|
|
979
|
-
GIT_MERGE_PREFERENCE_NO_FASTFORWARD,
|
|
980
|
-
GitError,
|
|
981
|
-
)
|
|
961
|
+
from pygit2 import GitError
|
|
962
|
+
from pygit2.enums import MergeAnalysis, MergePreference
|
|
982
963
|
|
|
983
964
|
if commit and squash:
|
|
984
965
|
raise SCMError("Cannot merge with 'squash' and 'commit'")
|
|
@@ -991,9 +972,9 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
991
972
|
except GitError as exc:
|
|
992
973
|
raise SCMError("Merge analysis failed") from exc
|
|
993
974
|
|
|
994
|
-
if analysis ==
|
|
975
|
+
if analysis == MergeAnalysis.NONE:
|
|
995
976
|
raise SCMError(f"'{rev}' cannot be merged into HEAD")
|
|
996
|
-
if analysis &
|
|
977
|
+
if analysis & MergeAnalysis.UP_TO_DATE:
|
|
997
978
|
return None
|
|
998
979
|
|
|
999
980
|
try:
|
|
@@ -1006,15 +987,15 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
1006
987
|
raise MergeConflictError("Merge contained conflicts")
|
|
1007
988
|
|
|
1008
989
|
try:
|
|
1009
|
-
if not (squash or ff_pref &
|
|
1010
|
-
if analysis &
|
|
990
|
+
if not (squash or ff_pref & MergePreference.NO_FASTFORWARD):
|
|
991
|
+
if analysis & MergeAnalysis.FASTFORWARD:
|
|
1011
992
|
return self._merge_ff(rev, obj)
|
|
1012
993
|
|
|
1013
|
-
if analysis &
|
|
994
|
+
if analysis & MergeAnalysis.UNBORN:
|
|
1014
995
|
self.repo.set_head(obj.id)
|
|
1015
996
|
return str(obj.id)
|
|
1016
997
|
|
|
1017
|
-
if ff_pref &
|
|
998
|
+
if ff_pref & MergePreference.FASTFORWARD_ONLY:
|
|
1018
999
|
raise SCMError(f"Cannot fast-forward HEAD to '{rev}'")
|
|
1019
1000
|
|
|
1020
1001
|
if commit:
|
|
@@ -1105,19 +1086,15 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
1105
1086
|
attr: str,
|
|
1106
1087
|
source: Optional[str] = None,
|
|
1107
1088
|
) -> Optional[Union[bool, str]]:
|
|
1108
|
-
from pygit2 import
|
|
1109
|
-
|
|
1110
|
-
GIT_ATTR_CHECK_INCLUDE_COMMIT,
|
|
1111
|
-
GIT_ATTR_CHECK_INDEX_ONLY,
|
|
1112
|
-
GitError,
|
|
1113
|
-
)
|
|
1089
|
+
from pygit2 import GitError
|
|
1090
|
+
from pygit2.enums import AttrCheck
|
|
1114
1091
|
|
|
1115
1092
|
commit: Optional["Commit"] = None
|
|
1116
|
-
flags =
|
|
1093
|
+
flags = AttrCheck.FILE_THEN_INDEX
|
|
1117
1094
|
if source:
|
|
1118
1095
|
try:
|
|
1119
1096
|
commit, _ref = self._resolve_refish(source)
|
|
1120
|
-
flags =
|
|
1097
|
+
flags = AttrCheck.INDEX_ONLY | AttrCheck.INCLUDE_COMMIT
|
|
1121
1098
|
except (KeyError, GitError) as exc:
|
|
1122
1099
|
raise SCMError(f"Invalid commit '{source}'") from exc
|
|
1123
1100
|
try:
|
|
@@ -19,7 +19,7 @@ scmrepo/git/backend/gitpython.py,sha256=RTDNUVLiJmhcRgdaJpApTQi6sMN-an9P9xKZBKwk
|
|
|
19
19
|
scmrepo/git/backend/dulwich/__init__.py,sha256=WT6B8LKzQN4pgNrA82CFqwKkR1wWVBRHwwA9LwuSHV4,34740
|
|
20
20
|
scmrepo/git/backend/dulwich/asyncssh_vendor.py,sha256=y0mvx3tRR99Nv85e2n39nPYlhme8dplmQQSbSpx7FDM,11562
|
|
21
21
|
scmrepo/git/backend/dulwich/client.py,sha256=bcDroljSvNz6s5WWv9UVvZHKkOJOVTK_zU7YCq62TN4,2360
|
|
22
|
-
scmrepo/git/backend/pygit2/__init__.py,sha256=
|
|
22
|
+
scmrepo/git/backend/pygit2/__init__.py,sha256=qquYBHB-gpW-AeDjO5OqSUpRKBhfLvGHFy-Od35g0DA,36356
|
|
23
23
|
scmrepo/git/backend/pygit2/callbacks.py,sha256=Ky4YmUPhv9xjU_44ypBYIcaVHJixzaGb6t9HIeUmBP4,2751
|
|
24
24
|
scmrepo/git/backend/pygit2/filter.py,sha256=2NlWfQ7soXN1H7Es6-LctE74hpj3QKQTlYqXRH83VpM,2128
|
|
25
25
|
scmrepo/git/lfs/__init__.py,sha256=at5blRIKnKpg_g5dLRDsGWBFi6SbucRlF_DX6aAkGtE,257
|
|
@@ -31,8 +31,8 @@ scmrepo/git/lfs/pointer.py,sha256=BcVbtjoOUG9cEzyJSJDeweqehGZvq43P6NNLDYUGYEI,31
|
|
|
31
31
|
scmrepo/git/lfs/progress.py,sha256=ELlBs2SeXhAcnPDN23w3FTeBRgB9RGqBD2CFMS6n9Xs,4750
|
|
32
32
|
scmrepo/git/lfs/smudge.py,sha256=1O_fznptWo4CKXqcJgUoWP6cgWWhvGAZ3d87kasG3cQ,1610
|
|
33
33
|
scmrepo/git/lfs/storage.py,sha256=LbHGhSRdORu4Iqzb7Ef-2tA_iJbZykXZFotWRJvyr2Y,2380
|
|
34
|
-
scmrepo-3.3.
|
|
35
|
-
scmrepo-3.3.
|
|
36
|
-
scmrepo-3.3.
|
|
37
|
-
scmrepo-3.3.
|
|
38
|
-
scmrepo-3.3.
|
|
34
|
+
scmrepo-3.3.5.dist-info/LICENSE,sha256=-1jhbPjoIVHR0cEgahL4Zhct75Ff4MzYCR_jOaJDPq8,11340
|
|
35
|
+
scmrepo-3.3.5.dist-info/METADATA,sha256=fS-xs4RY1ybtzHNycu6upzY6p4GJD2SN9-ExeS-sFaw,4731
|
|
36
|
+
scmrepo-3.3.5.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
37
|
+
scmrepo-3.3.5.dist-info/top_level.txt,sha256=iunjod6w3GogERsAYfLRupnANXnqzX3jbIfbeIQG5cc,8
|
|
38
|
+
scmrepo-3.3.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|