diff options
Diffstat (limited to 'git/refs')
-rw-r--r-- | git/refs/head.py | 4 | ||||
-rw-r--r-- | git/refs/log.py | 6 | ||||
-rw-r--r-- | git/refs/reference.py | 8 | ||||
-rw-r--r-- | git/refs/remote.py | 2 | ||||
-rw-r--r-- | git/refs/symbolic.py | 30 | ||||
-rw-r--r-- | git/refs/tag.py | 4 |
6 files changed, 27 insertions, 27 deletions
diff --git a/git/refs/head.py b/git/refs/head.py index 662c2c87..958f83fa 100644 --- a/git/refs/head.py +++ b/git/refs/head.py @@ -29,7 +29,7 @@ class HEAD(SymbolicReference): to contain the previous value of HEAD""" return SymbolicReference(self.repo, self._ORIG_HEAD_NAME) - def reset(self, commit='HEAD', index=True, working_tree = False, + def reset(self, commit='HEAD', index=True, working_tree=False, paths=None, **kwargs): """Reset our HEAD to the given commit optionally synchronizing the index and working tree. The reference we refer to will be set to @@ -71,7 +71,7 @@ class HEAD(SymbolicReference): if working_tree: mode = "--hard" if not index: - raise ValueError( "Cannot reset the working tree if the index is not reset as well") + raise ValueError("Cannot reset the working tree if the index is not reset as well") # END working tree handling diff --git a/git/refs/log.py b/git/refs/log.py index 8917f3fa..c075e7a0 100644 --- a/git/refs/log.py +++ b/git/refs/log.py @@ -100,8 +100,8 @@ class RefLogEntry(tuple): raise ValueError("Missing token: >") #END handle missing end brace - actor = Actor._from_string(info[82:email_end+1]) - time, tz_offset = parse_date(info[email_end+2:]) + actor = Actor._from_string(info[82:email_end + 1]) + time, tz_offset = parse_date(info[email_end + 2:]) return RefLogEntry((oldhexsha, newhexsha, actor, (time, tz_offset), msg)) @@ -200,7 +200,7 @@ class RefLog(list, Serializable): return RefLogEntry.from_line(fp.readlines()[index].strip()) else: # read until index is reached - for i in xrange(index+1): + for i in xrange(index + 1): line = fp.readline() if not line: break diff --git a/git/refs/reference.py b/git/refs/reference.py index a8ecc95d..dc745cce 100644 --- a/git/refs/reference.py +++ b/git/refs/reference.py @@ -36,7 +36,7 @@ class Reference(SymbolicReference, LazyMixin, Iterable): _resolve_ref_on_create = True _common_path_default = "refs" - def __init__(self, repo, path, check_path = True): + def __init__(self, repo, path, check_path=True): """Initialize this instance :param repo: Our parent repository @@ -45,7 +45,7 @@ class Reference(SymbolicReference, LazyMixin, Iterable): refs/heads/master :param check_path: if False, you can provide any path. Otherwise the path must start with the default path prefix of this type.""" - if check_path and not path.startswith(self._common_path_default+'/'): + if check_path and not path.startswith(self._common_path_default + '/'): raise ValueError("Cannot instantiate %r from path %s" % (self.__class__.__name__, path)) super(Reference, self).__init__(repo, path) @@ -54,7 +54,7 @@ class Reference(SymbolicReference, LazyMixin, Iterable): #{ Interface - def set_object(self, object, logmsg = None): + def set_object(self, object, logmsg=None): """Special version which checks if the head-log needs an update as well""" oldbinsha = None if logmsg is not None: @@ -95,7 +95,7 @@ class Reference(SymbolicReference, LazyMixin, Iterable): return '/'.join(tokens[2:]) @classmethod - def iter_items(cls, repo, common_path = None): + def iter_items(cls, repo, common_path=None): """Equivalent to SymbolicReference.iter_items, but will return non-detached references as well.""" return cls._iter_items(repo, common_path) diff --git a/git/refs/remote.py b/git/refs/remote.py index 6dd0856c..394ad9e5 100644 --- a/git/refs/remote.py +++ b/git/refs/remote.py @@ -14,7 +14,7 @@ class RemoteReference(Head): _common_path_default = Head._remote_common_path_default @classmethod - def iter_items(cls, repo, common_path = None, remote=None): + def iter_items(cls, repo, common_path=None, remote=None): """Iterate remote references, and if given, constrain them to the given remote""" common_path = common_path or cls._common_path_default if remote is not None: diff --git a/git/refs/symbolic.py b/git/refs/symbolic.py index 6832b8f2..1115ac9c 100644 --- a/git/refs/symbolic.py +++ b/git/refs/symbolic.py @@ -54,7 +54,7 @@ class SymbolicReference(object): return False def __ne__(self, other): - return not ( self == other ) + return not (self == other) def __hash__(self): return hash(self.path) @@ -99,7 +99,7 @@ class SymbolicReference(object): yield tuple(line.split(' ', 1)) # END for each line - except (OSError,IOError): + except (OSError, IOError): raise StopIteration # END no packed-refs file handling # NOTE: Had try-finally block around here to close the fp, @@ -130,7 +130,7 @@ class SymbolicReference(object): value = fp.read().rstrip() fp.close() tokens = value.split(" ") - except (OSError,IOError): + except (OSError, IOError): # Probably we are just packed, find our entry in the packed refs file # NOTE: We are not a symbolic ref if we are in a packed file, as these # are excluded explictly @@ -177,7 +177,7 @@ class SymbolicReference(object): #END handle type return obj - def set_commit(self, commit, logmsg = None): + def set_commit(self, commit, logmsg=None): """As set_object, but restricts the type of object to be a Commit :raise ValueError: If commit is not a Commit object or doesn't point to @@ -206,7 +206,7 @@ class SymbolicReference(object): return self - def set_object(self, object, logmsg = None): + def set_object(self, object, logmsg=None): """Set the object we point to, possibly dereference our symbolic reference first. If the reference does not exist, it will be created @@ -245,7 +245,7 @@ class SymbolicReference(object): raise TypeError("%s is a detached symbolic reference as it points to %r" % (self, sha)) return self.from_path(self.repo, target_ref_path) - def set_reference(self, ref, logmsg = None): + def set_reference(self, ref, logmsg=None): """Set ourselves to the given ref. It will stay a symbol if the ref is a Reference. Otherwise an Object, given as Object instance or refspec, is assumed and if valid, will be set which effectively detaches the refererence if it was a purely @@ -272,7 +272,7 @@ class SymbolicReference(object): write_value = ref.hexsha elif isinstance(ref, basestring): try: - obj = self.repo.rev_parse(ref+"^{}") # optionally deref tags + obj = self.repo.rev_parse(ref + "^{}") # optionally deref tags write_value = obj.hexsha except BadObject: raise ValueError("Could not extract object from %s" % ref) @@ -378,7 +378,7 @@ class SymbolicReference(object): full_ref_path = path if not cls._common_path_default: return full_ref_path - if not path.startswith(cls._common_path_default+"/"): + if not path.startswith(cls._common_path_default + "/"): full_ref_path = '%s/%s' % (cls._common_path_default, path) return full_ref_path @@ -402,7 +402,7 @@ class SymbolicReference(object): pack_file_path = cls._get_packed_refs_path(repo) try: reader = open(pack_file_path, 'rb') - except (OSError,IOError): + except (OSError, IOError): pass # it didnt exist at all else: new_lines = list() @@ -414,7 +414,7 @@ class SymbolicReference(object): # If we deleted the last line and this one is a tag-reference object, # we drop it as well if ( line.startswith('#') or full_ref_path not in line ) and \ - ( not dropped_last_line or dropped_last_line and not line.startswith('^') ): + (not dropped_last_line or dropped_last_line and not line.startswith('^')): new_lines.append(line) dropped_last_line = False continue @@ -526,7 +526,7 @@ class SymbolicReference(object): if isfile(new_abs_path): if not force: # if they point to the same file, its not an error - if open(new_abs_path,'rb').read().strip() != open(cur_abs_path,'rb').read().strip(): + if open(new_abs_path, 'rb').read().strip() != open(cur_abs_path, 'rb').read().strip(): raise OSError("File at path %r already exists" % new_abs_path) # else: we could remove ourselves and use the otherone, but # but clarity we just continue as usual @@ -545,7 +545,7 @@ class SymbolicReference(object): return self @classmethod - def _iter_items(cls, repo, common_path = None): + def _iter_items(cls, repo, common_path=None): if common_path is None: common_path = cls._common_path_default rela_paths = set() @@ -554,7 +554,7 @@ class SymbolicReference(object): # Currently we do not follow links for root, dirs, files in os.walk(join_path_native(repo.git_dir, common_path)): if 'refs/' not in root: # skip non-refs subfolders - refs_id = [ d for d in dirs if d == 'refs' ] + refs_id = [d for d in dirs if d == 'refs'] if refs_id: dirs[0:] = ['refs'] # END prune non-refs folders @@ -581,7 +581,7 @@ class SymbolicReference(object): # END for each sorted relative refpath @classmethod - def iter_items(cls, repo, common_path = None): + def iter_items(cls, repo, common_path=None): """Find all refs in the repository :param repo: is the Repo @@ -598,7 +598,7 @@ class SymbolicReference(object): List is lexigraphically sorted The returned objects represent actual subclasses, such as Head or TagReference""" - return ( r for r in cls._iter_items(repo, common_path) if r.__class__ == SymbolicReference or not r.is_detached ) + return (r for r in cls._iter_items(repo, common_path) if r.__class__ == SymbolicReference or not r.is_detached) @classmethod def from_path(cls, repo, path): diff --git a/git/refs/tag.py b/git/refs/tag.py index 2845ec7c..ff32224a 100644 --- a/git/refs/tag.py +++ b/git/refs/tag.py @@ -30,7 +30,7 @@ class TagReference(Reference): # it is a tag object which carries the commit as an object - we can point to anything return obj.object else: - raise ValueError( "Tag %s points to a Blob or Tree - have never seen that before" % self ) + raise ValueError("Tag %s points to a Blob or Tree - have never seen that before" % self) @property def tag(self): @@ -71,7 +71,7 @@ class TagReference(Reference): Additional keyword arguments to be passed to git-tag :return: A new TagReference""" - args = ( path, ref ) + args = (path, ref) if message: kwargs['m'] = message if force: |