##// END OF EJS Templates
temporarly fixed git _get_id_for_path problem in vcs....
marcink -
r2116:04881156 beta
parent child Browse files
Show More
@@ -68,19 +68,24 b' class GitChangeset(BaseChangeset):'
68 def branch(self):
68 def branch(self):
69 # TODO: Cache as we walk (id <-> branch name mapping)
69 # TODO: Cache as we walk (id <-> branch name mapping)
70 refs = self.repository._repo.get_refs()
70 refs = self.repository._repo.get_refs()
71 heads = [(key[len('refs/heads/'):], val) for key, val in refs.items()
71 heads = {}
72 if key.startswith('refs/heads/')]
72 for key, val in refs.items():
73 for ref_key in ['refs/heads/', 'refs/remotes/origin/']:
74 if key.startswith(ref_key):
75 n = key[len(ref_key):]
76 if n not in ['HEAD']:
77 heads[n] = val
73
78
74 for name, id in heads:
79 for name, id in heads.iteritems():
75 walker = self.repository._repo.object_store.get_graph_walker([id])
80 walker = self.repository._repo.object_store.get_graph_walker([id])
76 while True:
81 while True:
77 id = walker.next()
82 id_ = walker.next()
78 if not id:
83 if not id_:
79 break
84 break
80 if id == self.id:
85 if id_ == self.id:
81 return safe_unicode(name)
86 return safe_unicode(name)
82 raise ChangesetError("This should not happen... Have you manually "
87 raise ChangesetError("This should not happen... Have you manually "
83 "change id of the changeset?")
88 "change id of the changeset?")
84
89
85 def _fix_path(self, path):
90 def _fix_path(self, path):
86 """
91 """
@@ -92,6 +97,7 b' class GitChangeset(BaseChangeset):'
92 return path
97 return path
93
98
94 def _get_id_for_path(self, path):
99 def _get_id_for_path(self, path):
100
95 # FIXME: Please, spare a couple of minutes and make those codes cleaner;
101 # FIXME: Please, spare a couple of minutes and make those codes cleaner;
96 if not path in self._paths:
102 if not path in self._paths:
97 path = path.strip('/')
103 path = path.strip('/')
@@ -103,24 +109,23 b' class GitChangeset(BaseChangeset):'
103 splitted = path.split('/')
109 splitted = path.split('/')
104 dirs, name = splitted[:-1], splitted[-1]
110 dirs, name = splitted[:-1], splitted[-1]
105 curdir = ''
111 curdir = ''
112
113 # initially extract things from root dir
114 for item, stat, id in tree.iteritems():
115 if curdir:
116 name = '/'.join((curdir, item))
117 else:
118 name = item
119 self._paths[name] = id
120 self._stat_modes[name] = stat
121
106 for dir in dirs:
122 for dir in dirs:
107 if curdir:
123 if curdir:
108 curdir = '/'.join((curdir, dir))
124 curdir = '/'.join((curdir, dir))
109 else:
125 else:
110 curdir = dir
126 curdir = dir
111 #if curdir in self._paths:
112 ## This path have been already traversed
113 ## Update tree and continue
114 #tree = self.repository._repo[self._paths[curdir]]
115 #continue
116 dir_id = None
127 dir_id = None
117 for item, stat, id in tree.iteritems():
128 for item, stat, id in tree.iteritems():
118 if curdir:
119 item_path = '/'.join((curdir, item))
120 else:
121 item_path = item
122 self._paths[item_path] = id
123 self._stat_modes[item_path] = stat
124 if dir == item:
129 if dir == item:
125 dir_id = id
130 dir_id = id
126 if dir_id:
131 if dir_id:
@@ -130,13 +135,16 b' class GitChangeset(BaseChangeset):'
130 raise ChangesetError('%s is not a directory' % curdir)
135 raise ChangesetError('%s is not a directory' % curdir)
131 else:
136 else:
132 raise ChangesetError('%s have not been found' % curdir)
137 raise ChangesetError('%s have not been found' % curdir)
133 for item, stat, id in tree.iteritems():
138
134 if curdir:
139 # cache all items from the given traversed tree
135 name = '/'.join((curdir, item))
140 for item, stat, id in tree.iteritems():
136 else:
141 if curdir:
137 name = item
142 name = '/'.join((curdir, item))
138 self._paths[name] = id
143 else:
139 self._stat_modes[name] = stat
144 name = item
145 self._paths[name] = id
146 self._stat_modes[name] = stat
147
140 if not path in self._paths:
148 if not path in self._paths:
141 raise NodeDoesNotExistError("There is no file nor directory "
149 raise NodeDoesNotExistError("There is no file nor directory "
142 "at the given path %r at revision %r"
150 "at the given path %r at revision %r"
General Comments 0
You need to be logged in to leave comments. Login now