diff options
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 30 |
1 files changed, 4 insertions, 26 deletions
@@ -28,11 +28,7 @@ from error import GitError, ImportError, UploadError | |||
28 | from error import ManifestInvalidRevisionError | 28 | from error import ManifestInvalidRevisionError |
29 | from remote import Remote | 29 | from remote import Remote |
30 | 30 | ||
31 | HEAD = 'HEAD' | 31 | from git_refs import GitRefs, HEAD, R_HEADS, R_TAGS, R_PUB, R_M |
32 | R_HEADS = 'refs/heads/' | ||
33 | R_TAGS = 'refs/tags/' | ||
34 | R_PUB = 'refs/published/' | ||
35 | R_M = 'refs/remotes/m/' | ||
36 | 32 | ||
37 | def _error(fmt, *args): | 33 | def _error(fmt, *args): |
38 | msg = fmt % args | 34 | msg = fmt % args |
@@ -226,6 +222,7 @@ class Project(object): | |||
226 | else: | 222 | else: |
227 | self.work_git = None | 223 | self.work_git = None |
228 | self.bare_git = self._GitGetByExec(self, bare=True) | 224 | self.bare_git = self._GitGetByExec(self, bare=True) |
225 | self.bare_ref = GitRefs(gitdir) | ||
229 | 226 | ||
230 | @property | 227 | @property |
231 | def Exists(self): | 228 | def Exists(self): |
@@ -301,7 +298,7 @@ class Project(object): | |||
301 | """Get all existing local branches. | 298 | """Get all existing local branches. |
302 | """ | 299 | """ |
303 | current = self.CurrentBranch | 300 | current = self.CurrentBranch |
304 | all = self.bare_git.ListRefs() | 301 | all = self._allrefs |
305 | heads = {} | 302 | heads = {} |
306 | pubd = {} | 303 | pubd = {} |
307 | 304 | ||
@@ -1030,32 +1027,13 @@ class Project(object): | |||
1030 | 1027 | ||
1031 | @property | 1028 | @property |
1032 | def _allrefs(self): | 1029 | def _allrefs(self): |
1033 | return self.bare_git.ListRefs() | 1030 | return self.bare_ref.all |
1034 | 1031 | ||
1035 | class _GitGetByExec(object): | 1032 | class _GitGetByExec(object): |
1036 | def __init__(self, project, bare): | 1033 | def __init__(self, project, bare): |
1037 | self._project = project | 1034 | self._project = project |
1038 | self._bare = bare | 1035 | self._bare = bare |
1039 | 1036 | ||
1040 | def ListRefs(self, *args): | ||
1041 | cmdv = ['for-each-ref', '--format=%(objectname) %(refname)'] | ||
1042 | cmdv.extend(args) | ||
1043 | p = GitCommand(self._project, | ||
1044 | cmdv, | ||
1045 | bare = self._bare, | ||
1046 | capture_stdout = True, | ||
1047 | capture_stderr = True) | ||
1048 | r = {} | ||
1049 | for line in p.process.stdout: | ||
1050 | id, name = line[:-1].split(' ', 2) | ||
1051 | r[name] = id | ||
1052 | if p.Wait() != 0: | ||
1053 | raise GitError('%s for-each-ref %s: %s' % ( | ||
1054 | self._project.name, | ||
1055 | str(args), | ||
1056 | p.stderr)) | ||
1057 | return r | ||
1058 | |||
1059 | def LsOthers(self): | 1037 | def LsOthers(self): |
1060 | p = GitCommand(self._project, | 1038 | p = GitCommand(self._project, |
1061 | ['ls-files', | 1039 | ['ls-files', |