OLD | NEW |
---|---|
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import atexit | 5 import atexit |
6 import collections | 6 import collections |
7 import datetime | 7 import datetime |
8 import os | 8 import os |
9 import pytz | |
10 import shutil | 9 import shutil |
11 import subprocess | 10 import subprocess |
12 import sys | 11 import sys |
13 import tempfile | 12 import tempfile |
14 | 13 |
15 | 14 |
16 from testing_support.git.schema import GitRepoSchema | 15 from testing_support.git.schema import GitRepoSchema |
17 | 16 |
18 | 17 |
19 class GitRepo(object): | 18 class GitRepo(object): |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 """Makes new GitRepo. | 60 """Makes new GitRepo. |
62 | 61 |
63 Automatically creates a temp folder under GitRepo.BASE_TEMP_DIR. It's | 62 Automatically creates a temp folder under GitRepo.BASE_TEMP_DIR. It's |
64 recommended that you clean this repo up by calling nuke() on it, but if not, | 63 recommended that you clean this repo up by calling nuke() on it, but if not, |
65 GitRepo will automatically clean up all allocated repos at the exit of the | 64 GitRepo will automatically clean up all allocated repos at the exit of the |
66 program (assuming a normal exit like with sys.exit) | 65 program (assuming a normal exit like with sys.exit) |
67 | 66 |
68 Args: | 67 Args: |
69 schema - An instance of GitRepoSchema | 68 schema - An instance of GitRepoSchema |
70 """ | 69 """ |
70 class UTC(datetime.tzinfo): | |
71 def utcoffset(self, dt): return datetime.timedelta(0) | |
agable
2014/09/03 16:20:41
Despite being an inner class, please follow style.
Sergiy Byelozyorov
2014/09/03 16:22:33
Done.
| |
72 def dst(self, dt): return datetime.timedelta(0) | |
agable
2014/09/03 16:20:41
The dst and tzname functions aren't strictly neces
Sergiy Byelozyorov
2014/09/03 16:22:33
Done.
| |
73 def tzname(self, dt): return 'UTC' | |
74 | |
71 self.repo_path = tempfile.mkdtemp(dir=self.BASE_TEMP_DIR) | 75 self.repo_path = tempfile.mkdtemp(dir=self.BASE_TEMP_DIR) |
72 self.commit_map = {} | 76 self.commit_map = {} |
73 self._date = datetime.datetime(1970, 1, 1, tzinfo=pytz.utc) | 77 self._date = datetime.datetime(1970, 1, 1, tzinfo=UTC()) |
74 | 78 |
75 self.to_schema_refs = ['--branches'] | 79 self.to_schema_refs = ['--branches'] |
76 | 80 |
77 self.git('init') | 81 self.git('init') |
78 self.git('config', 'user.name', 'testcase') | 82 self.git('config', 'user.name', 'testcase') |
79 self.git('config', 'user.email', 'testcase@example.com') | 83 self.git('config', 'user.email', 'testcase@example.com') |
80 for commit in schema.walk(): | 84 for commit in schema.walk(): |
81 self._add_schema_commit(commit, schema.data_for(commit.name)) | 85 self._add_schema_commit(commit, schema.data_for(commit.name)) |
82 self.last_commit = self[commit.name] | 86 self.last_commit = self[commit.name] |
83 if schema.master: | 87 if schema.master: |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
230 else: | 234 else: |
231 assert current is not None | 235 assert current is not None |
232 hash_to_msg[current] = line | 236 hash_to_msg[current] = line |
233 ret.add_partial(line) | 237 ret.add_partial(line) |
234 for parent in parents: | 238 for parent in parents: |
235 ret.add_partial(line, hash_to_msg[parent]) | 239 ret.add_partial(line, hash_to_msg[parent]) |
236 current = None | 240 current = None |
237 parents = [] | 241 parents = [] |
238 assert current is None | 242 assert current is None |
239 return ret | 243 return ret |
OLD | NEW |