Skip to content

Instantly share code, notes, and snippets.

@sminnee
Created December 15, 2009 00:22
Show Gist options
  • Select an option

  • Save sminnee/256591 to your computer and use it in GitHub Desktop.

Select an option

Save sminnee/256591 to your computer and use it in GitHub Desktop.
diff --git a/arb b/arb
index b909d10..5699941 100755
--- a/arb
+++ b/arb
@@ -60,6 +60,10 @@ if(file_exists(".mergesources.yml")) {
echo "$dir (from $svnRoot$source)\n";
+ // Scrub source and dest of extraneous mergeinfo
+ $svn->scrubMergeInfoIfNecessary($source, true);
+ $svn->scrubMergeInfoIfNecessary($dir);
+
// Handle the revs argument
if(isset($keyedOptions['revs'])) {
$revs = preg_replace('/ *, */', "\n", $keyedOptions['revs']);
@@ -68,8 +72,6 @@ if(file_exists(".mergesources.yml")) {
}
$revs = $revs ? explode("\n", str_replace("r","", $revs)) : array();
-
-
$svn->formatMergeReport($revs, $source, $dir, $startrev, !$startrev && !isset($keyedOptions['revs']));
} else {
echo "Can't find merge source $mergeSource/$dir\n";
@@ -155,6 +157,37 @@ class SVNHelp {
return $this->repos;
}
+ /**
+ * Check that the given URL has no mergeinfo on sub-items, and if so, recommends a commit to
+ * remove it.
+ */
+ function scrubMergeInfoIfNecessary($mergeDir, $remoteDir = false) {
+ $url = $remoteDir ? $this->repos() . $mergeDir : $mergeDir;
+ $CLI_url = escapeshellarg($url);
+
+ $CLI_checkItems = array();
+ $subitemsXML = $this->xmlCommand("svn ls --xml $CLI_url");
+ foreach($subitemsXML->xpath('//name') as $subitem) {
+ $CLI_checkItems[] = escapeshellarg("$url/$subitem");
+ }
+
+ // Check for any mergeinfo on subdirectories
+ $checkCommand = "svn propget --recursive svn:mergeinfo " . implode(" ", $CLI_checkItems);
+ if(trim(`$checkCommand`)) {
+ echo "There is junk mergeinfo on files and subdirectories in $url. I need to scrub it "
+ . " before continuing.\n";
+
+ $propdelDir = $remoteDir ? "/tmp/arb-mergescrub" : $mergeDir;
+ if($remoteDir) execCommand("svn co $CLI_url $propdelDir");
+
+ suggestCommand("svn propdel --recursive svn:mergeinfo $propdelDir/*");
+ passthru("svn diff $propdelDir --diff-cmd " . escapeshellarg(DIFF_CMD));
+ suggestCommand("svn commit $propdelDir -m 'MINOR: Removed explicit svn:mergeinfo from subfolders'");
+ if($remoteDir) execCommand("rm -rf '/tmp/arb-mergescrub'");
+ }
+
+ }
+
function formatMergeReport($revs, $mergeSource, $dir, $startrev = null, $blockMergebacks = true) {
$fullMergeSource = $this->repos() . $mergeSource;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment