Skip to contentSkip to conversation

dim: add a variable for nightly.conf

PATCH New Jani Nikula 1 participant 2 messages Nov 4, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 dim: add a variable for nightly.conf

We'll change the name at some point, add some indirection, with a generic variable name.

---
 dim | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)
dim +15 -11
index 8e95cd82407f..6a23c868856c 100755
@@ -92,6 +92,9 @@ addr_intel_gfx="[email protected]"
 addr_dri_devel="[email protected]"
 addr_intel_qa="\"Christophe Prigent\" <[email protected]>"
 
+# integration configuration
+integration_config=nightly.conf
+
 #
 # Command line options.
 #
@@ -163,7 +166,7 @@ if [ "$subcommand" != "setup" -a "$subcommand" != "help" -a "$subcommand" != "us
 	# Internal configuration that depends on a sane setup.
 	#
 
-	dim_branches=`(source $DIM_PREFIX/drm-intel-rerere/nightly.conf ; echo $nightly_branches) | \
+	dim_branches=`(source $DIM_PREFIX/drm-intel-rerere/$integration_config ; echo $nightly_branches) | \
 		xargs -n 1 echo | grep '^origin' | sed -e 's/^origin\///'`
 fi
 
@@ -280,14 +283,16 @@ function dim_rebuild_nightly
 
 	cd $rerere
 	if [[ `git status --porcelain | grep -v "^[ ?][ ?]" | wc -l` -gt 0 ]]; then
-		warn_or_fail "-nightly configuration file not commited"
+		warn_or_fail "integration configuration file $integration_config not commited"
 	fi
 
-	echo -n "Updating rerere cache and nightly.conf... "
+	echo -n "Updating rerere cache... "
 	update_rerere_cache >& /dev/null
 	echo "Done."
 
-	source $rerere/nightly.conf
+	echo -n "Reloading $integration_config... "
+	source $rerere/$integration_config
+	echo "Done."
 
 	cd $DIM_PREFIX/$integration_branch
 	if ! git branch --list $integration_branch | grep '\*' >& /dev/null ; then
@@ -383,7 +388,6 @@ function dim_rebuild_nightly
 
 	update_linux_next
 }
-
 # push branch $1, rebuild nightly. the rest of the arguments are passed to git
 # push.
 function dim_push_branch
@@ -615,9 +619,9 @@ function dim_create_branch
 	git push $DRY_RUN $DIM_DRM_INTEL_REMOTE +$branch --set-upstream
 	cd $DIM_PREFIX/drm-intel-rerere
 	$DRY echo "nightly_branches=\"\$nightly_branches origin/$branch\"" \
-	     >> nightly.conf
-	$DRY git add nightly.conf
-	$DRY git commit --quiet -m "Adding $branch to -nightly"
+	     >> $integration_config
+	$DRY git add $integration_config
+	$DRY git commit --quiet -m "Add $branch to $integration_config"
 }
 
 function dim_remove_branch
@@ -643,9 +647,9 @@ function dim_remove_branch
 	$DRY git fetch origin --prune
 	cd $DIM_PREFIX/drm-intel-rerere
 	full_branch="origin/$branch"
-	$DRY sed -e "/${full_branch//\//\\\/}/d" -i nightly.conf
-	$DRY git add nightly.conf
-	$DRY git commit --quiet -m "Deleted $branch and removed from -nightly"
+	$DRY sed -e "/${full_branch//\//\\\/}/d" -i $integration_config
+	$DRY git add $integration_config
+	$DRY git commit --quiet -m "Remove $branch from $integration_config"
 }
 
 function dim_cd
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 2/2 dim: switch to using remote agnostic integration branch config

NOTE: This change depends on nightly.conf changes that have been committed earlier to the drm-intel-rerere repo. Looking at that first makes this change more sensible.

Use two arrays to configure the repos and branches to be merged to the integration branch:

drm_tip_repos

An associative array that maps repo names to urls. This is mostly a convenience for defining the other array. The repo names are symbolic, and not related to actual git remote names. It's also helpful for implementing dim create-branch and remove-branch.

drm_tip_config

An array of strings which describes the repos and branches to be used to generate the integration branch. The repos are listed using the symbolic repo names from the drm_tip_repos array. It's also possible to list an override sha, in case there's a need to hold back updating to the tip of the branch for some reason.

dim as a whole still remains dependent on specific (and configured) remote names, but this change detaches nightly.conf from the remote names.

---
 dim | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++-------------------
 1 file changed, 72 insertions(+), 26 deletions(-)
dim +72 -26
index 6a23c868856c..66ea0dd918b3 100755
@@ -95,6 +95,27 @@ addr_intel_qa="\"Christophe Prigent\" <[email protected]>"
 # integration configuration
 integration_config=nightly.conf
 
+function read_integration_config
+{
+	# clear everything first to allow configuration reload
+	unset drm_tip_repos drm_tip_config
+	declare -g -A drm_tip_repos
+	declare -g -a drm_tip_config
+
+	if [ -r $DIM_PREFIX/drm-intel-rerere/$integration_config ]; then
+		source $DIM_PREFIX/drm-intel-rerere/$integration_config
+	fi
+
+	dim_branches=
+	for conf in "${drm_tip_config[@]}"; do
+		read repo branch override <<< $conf
+		if [[ "$repo" = "drm-intel" ]]; then
+			dim_branches="$dim_branches $branch"
+		fi
+	done
+}
+read_integration_config
+
 #
 # Command line options.
 #
@@ -161,14 +182,30 @@ if [ "$subcommand" != "setup" -a "$subcommand" != "help" -a "$subcommand" != "us
 			exit 1
 		fi
 	done
+fi
 
-	#
-	# Internal configuration that depends on a sane setup.
-	#
+# get the remote name for url, depends on current repo
+function url_to_remote
+{
+	local url="$1"
 
-	dim_branches=`(source $DIM_PREFIX/drm-intel-rerere/$integration_config ; echo $nightly_branches) | \
-		xargs -n 1 echo | grep '^origin' | sed -e 's/^origin\///'`
-fi
+	if [[ -z "$url" ]]; then
+		echoerr "$0 without url"
+		exit 1
+	fi
+
+	local remote=$(git remote -v | grep -m 1 "$url" | cut -f 1)
+
+	if [[ -z "$remote" ]]; then
+		echoerr "No git remote for url $url found in $(pwd)"
+		echoerr "Please set it up using:"
+		echoerr "    $ git remote add <name> $url"
+		echoerr "with a name of your choice."
+		exit 1
+	fi
+
+	echo $remote
+}
 
 function dim_uptodate
 {
@@ -291,7 +328,7 @@ function dim_rebuild_nightly
 	echo "Done."
 
 	echo -n "Reloading $integration_config... "
-	source $rerere/$integration_config
+	read_integration_config
 	echo "Done."
 
 	cd $DIM_PREFIX/$integration_branch
@@ -300,7 +337,8 @@ function dim_rebuild_nightly
 		exit 1
 	fi
 
-	for remote in $(echo $nightly_branches | tr " " "\n" | sed 's|/.*$||g' | sort -u); do
+	for url in "${drm_tip_repos[@]}"; do
+		local remote=$(url_to_remote $url)
 		echo -n "Fetching $remote... "
 		# git fetch returns 128 if there's nothing to be fetched
 		git fetch $remote >& /dev/null || true
@@ -308,22 +346,17 @@ function dim_rebuild_nightly
 	done
 
 	# merge -fixes
-	for tree in $nightly_branches; do
-		local branch=${tree%:*}
-		local sha1=${tree#*:}
-		local name=${branch##*/}
-
-		# the : separator is optional
-		if [[ $sha1 == $tree ]] ; then
-			sha1=
-		fi
+	for conf in "${drm_tip_config[@]}"; do
+		read repo branch override <<< $conf
+		local url=${drm_tip_repos[$repo]}
+		local remote=$(url_to_remote $url)
+		local sha1=$remote/$branch
 
-		echo -n "Merging $branch... "
+		echo -n "Merging $repo (local remote $remote) $branch... "
 
-		if [[ -n $sha1 ]] ; then
+		if [[ -n "$override" ]]; then
+			sha1=$override
 			echo -n "Using override sha1: $sha1... "
-		else
-			sha1=$branch
 		fi
 
 		if [ $first == 1 ] ; then
@@ -335,8 +368,7 @@ function dim_rebuild_nightly
 			echo "Fast-forward. Done."
 			true
 		else
-			local fixup_file=$rerere/$integration_branch-$name-fixup.patch
-
+			local fixup_file=$rerere/$repo-${branch//\//-}-fixup.patch
 			echo $fixup_file > .fixup_file_path
 
 			git merge --rerere-autoupdate --no-commit $sha1 >& /dev/null || true
@@ -353,7 +385,7 @@ function dim_rebuild_nightly
 			echo "Done."
 		fi
 
-		echo -e "$branch `git rev-parse $sha1`\n\t`git log -1 $sha1 --pretty=format:%s`" >> $specfile
+		echo -e "$repo $branch `git rev-parse $sha1`\n\t`git log -1 $sha1 --pretty=format:%s`" >> $specfile
 
 		$INTERACTIVE
 	done
@@ -617,11 +649,18 @@ function dim_create_branch
 
 	$DRY git branch $branch $start
 	git push $DRY_RUN $DIM_DRM_INTEL_REMOTE +$branch --set-upstream
+
+	# FIXME: make it possible to add/remove non-drm-intel branches
+	local repo=drm-intel
 	cd $DIM_PREFIX/drm-intel-rerere
+	$DRY sed -i "s/^\() # DO NOT CHANGE THIS LINE\)$/\t\"$repo\t\t${branch//\//\\\/}\"\n\1/" $integration_config
+
+	# FIXME: For backward compatibility. Remove.
 	$DRY echo "nightly_branches=\"\$nightly_branches origin/$branch\"" \
 	     >> $integration_config
+
 	$DRY git add $integration_config
-	$DRY git commit --quiet -m "Add $branch to $integration_config"
+	$DRY git commit --quiet -m "Add $repo $branch to $integration_config"
 }
 
 function dim_remove_branch
@@ -645,11 +684,18 @@ function dim_remove_branch
 	cd $DIM_PREFIX/drm-intel-nightly
 	git push $DRY_RUN origin --delete $branch
 	$DRY git fetch origin --prune
+
+	# FIXME: make it possible to add/remove non-drm-intel branches
+	local repo=drm-intel
 	cd $DIM_PREFIX/drm-intel-rerere
+	$DRY sed -i "/^[[:space:]]*\"${repo}[[:space:]]\+${branch//\//\\\/}.*$/d" $integration_config
+
+	# FIXME: For backward compatibility. Remove.
 	full_branch="origin/$branch"
 	$DRY sed -e "/${full_branch//\//\\\/}/d" -i $integration_config
+
 	$DRY git add $integration_config
-	$DRY git commit --quiet -m "Remove $branch from $integration_config"
+	$DRY git commit --quiet -m "Remove $repo $branch from $integration_config"
 }
 
 function dim_cd
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx