Changeset 3174
- Timestamp:
- 02/05/08 05:28:35 (10 months ago)
- Files:
-
- gitplugin/0.10/gitplugin/git_fs.py (modified) (12 diffs)
- gitplugin/0.10/gitplugin/PyGIT.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gitplugin/0.10/gitplugin/git_fs.py
r3173 r3174 1 1 # -*- coding: iso-8859-1 -*- 2 2 # 3 # Copyright (C) 2006 Herbert Valerio Riedel <hvr@gnu.org>3 # Copyright (C) 2006,2008 Herbert Valerio Riedel <hvr@gnu.org> 4 4 # 5 5 # This program is free software; you can redistribute it and/or … … 27 27 28 28 def get_repository(self, type, dir, authname): 29 return GitRepository(dir, self.log) 29 options = dict(self.config.options(type)) 30 return GitRepository(dir, self.log, options) 30 31 31 32 class GitRepository(Repository): 32 def __init__(self, path, log ):33 def __init__(self, path, log, options): 33 34 self.gitrepo = path 34 35 self.git = PyGIT.Storage(path) … … 59 60 return GitNode(self.git, path, rev) 60 61 62 def get_changesets(self, start, stop): 63 #print "get_changesets", start, stop 64 for rev in self.git.history_all(start, stop): 65 yield self.get_changeset(rev) 66 61 67 def get_changeset(self, rev): 62 68 #print "get_changeset", rev … … 74 80 if mode2[0] == '1' or mode2[0] == '1': 75 81 kind = Node.DIRECTORY 76 82 77 83 if action == 'A': 78 84 change = Changeset.ADD … … 107 113 108 114 def rev_older_than(self, rev1, rev2): 109 rc = rev1 in self.git.history(rev2, '', 1)110 # print "rev_older_than", (rev1, rev2, rc)115 rc = self.git.rev_is_anchestor(rev1,rev2) 116 #rc = rev1 in self.git.history(rev2, '', skip=1) 111 117 return rc 112 118 … … 122 128 self.perm = None 123 129 self.data_len = None 124 130 125 131 kind = Node.DIRECTORY 126 132 p = path.strip('/') … … 146 152 else: 147 153 self.log.debug("kind is "+k) 148 154 149 155 Node.__init__(self, path, rev, kind) 150 156 … … 156 162 if self.isfile: 157 163 return self.git.get_file(self.sha) 158 164 159 165 return None 160 166 … … 169 175 if not self.isdir: 170 176 return 171 177 172 178 p = self.path.strip('/') 173 179 if p != '': p = p + '/' 174 180 for e in self.git.tree_ls(self.rev, p): 175 181 yield GitNode(self.git, e[3], self.rev, e) 176 182 177 183 def get_content_type(self): 178 184 if self.isdir: … … 188 194 189 195 def get_history(self, limit=None): 196 #print "get_history", limit, self.path 190 197 p = self.path.strip('/') 191 for rev in self.git.history(self.rev, p ):198 for rev in self.git.history(self.rev, p, limit): 192 199 yield (self.path, rev, Changeset.EDIT) 193 200 … … 198 205 def __init__(self, git, sha): 199 206 self.git = git 200 (msg,props) = git.read_commit(sha) 207 try: 208 (msg,props) = git.read_commit(sha) 209 except PyGIT.GitErrorSha: 210 raise NoSuchChangeset(sha) 201 211 self.props = props 202 212 203 213 committer = props['committer'][0] 204 214 (user,time,tz) = committer.rsplit(None, 2) 205 215 206 216 Changeset.__init__(self, sha, msg, user, float(time)) 207 217 … … 223 233 if mode1[0:1] == '04' or mode2[0:1] == '04': 224 234 kind = Node.DIRECTORY 225 235 226 236 if action == 'A': 227 237 change = Changeset.ADD gitplugin/0.10/gitplugin/PyGIT.py
r1536 r3174 1 1 # -*- coding: iso-8859-1 -*- 2 2 # 3 # Copyright (C) 2006 Herbert Valerio Riedel <hvr@gnu.org>3 # Copyright (C) 2006,2008 Herbert Valerio Riedel <hvr@gnu.org> 4 4 # 5 5 # This program is free software; you can redistribute it and/or … … 17 17 18 18 class GitError(Exception): 19 pass 20 21 class GitErrorSha(GitError): 19 22 pass 20 23 … … 75 78 lines = raw.splitlines() 76 79 80 if not lines: 81 raise GitErrorSha 82 77 83 line = lines.pop(0) 78 84 d = {} … … 104 110 if sha in revs[1:]: 105 111 yield revs[0] 106 107 def history(self, sha, path, skip=0): 108 for rev in self._git_call_f("git-rev-list %s -- '%s'" % (sha,path)).readlines(): 112 113 def history(self, sha, path, limit=None, skip=0): 114 #print "history", sha, path, limit, skip 115 if limit is None: 116 limit = -1 117 for rev in self._git_call_f("git-rev-list -n%d %s -- '%s'" % (limit,sha,path)).readlines(): 109 118 if(skip > 0): 110 119 skip = skip - 1 111 120 continue 112 121 yield rev.strip() 122 123 def history_all(self, start, stop): 124 for rev in self._git_call_f("git-rev-list --reverse --max-age=%d --min-age=%d --all" \ 125 % (start,stop)).readlines(): 126 yield rev.strip() 127 128 def rev_is_anchestor(self, rev1, rev2): 129 rev1 = rev1.strip() 130 rev2 = rev2.strip() 131 for rev in self._git_call_f("git-rev-list %s ^%s^" % (rev2,rev1)).readlines(): 132 if rev1 == rev.strip(): 133 return True 134 return False 113 135 114 136 def last_change(self, sha, path): … … 130 152 if __name__ == '__main__': 131 153 import sys 132 154 133 155 g = Storage(sys.argv[1]) 134 156 135 157 print "[%s]" % g.head() 136 158 print g.tree_ls(g.head())
