Jelmer Vernooij 2 ماه پیش
والد
کامیت
a5845b82b2
2فایلهای تغییر یافته به همراه25 افزوده شده و 23 حذف شده
  1. 1 1
      dulwich/client.py
  2. 24 22
      dulwich/worktree.py

+ 1 - 1
dulwich/client.py

@@ -3065,7 +3065,7 @@ class SSHGitClient(TraditionalGitClient):
         path_encoding: str = TraditionalGitClient.DEFAULT_ENCODING,
         path_encoding: str = TraditionalGitClient.DEFAULT_ENCODING,
         vendor: Optional[SSHVendor] = None,
         vendor: Optional[SSHVendor] = None,
         key_filename: Optional[str] = None,
         key_filename: Optional[str] = None,
-        ssh_command: str | None = None,
+        ssh_command: Optional[str] = None,
     ) -> "SSHGitClient":
     ) -> "SSHGitClient":
         """Create an SSHGitClient from a parsed URL.
         """Create an SSHGitClient from a parsed URL.
 
 

+ 24 - 22
dulwich/worktree.py

@@ -154,8 +154,8 @@ class WorkTreeContainer:
 
 
     def add(
     def add(
         self,
         self,
-        path: str | bytes | os.PathLike[str],
-        branch: str | bytes | None = None,
+        path: Union[str, bytes, os.PathLike[str]],
+        branch: Union[str, bytes, None] = None,
         commit: ObjectID | None = None,
         commit: ObjectID | None = None,
         force: bool = False,
         force: bool = False,
         detach: bool = False,
         detach: bool = False,
@@ -184,7 +184,7 @@ class WorkTreeContainer:
             exist_ok=exist_ok,
             exist_ok=exist_ok,
         )
         )
 
 
-    def remove(self, path: str | bytes | os.PathLike[str], force: bool = False) -> None:
+    def remove(self, path: Union[str, bytes, os.PathLike[str]], force: bool = False) -> None:
         """Remove a worktree.
         """Remove a worktree.
 
 
         Args:
         Args:
@@ -209,8 +209,8 @@ class WorkTreeContainer:
 
 
     def move(
     def move(
         self,
         self,
-        old_path: str | bytes | os.PathLike[str],
-        new_path: str | bytes | os.PathLike[str],
+        old_path: Union[str, bytes, os.PathLike[str]],
+        new_path: Union[str, bytes, os.PathLike[str]],
     ) -> None:
     ) -> None:
         """Move a worktree to a new location.
         """Move a worktree to a new location.
 
 
@@ -221,7 +221,7 @@ class WorkTreeContainer:
         move_worktree(self._repo, old_path, new_path)
         move_worktree(self._repo, old_path, new_path)
 
 
     def lock(
     def lock(
-        self, path: str | bytes | os.PathLike[str], reason: str | None = None
+        self, path: Union[str, bytes, os.PathLike[str]], reason: str | None = None
     ) -> None:
     ) -> None:
         """Lock a worktree to prevent it from being pruned.
         """Lock a worktree to prevent it from being pruned.
 
 
@@ -231,7 +231,7 @@ class WorkTreeContainer:
         """
         """
         lock_worktree(self._repo, path, reason=reason)
         lock_worktree(self._repo, path, reason=reason)
 
 
-    def unlock(self, path: str | bytes | os.PathLike[str]) -> None:
+    def unlock(self, path: Union[str, bytes, os.PathLike[str]]) -> None:
         """Unlock a worktree.
         """Unlock a worktree.
 
 
         Args:
         Args:
@@ -240,7 +240,7 @@ class WorkTreeContainer:
         unlock_worktree(self._repo, path)
         unlock_worktree(self._repo, path)
 
 
     def repair(
     def repair(
-        self, paths: Sequence[str | bytes | os.PathLike[str]] | None = None
+        self, paths: Sequence[Union[str, bytes, os.PathLike[str]]] | None = None
     ) -> builtins.list[str]:
     ) -> builtins.list[str]:
         """Repair worktree administrative files.
         """Repair worktree administrative files.
 
 
@@ -265,7 +265,7 @@ class WorkTree:
     such as staging files, committing changes, and resetting the index.
     such as staging files, committing changes, and resetting the index.
     """
     """
 
 
-    def __init__(self, repo: Repo, path: str | bytes | os.PathLike[str]) -> None:
+    def __init__(self, repo: Repo, path: Union[str, bytes, os.PathLike[str]]) -> None:
         """Initialize a WorkTree for the given repository.
         """Initialize a WorkTree for the given repository.
 
 
         Args:
         Args:
@@ -282,10 +282,12 @@ class WorkTree:
 
 
     def stage(
     def stage(
         self,
         self,
-        fs_paths: str
-        | bytes
-        | os.PathLike[str]
-        | Iterable[str | bytes | os.PathLike[str]],
+        fs_paths: Union[
+            str,
+            bytes,
+            os.PathLike[str],
+            Iterable[Union[str, bytes, os.PathLike[str]]],
+        ],
     ) -> None:
     ) -> None:
         """Stage a set of paths.
         """Stage a set of paths.
 
 
@@ -920,8 +922,8 @@ def list_worktrees(repo: Repo) -> list[WorkTreeInfo]:
 
 
 def add_worktree(
 def add_worktree(
     repo: Repo,
     repo: Repo,
-    path: str | bytes | os.PathLike[str],
-    branch: str | bytes | None = None,
+    path: Union[str, bytes, os.PathLike[str]],
+    branch: Union[str, bytes, None] = None,
     commit: ObjectID | None = None,
     commit: ObjectID | None = None,
     force: bool = False,
     force: bool = False,
     detach: bool = False,
     detach: bool = False,
@@ -1014,7 +1016,7 @@ def add_worktree(
 
 
 
 
 def remove_worktree(
 def remove_worktree(
-    repo: Repo, path: str | bytes | os.PathLike[str], force: bool = False
+    repo: Repo, path: Union[str, bytes, os.PathLike[str]], force: bool = False
 ) -> None:
 ) -> None:
     """Remove a worktree.
     """Remove a worktree.
 
 
@@ -1146,7 +1148,7 @@ def prune_worktrees(
 
 
 
 
 def lock_worktree(
 def lock_worktree(
-    repo: Repo, path: str | bytes | os.PathLike[str], reason: str | None = None
+    repo: Repo, path: Union[str, bytes, os.PathLike[str]], reason: str | None = None
 ) -> None:
 ) -> None:
     """Lock a worktree to prevent it from being pruned.
     """Lock a worktree to prevent it from being pruned.
 
 
@@ -1164,7 +1166,7 @@ def lock_worktree(
             f.write(reason)
             f.write(reason)
 
 
 
 
-def unlock_worktree(repo: Repo, path: str | bytes | os.PathLike[str]) -> None:
+def unlock_worktree(repo: Repo, path: Union[str, bytes, os.PathLike[str]]) -> None:
     """Unlock a worktree.
     """Unlock a worktree.
 
 
     Args:
     Args:
@@ -1179,7 +1181,7 @@ def unlock_worktree(repo: Repo, path: str | bytes | os.PathLike[str]) -> None:
         os.remove(lock_path)
         os.remove(lock_path)
 
 
 
 
-def _find_worktree_id(repo: Repo, path: str | bytes | os.PathLike[str]) -> str:
+def _find_worktree_id(repo: Repo, path: Union[str, bytes, os.PathLike[str]]) -> str:
     """Find the worktree identifier for the given path.
     """Find the worktree identifier for the given path.
 
 
     Args:
     Args:
@@ -1221,8 +1223,8 @@ def _find_worktree_id(repo: Repo, path: str | bytes | os.PathLike[str]) -> str:
 
 
 def move_worktree(
 def move_worktree(
     repo: Repo,
     repo: Repo,
-    old_path: str | bytes | os.PathLike[str],
-    new_path: str | bytes | os.PathLike[str],
+    old_path: Union[str, bytes, os.PathLike[str]],
+    new_path: Union[str, bytes, os.PathLike[str]],
 ) -> None:
 ) -> None:
     """Move a worktree to a new location.
     """Move a worktree to a new location.
 
 
@@ -1265,7 +1267,7 @@ def move_worktree(
 
 
 
 
 def repair_worktree(
 def repair_worktree(
-    repo: Repo, paths: Sequence[str | bytes | os.PathLike[str]] | None = None
+    repo: Repo, paths: Sequence[Union[str, bytes, os.PathLike[str]]] | None = None
 ) -> list[str]:
 ) -> list[str]:
     """Repair worktree administrative files.
     """Repair worktree administrative files.