<div dir="ltr">Ping. Can we update the script?<div><br><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">~Craig</div></div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jul 12, 2019 at 1:58 PM Craig Topper <<a href="mailto:craig.topper@gmail.com">craig.topper@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">That seems to work.<div><br clear="all"><div><div dir="ltr" class="gmail-m_2549174360913016936gmail_signature">~Craig</div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jul 12, 2019 at 11:00 AM James Y Knight <<a href="mailto:jyknight@google.com" target="_blank">jyknight@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Can you check if this will work?<div>- git_remote_url = git('remote', 'get-url', 'origin')<br></div><div>+ git_remote_url = git('ls-remote', '--get-url', 'origin')<br></div><div><br></div><div>I _think_ that'll work back to old versions of git, but I'd prefer if you could verify first. :)</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jul 12, 2019 at 1:44 PM Craig Topper <<a href="mailto:craig.topper@gmail.com" target="_blank">craig.topper@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">It seems get-url is not supported by the 1.8.3.1 version of git on the server I have use at work.<div><br></div><div><div><div dir="ltr" class="gmail-m_2549174360913016936gmail-m_4772403714434567342gmail-m_7379353017552638372gmail_signature">~Craig</div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jul 12, 2019 at 9:40 AM James Y Knight via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Author: jyknight<br>
Date: Fri Jul 12 09:40:46 2019<br>
New Revision: 365917<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=365917&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=365917&view=rev</a><br>
Log:<br>
Allow the 'git-llvm' tool to push to svn from the split repositories<br>
for 'test-suite', 'lnt', 'zorg', and 'www'.<br>
<br>
This is done by looking at the pathname of the git remote named<br>
'origin', which is not 100% reliable, but should work in most cases.<br>
<br>
Modified:<br>
llvm/trunk/utils/git-svn/git-llvm<br>
<br>
Modified: llvm/trunk/utils/git-svn/git-llvm<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/git-svn/git-llvm?rev=365917&r1=365916&r2=365917&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/git-svn/git-llvm?rev=365917&r1=365916&r2=365917&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/utils/git-svn/git-llvm (original)<br>
+++ llvm/trunk/utils/git-svn/git-llvm Fri Jul 12 09:40:46 2019<br>
@@ -48,7 +48,7 @@ except ImportError:<br>
from pipes import quote<br>
<br>
# It's *almost* a straightforward mapping from the monorepo to svn...<br>
-GIT_TO_SVN_DIR = {<br>
+LLVM_MONOREPO_SVN_MAPPING = {<br>
d: (d + '/trunk')<br>
for d in [<br>
'clang-tools-extra',<br>
@@ -70,8 +70,11 @@ GIT_TO_SVN_DIR = {<br>
'pstl',<br>
]<br>
}<br>
-GIT_TO_SVN_DIR.update({'clang': 'cfe/trunk'})<br>
-GIT_TO_SVN_DIR.update({'': 'monorepo-root/trunk'})<br>
+LLVM_MONOREPO_SVN_MAPPING.update({'clang': 'cfe/trunk'})<br>
+LLVM_MONOREPO_SVN_MAPPING.update({'': 'monorepo-root/trunk'})<br>
+<br>
+SPLIT_REPO_NAMES = {'llvm-' + d : d + '/trunk'<br>
+ for d in ['www', 'zorg', 'test-suite', 'lnt']}<br>
<br>
VERBOSE = False<br>
QUIET = False<br>
@@ -274,13 +277,13 @@ def fix_eol_style_native(rev, svn_sr_pat<br>
# just the diff, and not a mass line ending change.<br>
shell(['dos2unix'] + crlf_files, ignore_errors=True, cwd=svn_sr_path)<br>
<br>
-def split_subrepo(f):<br>
+def split_subrepo(f, git_to_svn_mapping):<br>
# Given a path, splits it into (subproject, rest-of-path). If the path is<br>
# not in a subproject, returns ('', full-path).<br>
<br>
subproject, remainder = split_first_path_component(f)<br>
<br>
- if subproject in GIT_TO_SVN_DIR:<br>
+ if subproject in git_to_svn_mapping:<br>
return subproject, remainder<br>
else:<br>
return '', f<br>
@@ -293,7 +296,7 @@ def get_all_parent_dirs(name):<br>
head, tail = os.path.split(head)<br>
return parts<br>
<br>
-def svn_push_one_rev(svn_repo, rev, dry_run):<br>
+def svn_push_one_rev(svn_repo, rev, git_to_svn_mapping, dry_run):<br>
files = git('diff-tree', '--no-commit-id', '--name-only', '-r',<br>
rev).split('\n')<br>
if not files:<br>
@@ -302,7 +305,7 @@ def svn_push_one_rev(svn_repo, rev, dry_<br>
# Split files by subrepo<br>
subrepo_files = collections.defaultdict(list)<br>
for f in files:<br>
- subrepo, remainder = split_subrepo(f)<br>
+ subrepo, remainder = split_subrepo(f, git_to_svn_mapping)<br>
subrepo_files[subrepo].append(remainder)<br>
<br>
status = svn(svn_repo, 'status', '--no-ignore')<br>
@@ -312,7 +315,7 @@ def svn_push_one_rev(svn_repo, rev, dry_<br>
<br>
svn_dirs_to_update = set()<br>
for sr, files in iteritems(subrepo_files):<br>
- svn_sr_path = GIT_TO_SVN_DIR[sr]<br>
+ svn_sr_path = git_to_svn_mapping[sr]<br>
for f in files:<br>
svn_dirs_to_update.add(<br>
os.path.dirname(os.path.join(svn_sr_path, f)))<br>
@@ -333,7 +336,7 @@ def svn_push_one_rev(svn_repo, rev, dry_<br>
svn(svn_repo, 'update', '--depth=files', *sorted_dirs_to_update)<br>
<br>
for sr, files in iteritems(subrepo_files):<br>
- svn_sr_path = os.path.join(svn_repo, GIT_TO_SVN_DIR[sr])<br>
+ svn_sr_path = os.path.join(svn_repo, git_to_svn_mapping[sr])<br>
if <a href="http://os.name" rel="noreferrer" target="_blank">os.name</a> == 'nt':<br>
fix_eol_style_native(rev, svn_sr_path, files)<br>
# We use text=False (and pass '--binary') so that we can get an exact<br>
@@ -390,6 +393,17 @@ def cmd_push(args):<br>
# Push from the root of the git repo<br>
os.chdir(git_root)<br>
<br>
+ # Get the remote URL, and check if it's one of the standalone repos.<br>
+ git_remote_url = git('remote', 'get-url', 'origin')<br>
+ git_remote_url = git_remote_url.rstrip('.git').rstrip('/')<br>
+ git_remote_repo_name = git_remote_url.rsplit('/', 1)[-1]<br>
+ split_repo_path = SPLIT_REPO_NAMES.get(git_remote_repo_name)<br>
+ if split_repo_path:<br>
+ git_to_svn_mapping = {'': split_repo_path}<br>
+ else:<br>
+ # Default to the monorepo mapping<br>
+ git_to_svn_mapping = LLVM_MONOREPO_SVN_MAPPING<br>
+<br>
# We need a staging area for SVN, let's hide it in the .git directory.<br>
dot_git_dir = git('rev-parse', '--git-common-dir')<br>
# Not all versions of git support --git-common-dir and just print the<br>
@@ -403,13 +417,15 @@ def cmd_push(args):<br>
rev_range = args.rev_range<br>
dry_run = args.dry_run<br>
revs = get_revs_to_push(rev_range)<br>
- log('Pushing %d commit%s:\n%s' %<br>
- (len(revs), 's' if len(revs) != 1<br>
- else '', '\n'.join(' ' + git('show', '--oneline', '--quiet', c)<br>
- for c in revs)))<br>
+ log('Pushing %d %s commit%s:\n%s' %<br>
+ (len(revs),<br>
+ 'split-repo (%s)' % split_repo_path if split_repo_path else 'monorepo',<br>
+ 's' if len(revs) != 1 else '',<br>
+ '\n'.join(' ' + git('show', '--oneline', '--quiet', c)<br>
+ for c in revs)))<br>
for r in revs:<br>
clean_svn(svn_root)<br>
- svn_push_one_rev(svn_root, r, dry_run)<br>
+ svn_push_one_rev(svn_root, r, git_to_svn_mapping, dry_run)<br>
<br>
<br>
def lookup_llvm_svn_id(git_commit_hash):<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>