summaryrefslogtreecommitdiff
path: root/git/repo
diff options
context:
space:
mode:
Diffstat (limited to 'git/repo')
-rw-r--r--git/repo/base.py61
-rw-r--r--git/repo/fun.py40
2 files changed, 54 insertions, 47 deletions
diff --git a/git/repo/base.py b/git/repo/base.py
index 5273d4b2..174f29aa 100644
--- a/git/repo/base.py
+++ b/git/repo/base.py
@@ -9,35 +9,35 @@ from git.cmd import Git
from git.util import (
Actor,
finalize_process
- )
+)
from git.refs import *
from git.index import IndexFile
from git.objects import *
from git.config import GitConfigParser
from git.remote import (
- Remote,
- digest_process_messages,
- add_progress
- )
+ Remote,
+ digest_process_messages,
+ add_progress
+)
from git.db import (
- GitCmdObjectDB,
- GitDB
- )
+ GitCmdObjectDB,
+ GitDB
+)
from gitdb.util import (
- join,
- isfile,
- hex_to_bin
- )
+ join,
+ isfile,
+ hex_to_bin
+)
from fun import (
- rev_parse,
- is_git_dir,
- find_git_dir,
- read_gitfile,
- touch,
- )
+ rev_parse,
+ is_git_dir,
+ find_git_dir,
+ read_gitfile,
+ touch,
+)
import os
import sys
@@ -53,6 +53,7 @@ __all__ = ('Repo', )
class Repo(object):
+
"""Represents a git repository and allows you to query references,
gather commit information, generate diffs, create and clone repositories query
the log.
@@ -488,7 +489,8 @@ class Repo(object):
# END file handling
# END alts handling
- alternates = property(_get_alternates, _set_alternates, doc="Retrieve a list of alternates paths or set a list paths to be used as alternates")
+ alternates = property(_get_alternates, _set_alternates,
+ doc="Retrieve a list of alternates paths or set a list paths to be used as alternates")
def is_dirty(self, index=True, working_tree=True, untracked_files=False):
"""
@@ -506,7 +508,7 @@ class Repo(object):
if index:
# diff index against HEAD
if isfile(self.index.path) and \
- len(self.git.diff('--cached', *default_args)):
+ len(self.git.diff('--cached', *default_args)):
return True
# END index handling
if working_tree:
@@ -576,7 +578,8 @@ class Repo(object):
if self.re_hexsha_only.search(firstpart):
# handles
# 634396b2f541a9f2d58b00be1a07f0c358b999b3 1 1 7 - indicates blame-data start
- # 634396b2f541a9f2d58b00be1a07f0c358b999b3 2 2 - indicates another line of blame with the same data
+ # 634396b2f541a9f2d58b00be1a07f0c358b999b3 2 2 - indicates
+ # another line of blame with the same data
digits = parts[-1].split(" ")
if len(digits) == 3:
info = {'id': firstpart}
@@ -620,11 +623,12 @@ class Repo(object):
c = commits.get(sha)
if c is None:
c = Commit(self, hex_to_bin(sha),
- author=Actor._from_string(info['author'] + ' ' + info['author_email']),
- authored_date=info['author_date'],
- committer=Actor._from_string(info['committer'] + ' ' + info['committer_email']),
- committed_date=info['committer_date'],
- message=info['summary'])
+ author=Actor._from_string(info['author'] + ' ' + info['author_email']),
+ authored_date=info['author_date'],
+ committer=Actor._from_string(
+ info['committer'] + ' ' + info['committer_email']),
+ committed_date=info['committer_date'],
+ message=info['summary'])
commits[sha] = c
# END if commit objects needs initial creation
m = self.re_tab_full_line.search(line)
@@ -693,10 +697,11 @@ class Repo(object):
# END windows handling
try:
- proc = git.clone(url, path, with_extended_output=True, as_process=True, v=True, **add_progress(kwargs, git, progress))
+ proc = git.clone(url, path, with_extended_output=True, as_process=True,
+ v=True, **add_progress(kwargs, git, progress))
if progress:
digest_process_messages(proc.stderr, progress)
- #END handle progress
+ # END handle progress
finalize_process(proc)
finally:
if prev_cwd is not None:
diff --git a/git/repo/fun.py b/git/repo/fun.py
index 0bff677a..b8905517 100644
--- a/git/repo/fun.py
+++ b/git/repo/fun.py
@@ -4,16 +4,16 @@ from gitdb.exc import BadObject
from git.refs import SymbolicReference
from git.objects import Object
from gitdb.util import (
- join,
- isdir,
- isfile,
- dirname,
- hex_to_bin,
- bin_to_hex
- )
+ join,
+ isdir,
+ isfile,
+ dirname,
+ hex_to_bin,
+ bin_to_hex
+)
from string import digits
-__all__ = ('rev_parse', 'is_git_dir', 'touch', 'read_gitfile', 'find_git_dir', 'name_to_object',
+__all__ = ('rev_parse', 'is_git_dir', 'touch', 'read_gitfile', 'find_git_dir', 'name_to_object',
'short_to_long', 'deref_tag', 'to_commit')
@@ -30,8 +30,8 @@ def is_git_dir(d):
isdir(join(d, 'refs')):
headref = join(d, 'HEAD')
return isfile(headref) or \
- (os.path.islink(headref) and
- os.readlink(headref).startswith('refs'))
+ (os.path.islink(headref) and
+ os.readlink(headref).startswith('refs'))
return False
@@ -46,13 +46,14 @@ def find_git_dir(d):
return find_git_dir(d)
return None
+
def read_gitfile(f):
""" This is taken from the git setup.c:read_gitfile function.
:return gitdir path or None if gitfile is invalid."""
if f is None:
return None
try:
- line = open(f, 'r').readline().rstrip()
+ line = open(f, 'r').readline().rstrip()
except (OSError, IOError):
# File might not exist or is unreadable - ignore
return None
@@ -62,6 +63,7 @@ def read_gitfile(f):
path = os.path.realpath(line[8:])
return path if is_git_dir(path) else None
+
def short_to_long(odb, hexsha):
""":return: long hexadecimal sha1 from the given less-than-40 byte hexsha
or None if no candidate could be found.
@@ -90,7 +92,7 @@ def name_to_object(repo, name, return_ref=False):
else:
hexsha = name
# END handle short shas
- #END find sha if it matches
+ # END find sha if it matches
# if we couldn't find an object for what seemed to be a short hexsha
# try to find it as reference anyway, it could be named 'aaa' for instance
@@ -100,7 +102,7 @@ def name_to_object(repo, name, return_ref=False):
hexsha = SymbolicReference.dereference_recursive(repo, base % name)
if return_ref:
return SymbolicReference(repo, base % name)
- #END handle symbolic ref
+ # END handle symbolic ref
break
except ValueError:
pass
@@ -110,7 +112,7 @@ def name_to_object(repo, name, return_ref=False):
# didn't find any ref, this is an error
if return_ref:
raise BadObject("Couldn't find reference named %r" % name)
- #END handle return ref
+ # END handle return ref
# tried everything ? fail
if hexsha is None:
@@ -183,12 +185,12 @@ def rev_parse(repo, rev):
ref = name_to_object(repo, rev[:start], return_ref=True)
else:
obj = name_to_object(repo, rev[:start])
- #END handle token
- #END handle refname
+ # END handle token
+ # END handle refname
if ref is not None:
obj = ref.commit
- #END handle ref
+ # END handle ref
# END initialize obj on first token
start += 1
@@ -227,13 +229,13 @@ def rev_parse(repo, rev):
# TODO: Try to parse the other date options, using parse_date
# maybe
raise NotImplementedError("Support for additional @{...} modes not implemented")
- #END handle revlog index
+ # END handle revlog index
try:
entry = ref.log_entry(revlog_index)
except IndexError:
raise IndexError("Invalid revlog index: %i" % revlog_index)
- #END handle index out of bound
+ # END handle index out of bound
obj = Object.new_from_sha(repo, hex_to_bin(entry.newhexsha))