Show More
@@ -452,11 +452,22 b' class GitRemote(RemoteBase):' | |||
|
452 | 452 | # TODO: this is quite complex, check if that can be simplified |
|
453 | 453 | @reraise_safe_exceptions |
|
454 | 454 | def commit(self, wire, commit_data, branch, commit_tree, updated, removed): |
|
455 | # Defines the root tree | |
|
456 | class _Root(object): | |
|
457 | def __repr__(self): | |
|
458 | return 'ROOT TREE' | |
|
459 | ROOT = _Root() | |
|
460 | ||
|
455 | 461 | repo = self._factory.repo(wire) |
|
456 | 462 | object_store = repo.object_store |
|
457 | 463 | |
|
458 | 464 | # Create tree and populates it with blobs |
|
459 | commit_tree = commit_tree and repo[commit_tree] or objects.Tree() | |
|
465 | ||
|
466 | if commit_tree and repo[commit_tree]: | |
|
467 | git_commit = repo[commit_data['parents'][0]] | |
|
468 | commit_tree = repo[git_commit.tree] # root tree | |
|
469 | else: | |
|
470 | commit_tree = objects.Tree() | |
|
460 | 471 | |
|
461 | 472 | for node in updated: |
|
462 | 473 | # Compute subdirs if needed |
@@ -515,21 +526,34 b' class GitRemote(RemoteBase):' | |||
|
515 | 526 | |
|
516 | 527 | for node_path in removed: |
|
517 | 528 | paths = node_path.split('/') |
|
518 | tree = commit_tree | |
|
519 | trees = [tree] | |
|
529 | tree = commit_tree # start with top-level | |
|
530 | trees = [{'tree': tree, 'path': ROOT}] | |
|
520 | 531 | # Traverse deep into the forest... |
|
532 | # resolve final tree by iterating the path. | |
|
533 | # e.g a/b/c.txt will get | |
|
534 | # - root as tree then | |
|
535 | # - 'a' as tree, | |
|
536 | # - 'b' as tree, | |
|
537 | # - stop at c as blob. | |
|
521 | 538 | for path in paths: |
|
522 | 539 | try: |
|
523 | 540 | obj = repo[tree[path][1]] |
|
524 | 541 | if isinstance(obj, objects.Tree): |
|
525 | trees.append(obj) | |
|
542 | trees.append({'tree': obj, 'path': path}) | |
|
526 | 543 | tree = obj |
|
527 | 544 | except KeyError: |
|
528 | 545 | break |
|
546 | #PROBLEM: | |
|
547 | """ | |
|
548 | We're not editing same reference tree object | |
|
549 | """ | |
|
529 | 550 | # Cut down the blob and all rotten trees on the way back... |
|
530 | for path, tree in reversed(zip(paths, trees)): | |
|
531 |
|
|
|
532 |
|
|
|
551 | for path, tree_data in reversed(zip(paths, trees)): | |
|
552 | tree = tree_data['tree'] | |
|
553 | tree.__delitem__(path) | |
|
554 | # This operation edits the tree, we need to mark new commit back | |
|
555 | ||
|
556 | if len(tree) > 0: | |
|
533 | 557 | # This tree still has elements - don't remove it or any |
|
534 | 558 | # of it's parents |
|
535 | 559 | break |
@@ -539,7 +563,7 b' class GitRemote(RemoteBase):' | |||
|
539 | 563 | # Create commit |
|
540 | 564 | commit = objects.Commit() |
|
541 | 565 | commit.tree = commit_tree.id |
|
542 |
for k, v in commit_data. |
|
|
566 | for k, v in commit_data.items(): | |
|
543 | 567 | setattr(commit, k, v) |
|
544 | 568 | object_store.add_object(commit) |
|
545 | 569 | |
@@ -1203,13 +1227,6 b' class GitRemote(RemoteBase):' | |||
|
1203 | 1227 | return install_git_hooks(path, bare, force_create=force) |
|
1204 | 1228 | |
|
1205 | 1229 | @reraise_safe_exceptions |
|
1206 | def set_head_ref(self, wire, head_name): | |
|
1207 | log.debug('Setting refs/head to `%s`', head_name) | |
|
1208 | cmd = ['symbolic-ref', 'HEAD', 'refs/heads/%s' % head_name] | |
|
1209 | output, __ = self.run_git_command(wire, cmd) | |
|
1210 | return [head_name] + output.splitlines() | |
|
1211 | ||
|
1212 | @reraise_safe_exceptions | |
|
1213 | 1230 | def get_hooks_info(self, wire): |
|
1214 | 1231 | from vcsserver.hook_utils import ( |
|
1215 | 1232 | get_git_pre_hook_version, get_git_post_hook_version) |
@@ -1221,6 +1238,13 b' class GitRemote(RemoteBase):' | |||
|
1221 | 1238 | } |
|
1222 | 1239 | |
|
1223 | 1240 | @reraise_safe_exceptions |
|
1241 | def set_head_ref(self, wire, head_name): | |
|
1242 | log.debug('Setting refs/head to `%s`', head_name) | |
|
1243 | cmd = ['symbolic-ref', 'HEAD', 'refs/heads/%s' % head_name] | |
|
1244 | output, __ = self.run_git_command(wire, cmd) | |
|
1245 | return [head_name] + output.splitlines() | |
|
1246 | ||
|
1247 | @reraise_safe_exceptions | |
|
1224 | 1248 | def archive_repo(self, wire, archive_dest_path, kind, mtime, archive_at_path, |
|
1225 | 1249 | archive_dir_name, commit_id): |
|
1226 | 1250 |
@@ -1017,6 +1017,10 b' class HgRemote(RemoteBase):' | |||
|
1017 | 1017 | } |
|
1018 | 1018 | |
|
1019 | 1019 | @reraise_safe_exceptions |
|
1020 | def set_head_ref(self, wire, head_name): | |
|
1021 | pass | |
|
1022 | ||
|
1023 | @reraise_safe_exceptions | |
|
1020 | 1024 | def archive_repo(self, wire, archive_dest_path, kind, mtime, archive_at_path, |
|
1021 | 1025 | archive_dir_name, commit_id): |
|
1022 | 1026 |
@@ -537,6 +537,10 b' class SvnRemote(RemoteBase):' | |||
|
537 | 537 | } |
|
538 | 538 | |
|
539 | 539 | @reraise_safe_exceptions |
|
540 | def set_head_ref(self, wire, head_name): | |
|
541 | pass | |
|
542 | ||
|
543 | @reraise_safe_exceptions | |
|
540 | 544 | def archive_repo(self, wire, archive_dest_path, kind, mtime, archive_at_path, |
|
541 | 545 | archive_dir_name, commit_id): |
|
542 | 546 |
General Comments 0
You need to be logged in to leave comments.
Login now