Remove platform_utils.realpath
... since it's just a simple wrapper of os.path.realpath now.
Change-Id: I7433e5fe09c64b130f06e2541151dce1961772c9
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/416637
Tested-by: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Greg Edelston <gredelston@google.com>
Commit-Queue: Kaiyi Li <kaiyili@google.com>
diff --git a/platform_utils.py b/platform_utils.py
index 2906009..e20198e 100644
--- a/platform_utils.py
+++ b/platform_utils.py
@@ -251,12 +251,3 @@
return platform_utils_win32.readlink(_makelongpath(path))
else:
return os.readlink(path)
-
-
-def realpath(path):
- """Return the canonical path of the specified filename, eliminating
- any symbolic links encountered in the path.
-
- Availability: Windows, Unix.
- """
- return os.path.realpath(path)
diff --git a/project.py b/project.py
index 1f5e4c3..0e60111 100644
--- a/project.py
+++ b/project.py
@@ -145,7 +145,7 @@
"""
global _project_hook_list
if _project_hook_list is None:
- d = platform_utils.realpath(os.path.abspath(os.path.dirname(__file__)))
+ d = os.path.realpath(os.path.abspath(os.path.dirname(__file__)))
d = os.path.join(d, "hooks")
_project_hook_list = [
os.path.join(d, x) for x in platform_utils.listdir(d)
@@ -1826,7 +1826,7 @@
# remove because it will recursively delete projects -- we handle that
# ourselves below. https://crbug.com/git/48
if self.use_git_worktrees:
- needle = platform_utils.realpath(self.gitdir)
+ needle = os.path.realpath(self.gitdir)
# Find the git worktree commondir under .repo/worktrees/.
output = self.bare_git.worktree("list", "--porcelain").splitlines()[
0
@@ -1840,7 +1840,7 @@
with open(gitdir) as fp:
relpath = fp.read().strip()
# Resolve the checkout path and see if it matches this project.
- fullpath = platform_utils.realpath(
+ fullpath = os.path.realpath(
os.path.join(configs, name, relpath)
)
if fullpath == needle:
@@ -2975,14 +2975,12 @@
"Retrying clone after deleting %s", self.gitdir
)
try:
- platform_utils.rmtree(
- platform_utils.realpath(self.gitdir)
- )
+ platform_utils.rmtree(os.path.realpath(self.gitdir))
if self.worktree and os.path.exists(
- platform_utils.realpath(self.worktree)
+ os.path.realpath(self.worktree)
):
platform_utils.rmtree(
- platform_utils.realpath(self.worktree)
+ os.path.realpath(self.worktree)
)
return self._InitGitDir(
mirror_git=mirror_git,
@@ -3068,7 +3066,7 @@
self._InitHooks(quiet=quiet)
def _InitHooks(self, quiet=False):
- hooks = platform_utils.realpath(os.path.join(self.objdir, "hooks"))
+ hooks = os.path.realpath(os.path.join(self.objdir, "hooks"))
if not os.path.exists(hooks):
os.makedirs(hooks)
@@ -3211,9 +3209,9 @@
dst_path = os.path.join(destdir, name)
src_path = os.path.join(srcdir, name)
- dst = platform_utils.realpath(dst_path)
+ dst = os.path.realpath(dst_path)
if os.path.lexists(dst):
- src = platform_utils.realpath(src_path)
+ src = os.path.realpath(src_path)
# Fail if the links are pointing to the wrong place.
if src != dst:
logger.error(
@@ -3249,10 +3247,10 @@
if copy_all:
to_copy = platform_utils.listdir(gitdir)
- dotgit = platform_utils.realpath(dotgit)
+ dotgit = os.path.realpath(dotgit)
for name in set(to_copy).union(to_symlink):
try:
- src = platform_utils.realpath(os.path.join(gitdir, name))
+ src = os.path.realpath(os.path.join(gitdir, name))
dst = os.path.join(dotgit, name)
if os.path.lexists(dst):
@@ -3349,9 +3347,7 @@
else:
if not init_dotgit:
# See if the project has changed.
- if platform_utils.realpath(
- self.gitdir
- ) != platform_utils.realpath(dotgit):
+ if os.path.realpath(self.gitdir) != os.path.realpath(dotgit):
platform_utils.remove(dotgit)
if init_dotgit or not os.path.exists(dotgit):