##// 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 68 def branch(self):
69 69 # TODO: Cache as we walk (id <-> branch name mapping)
70 70 refs = self.repository._repo.get_refs()
71 heads = [(key[len('refs/heads/'):], val) for key, val in refs.items()
72 if key.startswith('refs/heads/')]
71 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 80 walker = self.repository._repo.object_store.get_graph_walker([id])
76 81 while True:
77 id = walker.next()
78 if not id:
82 id_ = walker.next()
83 if not id_:
79 84 break
80 if id == self.id:
85 if id_ == self.id:
81 86 return safe_unicode(name)
82 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 90 def _fix_path(self, path):
86 91 """
@@ -92,6 +97,7 b' class GitChangeset(BaseChangeset):'
92 97 return path
93 98
94 99 def _get_id_for_path(self, path):
100
95 101 # FIXME: Please, spare a couple of minutes and make those codes cleaner;
96 102 if not path in self._paths:
97 103 path = path.strip('/')
@@ -103,24 +109,23 b' class GitChangeset(BaseChangeset):'
103 109 splitted = path.split('/')
104 110 dirs, name = splitted[:-1], splitted[-1]
105 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 122 for dir in dirs:
107 123 if curdir:
108 124 curdir = '/'.join((curdir, dir))
109 125 else:
110 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 127 dir_id = None
117 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 129 if dir == item:
125 130 dir_id = id
126 131 if dir_id:
@@ -130,13 +135,16 b' class GitChangeset(BaseChangeset):'
130 135 raise ChangesetError('%s is not a directory' % curdir)
131 136 else:
132 137 raise ChangesetError('%s have not been found' % curdir)
133 for item, stat, id in tree.iteritems():
134 if curdir:
135 name = '/'.join((curdir, item))
136 else:
137 name = item
138 self._paths[name] = id
139 self._stat_modes[name] = stat
138
139 # cache all items from the given traversed tree
140 for item, stat, id in tree.iteritems():
141 if curdir:
142 name = '/'.join((curdir, item))
143 else:
144 name = item
145 self._paths[name] = id
146 self._stat_modes[name] = stat
147
140 148 if not path in self._paths:
141 149 raise NodeDoesNotExistError("There is no file nor directory "
142 150 "at the given path %r at revision %r"
General Comments 0
You need to be logged in to leave comments. Login now