| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -55,6 +55,10 @@ Repo | |||
| 55 | 55 | - 'commit_count' as it was just a redirection to the respective commit method | |
| 56 | 56 | - 'commits_between', replaced by a note on the iter_commits method as it can | |
| 57 | 57 | achieve the same thing | |
| 58 | + - 'commit_delta_from' as it was a very special case by comparing two different | ||
| 59 | + repositories which are likely to have completly different commits. For | ||
| 60 | + related repositories, i.e. clones, git-rev-list would be sufficient to find | ||
| 61 | + commits that would need to be transferred for example. | ||
| 58 | 62 | * Renamed commits to iter_commits to improve the performance, adjusted signature | |
| 59 | 63 | to be more versatile | |
| 60 | 64 | * 'commits' method has no max-count of returned commits anymore, it now behaves | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -101,30 +101,8 @@ def summary(self): | |||
| 101 | 101 | """ | |
| 102 | 102 | return self.message.split('\n', 1)[0] | |
| 103 | 103 | ||
| 104 | - def iter_parents(self, paths='', **kwargs): | ||
| 105 | - """ | ||
| 106 | - Iterate _all_ parents of this commit. | ||
| 107 | - | ||
| 108 | - ``paths`` | ||
| 109 | - Optional path or list of paths limiting the Commits to those that | ||
| 110 | - contain at least one of the paths | ||
| 111 | - | ||
| 112 | - ``kwargs`` | ||
| 113 | - All arguments allowed by git-rev-list | ||
| 114 | - | ||
| 115 | - Return: | ||
| 116 | - Iterator yielding Commit objects which are parents of self | ||
| 117 | - """ | ||
| 118 | - # skip ourselves | ||
| 119 | - skip = kwargs.get("skip", 1) | ||
| 120 | - if skip == 0: # skip ourselves | ||
| 121 | - skip = 1 | ||
| 122 | - kwargs['skip'] = skip | ||
| 123 | - | ||
| 124 | - return self.iter_items( self.repo, self, paths, **kwargs ) | ||
| 125 | - | ||
| 126 | 104 | @classmethod | |
| 127 | - def count(cls, repo, rev, paths=''): | ||
| 105 | + def count(cls, repo, rev, paths='', **kwargs): | ||
| 128 | 106 | """ | |
| 129 | 107 | Count the number of commits reachable from this revision | |
| 130 | 108 | ||
@@ -138,10 +116,12 @@ def count(cls, repo, rev, paths=''): | |||
| 138 | 116 | is an optinal path or a list of paths restricting the return value | |
| 139 | 117 | to commits actually containing the paths | |
| 140 | 118 | ||
| 119 | + ``kwargs`` | ||
| 120 | + Additional options to be passed to git-rev-list | ||
| 141 | 121 | Returns | |
| 142 | 122 | int | |
| 143 | 123 | """ | |
| 144 | - return len(repo.git.rev_list(rev, '--', paths).strip().splitlines()) | ||
| 124 | + return len(repo.git.rev_list(rev, '--', paths, **kwargs).strip().splitlines()) | ||
| 145 | 125 | ||
| 146 | 126 | @classmethod | |
| 147 | 127 | def iter_items(cls, repo, rev, paths='', **kwargs): | |
@@ -173,59 +153,28 @@ def iter_items(cls, repo, rev, paths='', **kwargs): | |||
| 173 | 153 | # the test system might confront us with string values - | |
| 174 | 154 | proc = repo.git.rev_list(rev, '--', paths, **options) | |
| 175 | 155 | return cls._iter_from_process_or_stream(repo, proc) | |
| 176 | - | ||
| 177 | - @classmethod | ||
| 178 | - def _iter_from_process_or_stream(cls, repo, proc_or_stream): | ||
| 179 | - """ | ||
| 180 | - Parse out commit information into a list of Commit objects | ||
| 181 | - | ||
| 182 | - ``repo`` | ||
| 183 | - is the Repo | ||
| 184 | - | ||
| 185 | - ``proc`` | ||
| 186 | - git-rev-list process instance (raw format) | ||
| 187 | - | ||
| 188 | - Returns | ||
| 189 | - iterator returning Commit objects | ||
| 156 | + | ||
| 157 | + def iter_parents(self, paths='', **kwargs): | ||
| 190 | 158 | """ | |
| 191 | - stream = proc_or_stream | ||
| 192 | - if not hasattr(stream,'next'): | ||
| 193 | - stream = proc_or_stream.stdout | ||
| 194 | - | ||
| 195 | - for line in stream: | ||
| 196 | - id = line.split()[1] | ||
| 197 | - assert line.split()[0] == "commit" | ||
| 198 | - tree = stream.next().split()[1] | ||
| 199 | - | ||
| 200 | - parents = [] | ||
| 201 | - next_line = None | ||
| 202 | - for parent_line in stream: | ||
| 203 | - if not parent_line.startswith('parent'): | ||
| 204 | - next_line = parent_line | ||
| 205 | - break | ||
| 206 | - # END abort reading parents | ||
| 207 | - parents.append(parent_line.split()[-1]) | ||
| 208 | - # END for each parent line | ||
| 209 | - | ||
| 210 | - author, authored_date = utils.parse_actor_and_date(next_line) | ||
| 211 | - committer, committed_date = utils.parse_actor_and_date(stream.next()) | ||
| 212 | - | ||
| 213 | - # empty line | ||
| 214 | - stream.next() | ||
| 215 | - | ||
| 216 | - message_lines = [] | ||
| 217 | - next_line = None | ||
| 218 | - for msg_line in stream: | ||
| 219 | - if not msg_line.startswith(' '): | ||
| 220 | - break | ||
| 221 | - # END abort message reading | ||
| 222 | - message_lines.append(msg_line.strip()) | ||
| 223 | - # END while there are message lines | ||
| 224 | - message = '\n'.join(message_lines) | ||
| 159 | + Iterate _all_ parents of this commit. | ||
| 160 | + | ||
| 161 | + ``paths`` | ||
| 162 | + Optional path or list of paths limiting the Commits to those that | ||
| 163 | + contain at least one of the paths | ||
| 164 | + | ||
| 165 | + ``kwargs`` | ||
| 166 | + All arguments allowed by git-rev-list | ||
| 225 | 167 | ||
| 226 | - yield Commit(repo, id=id, parents=tuple(parents), tree=tree, author=author, authored_date=authored_date, | ||
| 227 | - committer=committer, committed_date=committed_date, message=message) | ||
| 228 | - # END for each line in stream | ||
| 168 | + Return: | ||
| 169 | + Iterator yielding Commit objects which are parents of self | ||
| 170 | + """ | ||
| 171 | + # skip ourselves | ||
| 172 | + skip = kwargs.get("skip", 1) | ||
| 173 | + if skip == 0: # skip ourselves | ||
| 174 | + skip = 1 | ||
| 175 | + kwargs['skip'] = skip | ||
| 176 | + | ||
| 177 | + return self.iter_items( self.repo, self, paths, **kwargs ) | ||
| 229 | 178 | ||
| 230 | 179 | @classmethod | |
| 231 | 180 | def diff(cls, repo, a, b=None, paths=None): | |
@@ -301,6 +250,60 @@ def stats(self): | |||
| 301 | 250 | text = self.repo.git.diff(self.parents[0].id, self.id, '--', numstat=True) | |
| 302 | 251 | return stats.Stats._list_from_string(self.repo, text) | |
| 303 | 252 | ||
| 253 | + @classmethod | ||
| 254 | + def _iter_from_process_or_stream(cls, repo, proc_or_stream): | ||
| 255 | + """ | ||
| 256 | + Parse out commit information into a list of Commit objects | ||
| 257 | + | ||
| 258 | + ``repo`` | ||
| 259 | + is the Repo | ||
| 260 | + | ||
| 261 | + ``proc`` | ||
| 262 | + git-rev-list process instance (raw format) | ||
| 263 | + | ||
| 264 | + Returns | ||
| 265 | + iterator returning Commit objects | ||
| 266 | + """ | ||
| 267 | + stream = proc_or_stream | ||
| 268 | + if not hasattr(stream,'next'): | ||
| 269 | + stream = proc_or_stream.stdout | ||
| 270 | + | ||
| 271 | + for line in stream: | ||
| 272 | + id = line.split()[1] | ||
| 273 | + assert line.split()[0] == "commit" | ||
| 274 | + tree = stream.next().split()[1] | ||
| 275 | + | ||
| 276 | + parents = [] | ||
| 277 | + next_line = None | ||
| 278 | + for parent_line in stream: | ||
| 279 | + if not parent_line.startswith('parent'): | ||
| 280 | + next_line = parent_line | ||
| 281 | + break | ||
| 282 | + # END abort reading parents | ||
| 283 | + parents.append(parent_line.split()[-1]) | ||
| 284 | + # END for each parent line | ||
| 285 | + | ||
| 286 | + author, authored_date = utils.parse_actor_and_date(next_line) | ||
| 287 | + committer, committed_date = utils.parse_actor_and_date(stream.next()) | ||
| 288 | + | ||
| 289 | + # empty line | ||
| 290 | + stream.next() | ||
| 291 | + | ||
| 292 | + message_lines = [] | ||
| 293 | + next_line = None | ||
| 294 | + for msg_line in stream: | ||
| 295 | + if not msg_line.startswith(' '): | ||
| 296 | + break | ||
| 297 | + # END abort message reading | ||
| 298 | + message_lines.append(msg_line.strip()) | ||
| 299 | + # END while there are message lines | ||
| 300 | + message = '\n'.join(message_lines) | ||
| 301 | + | ||
| 302 | + yield Commit(repo, id=id, parents=tuple(parents), tree=tree, author=author, authored_date=authored_date, | ||
| 303 | + committer=committer, committed_date=committed_date, message=message) | ||
| 304 | + # END for each line in stream | ||
| 305 | + | ||
| 306 | + | ||
| 304 | 307 | def __str__(self): | |
| 305 | 308 | """ Convert commit to string which is SHA1 """ | |
| 306 | 309 | return self.id | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -202,20 +202,6 @@ def iter_commits(self, rev=None, paths='', **kwargs): | |||
| 202 | 202 | ||
| 203 | 203 | return Commit.iter_items(self, rev, paths, **kwargs) | |
| 204 | 204 | ||
| 205 | - def commit_deltas_from(self, other_repo, ref='master', other_ref='master'): | ||
| 206 | - """ | ||
| 207 | - Returns a list of commits that is in ``other_repo`` but not in self | ||
| 208 | - | ||
| 209 | - Returns | ||
| 210 | - git.Commit[] | ||
| 211 | - """ | ||
| 212 | - repo_refs = self.git.rev_list(ref, '--').strip().splitlines() | ||
| 213 | - other_repo_refs = other_repo.git.rev_list(other_ref, '--').strip().splitlines() | ||
| 214 | - | ||
| 215 | - diff_refs = list(set(other_repo_refs) - set(repo_refs)) | ||
| 216 | - return map(lambda ref: Commit(other_repo, ref ), diff_refs) | ||
| 217 | - | ||
| 218 | - | ||
| 219 | 205 | def _get_daemon_export(self): | |
| 220 | 206 | filename = os.path.join(self.path, self.DAEMON_EXPORT_FILE) | |
| 221 | 207 | return os.path.exists(filename) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments