diff options
Diffstat (limited to 'git/refs')
-rw-r--r-- | git/refs/log.py | 36 | ||||
-rw-r--r-- | git/refs/remote.py | 9 | ||||
-rw-r--r-- | git/refs/symbolic.py | 38 |
3 files changed, 37 insertions, 46 deletions
diff --git a/git/refs/log.py b/git/refs/log.py index 3078355d..bab6ae04 100644 --- a/git/refs/log.py +++ b/git/refs/log.py @@ -1,31 +1,29 @@ +import re +import time + +from git.compat import ( + PY3, + xrange, + string_types, + defenc +) +from git.objects.util import ( + parse_date, + Serializable, + altz_to_utctz_str, +) from git.util import ( Actor, LockedFD, LockFile, assure_directory_exists, to_native_path, -) - -from gitdb.util import ( bin_to_hex, - join, - file_contents_ro_filepath, + file_contents_ro_filepath ) -from git.objects.util import ( - parse_date, - Serializable, - altz_to_utctz_str, -) -from git.compat import ( - PY3, - xrange, - string_types, - defenc -) +import os.path as osp -import time -import re __all__ = ["RefLog", "RefLogEntry"] @@ -185,7 +183,7 @@ class RefLog(list, Serializable): instance would be found. The path is not guaranteed to point to a valid file though. :param ref: SymbolicReference instance""" - return join(ref.repo.git_dir, "logs", to_native_path(ref.path)) + return osp.join(ref.repo.git_dir, "logs", to_native_path(ref.path)) @classmethod def iter_entries(cls, stream): diff --git a/git/refs/remote.py b/git/refs/remote.py index 1f256b75..4fc784d1 100644 --- a/git/refs/remote.py +++ b/git/refs/remote.py @@ -1,9 +1,10 @@ +import os + from git.util import join_path -from gitdb.util import join -from .head import Head +import os.path as osp -import os +from .head import Head __all__ = ["RemoteReference"] @@ -36,7 +37,7 @@ class RemoteReference(Head): # and delete remainders manually for ref in refs: try: - os.remove(join(repo.git_dir, ref.path)) + os.remove(osp.join(repo.git_dir, ref.path)) except OSError: pass # END for each ref diff --git a/git/refs/symbolic.py b/git/refs/symbolic.py index d1c412c8..3a93d81c 100644 --- a/git/refs/symbolic.py +++ b/git/refs/symbolic.py @@ -9,22 +9,14 @@ from git.util import ( join_path, join_path_native, to_native_path_linux, - assure_directory_exists + assure_directory_exists, + hex_to_bin, + LockedFD ) from gitdb.exc import ( BadObject, BadName ) -from gitdb.util import ( - join, - dirname, - isdir, - exists, - isfile, - rename, - hex_to_bin, - LockedFD -) import os.path as osp @@ -83,7 +75,7 @@ class SymbolicReference(object): @classmethod def _get_packed_refs_path(cls, repo): - return join(repo.git_dir, 'packed-refs') + return osp.join(repo.git_dir, 'packed-refs') @classmethod def _iter_packed_refs(cls, repo): @@ -136,7 +128,7 @@ class SymbolicReference(object): point to, or None""" tokens = None try: - with open(join(repo.git_dir, ref_path), 'rt') as fp: + with open(osp.join(repo.git_dir, ref_path), 'rt') as fp: value = fp.read().rstrip() # Don't only split on spaces, but on whitespace, which allows to parse lines like # 60b64ef992065e2600bfef6187a97f92398a9144 branch 'master' of git-server:/path/to/repo @@ -420,8 +412,8 @@ class SymbolicReference(object): or just "myreference", hence 'refs/' is implied. Alternatively the symbolic reference to be deleted""" full_ref_path = cls.to_full_path(path) - abs_path = join(repo.git_dir, full_ref_path) - if exists(abs_path): + abs_path = osp.join(repo.git_dir, full_ref_path) + if osp.exists(abs_path): os.remove(abs_path) else: # check packed refs @@ -472,14 +464,14 @@ class SymbolicReference(object): corresponding object and a detached symbolic reference will be created instead""" full_ref_path = cls.to_full_path(path) - abs_ref_path = join(repo.git_dir, full_ref_path) + abs_ref_path = osp.join(repo.git_dir, full_ref_path) # figure out target data target = reference if resolve: target = repo.rev_parse(str(reference)) - if not force and isfile(abs_ref_path): + if not force and osp.isfile(abs_ref_path): target_data = str(target) if isinstance(target, SymbolicReference): target_data = target.path @@ -546,9 +538,9 @@ class SymbolicReference(object): if self.path == new_path: return self - new_abs_path = join(self.repo.git_dir, new_path) - cur_abs_path = join(self.repo.git_dir, self.path) - if isfile(new_abs_path): + new_abs_path = osp.join(self.repo.git_dir, new_path) + cur_abs_path = osp.join(self.repo.git_dir, self.path) + if osp.isfile(new_abs_path): if not force: # if they point to the same file, its not an error with open(new_abs_path, 'rb') as fd1: @@ -563,12 +555,12 @@ class SymbolicReference(object): os.remove(new_abs_path) # END handle existing target file - dname = dirname(new_abs_path) - if not isdir(dname): + dname = osp.dirname(new_abs_path) + if not osp.isdir(dname): os.makedirs(dname) # END create directory - rename(cur_abs_path, new_abs_path) + os.rename(cur_abs_path, new_abs_path) self.path = new_path return self |