Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Unified Diff: git_common.py

Issue 1342383002: Add a git-drover. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « git-drover ('k') | git_drover.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: git_common.py
diff --git a/git_common.py b/git_common.py
index 9e0adf24741494b6c3b3a04b82674383993fdd68..5a01c835a96b67929c55cbca573a1804fd648d11 100644
--- a/git_common.py
+++ b/git_common.py
@@ -22,6 +22,7 @@ import functools
import logging
import os
import re
+import shutil
import signal
import sys
import tempfile
@@ -817,3 +818,38 @@ def get_branches_info(include_tracking_status):
missing_upstreams[info.upstream] = None
return dict(info_map.items() + missing_upstreams.items())
+
+
+def make_workdir_common(repository, new_workdir, files_to_symlink,
+ files_to_copy):
+ os.makedirs(new_workdir)
+ for entry in files_to_symlink:
+ clone_file(repository, new_workdir, entry, os.symlink)
+ for entry in files_to_copy:
+ clone_file(repository, new_workdir, entry, shutil.copy)
+
+
+def make_workdir(repository, new_workdir):
+ GIT_DIRECTORY_WHITELIST = [
+ 'config',
+ 'info',
+ 'hooks',
+ 'logs/refs',
+ 'objects',
+ 'packed-refs',
+ 'refs',
+ 'remotes',
+ 'rr-cache',
+ 'svn'
+ ]
+ make_workdir_common(repository, new_workdir, GIT_DIRECTORY_WHITELIST,
+ ['HEAD'])
+
+
+def clone_file(repository, new_workdir, link, operation):
+ if not os.path.exists(os.path.join(repository, link)):
+ return
+ link_dir = os.path.dirname(os.path.join(new_workdir, link))
+ if not os.path.exists(link_dir):
+ os.makedirs(link_dir)
+ operation(os.path.join(repository, link), os.path.join(new_workdir, link))
« no previous file with comments | « git-drover ('k') | git_drover.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698