diff mbox

[07/10] dim: autodetect branches in rebuild-nightly

Message ID 20161018121356.9594-7-daniel.vetter@ffwll.ch (mailing list archive)
State New, archived
Headers show

Commit Message

Daniel Vetter Oct. 18, 2016, 12:13 p.m. UTC
Needs new url-mapping information in nightly.conf to work properly.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 dim | 48 ++++++++++++++++++++++++++++++++++++------------
 1 file changed, 36 insertions(+), 12 deletions(-)

Comments

Jani Nikula Oct. 18, 2016, 1:52 p.m. UTC | #1
On Tue, 18 Oct 2016, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> Needs new url-mapping information in nightly.conf to work properly.

I think in the long run the right fix would be to make nightly.conf
independent of remote names. Not sure if that's worth the trouble at
this point.

BR,
Jani.



>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  dim | 48 ++++++++++++++++++++++++++++++++++++------------
>  1 file changed, 36 insertions(+), 12 deletions(-)
>
> diff --git a/dim b/dim
> index 48d5e7b6477a..f9b28d5fd241 100755
> --- a/dim
> +++ b/dim
> @@ -235,20 +235,30 @@ function dim_commit_add_tag
>  	done
>  }
>  
> +function map_nightly_remote
> +{
> +	local nightly_remote=$1
> +	local remote_url=`eval echo "\\\$nightly_remote_url_${nightly_remote/-/_}"`
> +
> +	get_remote_name $remote_url
> +}
> +
>  function update_linux_next
>  {
>  	cd $DIM_PREFIX/drm-intel-nightly
>  
> +	local nightly_origin=`map_nightly_remote origin`
> +
>  	# always update drm-intel-fixes
>  	echo -n "Pushing drm-intel-fixes to for-linux-next-fixes... "
> -	git push $DRY_RUN origin +origin/drm-intel-fixes:for-linux-next-fixes >& /dev/null
> +	git push $DRY_RUN $nightly_origin +$nightly_origin/drm-intel-fixes:for-linux-next-fixes >& /dev/null
>  	echo "Done."
>  
> -	if git merge-base --is-ancestor origin/drm-intel-next-fixes origin/drm-intel-fixes ; then
> +	if git merge-base --is-ancestor $nightly_origin/drm-intel-next-fixes $nightly_origin/drm-intel-fixes ; then
>  		# -fixes has caught up to dinf, i.e. we're out of the merge
>  		# window. Push the next queue.
>  		echo -n "Out of merge window. Pushing drm-intel-next-queued to for-linux-next... "
> -		git push $DRY_RUN origin +origin/drm-intel-next-queued:for-linux-next >& /dev/null
> +		git push $DRY_RUN $nightly_origin +$nightly_origin/drm-intel-next-queued:for-linux-next >& /dev/null
>  		echo "Done."
>  	else
>  		# dinf is ahead of -fixes, i.e. drm-next has already closed for
> @@ -256,7 +266,7 @@ function update_linux_next
>  		# for the current -next cycle. Push dinf
>  
>  		echo -n "Pushing drm-intel-next-fixes to for-linux-next... "
> -		git push $DRY_RUN origin +origin/drm-intel-next-fixes:for-linux-next >& /dev/null
> +		git push $DRY_RUN $nightly_origin +$nightly_origin/drm-intel-next-fixes:for-linux-next >& /dev/null
>  		echo "Done."
>  	fi
>  }
> @@ -272,11 +282,20 @@ function check_conflicts
>  	true
>  }
>  
> +function rr_cache_dir
> +{
> +	if [ -d $DIM_PREFIX/drm-intel-nightly/.git/rr-cache/ ] ; then
> +		echo $DIM_PREFIX/drm-intel-nightly/.git/rr-cache/
> +	else
> +		echo $DIM_PREFIX/$DIM_DRM_INTEL/.git/rr-cache/
> +	fi
> +}
> +
>  function update_rerere_cache
>  {
>  	cd $DIM_PREFIX/drm-intel-rerere/
>  	git pull
> -	cp rr-cache/* $DIM_PREFIX/drm-intel-nightly/.git/rr-cache/ -r
> +	cp rr-cache/* `rr_cache-dir` -r
>  	cd -
>  }
>  
> @@ -307,9 +326,10 @@ function dim_rebuild_nightly
>  	fi
>  
>  	for remote in $(echo $nightly_branches | tr " " "\n" | sed 's|/.*$||g' | sort -u); do
> -		echo -n "Fetching $remote... "
> +		local nightly_remote=`map_nightly_remote $remote`
> +		echo -n "Fetching $remote (as $nightly_remote) ... "
>  		# git fetch returns 128 if there's nothing to be fetched
> -		git fetch $remote >& /dev/null || true
> +		git fetch $nightly_remote >& /dev/null || true
>  		echo "Done."
>  	done
>  
> @@ -329,12 +349,14 @@ function dim_rebuild_nightly
>  		if [[ -n $sha1 ]] ; then
>  			echo -n "Using override sha1: $sha1... "
>  		else
> -			sha1=$branch
> +			local remote=${branch%%/*}
> +			local nightly_remote=`map_nightly_remote $remote`
> +			sha1=`echo $branch | sed -e s/^$remote/$nightly_remote/`
>  		fi
>  
>  		if [ $first == 1 ] ; then
> +			git reset --hard $sha1 &> /dev/null
>  			echo "Reset. Done."
> -			git reset --hard $sha1 >& /dev/null
>  			first=0
>  		elif git merge --rerere-autoupdate --ff-only $sha1 >& /dev/null ; then
>  			# nothing to do if just fast-forward
> @@ -370,14 +392,16 @@ function dim_rebuild_nightly
>  	git commit --quiet -m "$integration_branch: $time integration manifest"
>  	echo "Done."
>  
> +	local nightly_origin=`map_nightly_remote origin`
> +
>  	echo -n "Pushing $integration_branch... "
> -	git push $DRY_RUN origin +HEAD >& /dev/null && echo "Done."
> +	git push $DRY_RUN $nightly_origin +HEAD >& /dev/null && echo "Done."
>  
>  	echo -n "Updating rerere cache... "
>  	cd $rerere
>  	if git branch | grep rerere-cache | grep '\*' >& /dev/null ; then
>  		git pull >& /dev/null
> -		cp $DIM_PREFIX/$integration_branch/.git/rr-cache/* rr-cache -r
> +		cp `rr_cache_dir` rr-cache -r
>  		git add *.patch >& /dev/null || true
>  		git add rr-cache/* > /dev/null
>  		if git commit -m "$time: $integration_branch rerere cache update" >& /dev/null; then
> @@ -386,7 +410,7 @@ function dim_rebuild_nightly
>  			echo -n "Nothing changed. "
>  		fi
>  		echo -n "Pushing rerere cache... "
> -		git push $DRY_RUN origin HEAD >& /dev/null && echo "Done."
> +		git push $DRY_RUN $nightly_origin HEAD >& /dev/null && echo "Done."
>  	else
>  		echo "Fail: Branch setup for the rerere-cache is borked."
>  		exit 1
Daniel Vetter Oct. 18, 2016, 7:29 p.m. UTC | #2
On Tue, Oct 18, 2016 at 3:52 PM, Jani Nikula
<jani.nikula@linux.intel.com> wrote:
> On Tue, 18 Oct 2016, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
>> Needs new url-mapping information in nightly.conf to work properly.
>
> I think in the long run the right fix would be to make nightly.conf
> independent of remote names. Not sure if that's worth the trouble at
> this point.

It is with this. The remote names in nightly.conf are now entirely
fiction. The magic here takes those, then looks up the corresponding
url (againg from nigthly.conf) and then uses get_remote_name to figure
out the appropriate git remote in the local repo. Or complain and quit
if it doesn't exist. My drm-tip now has an "origin" remote pointing at
Linus' repo, while the "origin" from nightly.conf gets remapped to
"drm-tip". Sample output from running rebuild-nightly:

Updating rerere cache and nightly.conf... Done.
Fetching drm-intel (as danvet) ... Done.
Fetching drm-upstream (as airlied) ... Done.
Fetching sound-upstream (as takashi) ... Done.
Merging drm-intel/drm-intel-fixes... Reset. Done.
Merging drm-upstream/drm-fixes... Fast-forward. Done.
Merging drm-intel/drm-intel-next-fixes... Fast-forward. Done.
...

Cheers, Daniel
Jani Nikula Oct. 19, 2016, 7:10 a.m. UTC | #3
On Tue, 18 Oct 2016, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> On Tue, Oct 18, 2016 at 3:52 PM, Jani Nikula
> <jani.nikula@linux.intel.com> wrote:
>> On Tue, 18 Oct 2016, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
>>> Needs new url-mapping information in nightly.conf to work properly.
>>
>> I think in the long run the right fix would be to make nightly.conf
>> independent of remote names. Not sure if that's worth the trouble at
>> this point.
>
> It is with this.

I mean, is it worth changing the nightly.conf format at this point to
*not* have remote names at all, but just repo urls and branches. That's
what I think should be done eventually. Because the remote names are
fiction.

BR,
Jani.

> The remote names in nightly.conf are now entirely
> fiction. The magic here takes those, then looks up the corresponding
> url (againg from nigthly.conf) and then uses get_remote_name to figure
> out the appropriate git remote in the local repo. Or complain and quit
> if it doesn't exist. My drm-tip now has an "origin" remote pointing at
> Linus' repo, while the "origin" from nightly.conf gets remapped to
> "drm-tip". Sample output from running rebuild-nightly:
>
> Updating rerere cache and nightly.conf... Done.
> Fetching drm-intel (as danvet) ... Done.
> Fetching drm-upstream (as airlied) ... Done.
> Fetching sound-upstream (as takashi) ... Done.
> Merging drm-intel/drm-intel-fixes... Reset. Done.
> Merging drm-upstream/drm-fixes... Fast-forward. Done.
> Merging drm-intel/drm-intel-next-fixes... Fast-forward. Done.
> ...
>
> Cheers, Daniel
diff mbox

Patch

diff --git a/dim b/dim
index 48d5e7b6477a..f9b28d5fd241 100755
--- a/dim
+++ b/dim
@@ -235,20 +235,30 @@  function dim_commit_add_tag
 	done
 }
 
+function map_nightly_remote
+{
+	local nightly_remote=$1
+	local remote_url=`eval echo "\\\$nightly_remote_url_${nightly_remote/-/_}"`
+
+	get_remote_name $remote_url
+}
+
 function update_linux_next
 {
 	cd $DIM_PREFIX/drm-intel-nightly
 
+	local nightly_origin=`map_nightly_remote origin`
+
 	# always update drm-intel-fixes
 	echo -n "Pushing drm-intel-fixes to for-linux-next-fixes... "
-	git push $DRY_RUN origin +origin/drm-intel-fixes:for-linux-next-fixes >& /dev/null
+	git push $DRY_RUN $nightly_origin +$nightly_origin/drm-intel-fixes:for-linux-next-fixes >& /dev/null
 	echo "Done."
 
-	if git merge-base --is-ancestor origin/drm-intel-next-fixes origin/drm-intel-fixes ; then
+	if git merge-base --is-ancestor $nightly_origin/drm-intel-next-fixes $nightly_origin/drm-intel-fixes ; then
 		# -fixes has caught up to dinf, i.e. we're out of the merge
 		# window. Push the next queue.
 		echo -n "Out of merge window. Pushing drm-intel-next-queued to for-linux-next... "
-		git push $DRY_RUN origin +origin/drm-intel-next-queued:for-linux-next >& /dev/null
+		git push $DRY_RUN $nightly_origin +$nightly_origin/drm-intel-next-queued:for-linux-next >& /dev/null
 		echo "Done."
 	else
 		# dinf is ahead of -fixes, i.e. drm-next has already closed for
@@ -256,7 +266,7 @@  function update_linux_next
 		# for the current -next cycle. Push dinf
 
 		echo -n "Pushing drm-intel-next-fixes to for-linux-next... "
-		git push $DRY_RUN origin +origin/drm-intel-next-fixes:for-linux-next >& /dev/null
+		git push $DRY_RUN $nightly_origin +$nightly_origin/drm-intel-next-fixes:for-linux-next >& /dev/null
 		echo "Done."
 	fi
 }
@@ -272,11 +282,20 @@  function check_conflicts
 	true
 }
 
+function rr_cache_dir
+{
+	if [ -d $DIM_PREFIX/drm-intel-nightly/.git/rr-cache/ ] ; then
+		echo $DIM_PREFIX/drm-intel-nightly/.git/rr-cache/
+	else
+		echo $DIM_PREFIX/$DIM_DRM_INTEL/.git/rr-cache/
+	fi
+}
+
 function update_rerere_cache
 {
 	cd $DIM_PREFIX/drm-intel-rerere/
 	git pull
-	cp rr-cache/* $DIM_PREFIX/drm-intel-nightly/.git/rr-cache/ -r
+	cp rr-cache/* `rr_cache-dir` -r
 	cd -
 }
 
@@ -307,9 +326,10 @@  function dim_rebuild_nightly
 	fi
 
 	for remote in $(echo $nightly_branches | tr " " "\n" | sed 's|/.*$||g' | sort -u); do
-		echo -n "Fetching $remote... "
+		local nightly_remote=`map_nightly_remote $remote`
+		echo -n "Fetching $remote (as $nightly_remote) ... "
 		# git fetch returns 128 if there's nothing to be fetched
-		git fetch $remote >& /dev/null || true
+		git fetch $nightly_remote >& /dev/null || true
 		echo "Done."
 	done
 
@@ -329,12 +349,14 @@  function dim_rebuild_nightly
 		if [[ -n $sha1 ]] ; then
 			echo -n "Using override sha1: $sha1... "
 		else
-			sha1=$branch
+			local remote=${branch%%/*}
+			local nightly_remote=`map_nightly_remote $remote`
+			sha1=`echo $branch | sed -e s/^$remote/$nightly_remote/`
 		fi
 
 		if [ $first == 1 ] ; then
+			git reset --hard $sha1 &> /dev/null
 			echo "Reset. Done."
-			git reset --hard $sha1 >& /dev/null
 			first=0
 		elif git merge --rerere-autoupdate --ff-only $sha1 >& /dev/null ; then
 			# nothing to do if just fast-forward
@@ -370,14 +392,16 @@  function dim_rebuild_nightly
 	git commit --quiet -m "$integration_branch: $time integration manifest"
 	echo "Done."
 
+	local nightly_origin=`map_nightly_remote origin`
+
 	echo -n "Pushing $integration_branch... "
-	git push $DRY_RUN origin +HEAD >& /dev/null && echo "Done."
+	git push $DRY_RUN $nightly_origin +HEAD >& /dev/null && echo "Done."
 
 	echo -n "Updating rerere cache... "
 	cd $rerere
 	if git branch | grep rerere-cache | grep '\*' >& /dev/null ; then
 		git pull >& /dev/null
-		cp $DIM_PREFIX/$integration_branch/.git/rr-cache/* rr-cache -r
+		cp `rr_cache_dir` rr-cache -r
 		git add *.patch >& /dev/null || true
 		git add rr-cache/* > /dev/null
 		if git commit -m "$time: $integration_branch rerere cache update" >& /dev/null; then
@@ -386,7 +410,7 @@  function dim_rebuild_nightly
 			echo -n "Nothing changed. "
 		fi
 		echo -n "Pushing rerere cache... "
-		git push $DRY_RUN origin HEAD >& /dev/null && echo "Done."
+		git push $DRY_RUN $nightly_origin HEAD >& /dev/null && echo "Done."
 	else
 		echo "Fail: Branch setup for the rerere-cache is borked."
 		exit 1