Changeset 3213
- Timestamp:
- 02/11/08 05:23:48 (10 months ago)
- Files:
-
- gitplugin/0.11/tracext/git/git_fs.py (modified) (7 diffs)
- gitplugin/0.11/tracext/git/PyGIT.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gitplugin/0.11/tracext/git/git_fs.py
r3212 r3213 202 202 203 203 def get_changesets(self, start, stop): 204 #print "get_changesets", start, stop205 204 for rev in self.git.history_timerange(to_timestamp(start), to_timestamp(stop)): 206 205 yield self.get_changeset(rev) … … 211 210 212 211 def get_changes(self, old_path, old_rev, new_path, new_rev): 212 # TODO: handle renames/copies 213 213 if old_path != new_path: 214 214 raise TracError("not supported in git_fs") 215 #print "get_changes", (old_path, old_rev, new_path, new_rev)216 215 217 216 for chg in self.git.diff_tree(old_rev, new_rev, self.normalize_path(new_path)): … … 344 343 345 344 def get_history(self, limit=None): 345 # TODO: find a way to follow renames/copies 346 346 for is_last,rev in _last_iterable(self.git.history(self.rev, self.__git_path(), limit)): 347 347 yield (self.path, rev, Changeset.EDIT if not is_last else Changeset.ADD) … … 365 365 'A': Changeset.ADD, 366 366 'M': Changeset.EDIT, 367 'D': Changeset.DELETE 367 'D': Changeset.DELETE, 368 'R': Changeset.MOVE, 369 'C': Changeset.COPY 368 370 } 369 371 … … 403 405 404 406 def get_changes(self): 405 # TODO: handle renames/removals407 paths_seen = set() 406 408 for parent in self.props.get('parent', [None]): 407 for mode1,mode2,obj1,obj2,action,path,path2 in \ 408 self.git.diff_tree(parent, self.rev): 409 p_path, p_rev = path, parent 409 for mode1,mode2,obj1,obj2,action,path1,path2 in \ 410 self.git.diff_tree(parent, self.rev, find_renames=True): 411 path = path2 or path1 412 p_path, p_rev = path1, parent 410 413 411 414 kind = Node.FILE … … 413 416 kind = Node.DIRECTORY 414 417 415 action = GitChangeset.action_map[action ]418 action = GitChangeset.action_map[action[0]] 416 419 417 420 if action == Changeset.ADD: … … 419 422 p_rev = None 420 423 424 # CachedRepository expects unique (rev, path, change_type) key 425 # this is only an issue in case of merges where files required editing 426 if path in paths_seen: 427 continue 428 429 paths_seen.add(path) 430 421 431 yield (path, kind, action, p_path, p_rev) gitplugin/0.11/tracext/git/PyGIT.py
r3212 r3213 303 303 304 304 line = lines.pop(0) 305 d = {} 306 while line != "": 307 (key,value)=line.split(None, 1) 308 if not d.has_key(key): 309 d[key] = [] 310 d[key].append(value.strip()) 305 props = {} 306 while line: 307 (key,value) = line.split(None, 1) 308 props.setdefault(key,[]).append(value.strip()) 311 309 line = lines.pop(0) 312 310 313 return ("\n".join(lines), d)311 return ("\n".join(lines), props) 314 312 315 313 def get_file(self, sha): … … 409 407 return last_rev.strip() 410 408 411 def diff_tree(self, tree1, tree2, path="" ):409 def diff_tree(self, tree1, tree2, path="", find_renames=False): 412 410 """calls `git diff-tree` and returns tuples of the kind 413 (mode1,mode2,obj1,obj2,action,path ,path2)"""411 (mode1,mode2,obj1,obj2,action,path1,path2)""" 414 412 415 413 # diff-tree returns records with the following structure: 416 # :<old-mode> <new-mode> <old-sha> <new-sha> <change> NUL <path> NUL [ <src-path> NUL ] 417 418 lines = self._git_call("diff-tree", 419 ["-z", "-r", 420 str(tree1) if tree1 else "--root", 421 str(tree2), 422 "--", path]).split('\0') 414 # :<old-mode> <new-mode> <old-sha> <new-sha> <change> NUL <old-path> NUL [ <new-path> NUL ] 415 416 diff_tree_args = ["-z", "-r"] 417 if find_renames: 418 diff_tree_args.append("-M") 419 diff_tree_args.extend([str(tree1) if tree1 else "--root", 420 str(tree2), 421 "--", path]) 422 423 lines = self._git_call("diff-tree", diff_tree_args).split('\0') 423 424 424 425 assert lines[-1] == ""
