You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Ryan Meador <rm...@softscape.com> on 2009/05/19 15:54:37 UTC

script to force SVN to elide mergeinfo on child paths

Hi all,

I've cooked up a perl script that will run a giant --record-only merge
on the root of a branch in an attempt to get SVN to elide all the
mergeinfo on the child paths.  This is very much a work in progress and
is semi-specific to my case (some hardcoded paths), but should be
possible to generalize.  I'm not 100% sure it works, since the mergeinfo
in my repository is very messed up, but some of it gets elided, which
gives me hope.  Pburba has been a huge help to me in creating this
script, and he suggested I send it to this list.  You can do whatever
you want with it, including releasing it as open source, if you wish.
I'm probably going to continue development on it until my mergeinfo
problems are solved, so I'll send out another version if I make any
changes of note.

 

Ryan


This e-mail communication and any attachments are confidential and intended only for the person or
entity to which it is addressed.  Any review, retransmission, dissemination or other use of, or taking
of any action in reliance upon this information by persons or entities other than the intended recipient
is prohibited.  If you are not the intended recipient, any review, disclosure, dissemination,
distribution or copying of it or its contents is prohibited.  If you have received this communication
in error, please notify the sender immediately and destroy all copies of this communication and any attachments.

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2314498

RE: script to force SVN to elide mergeinfo on child paths

Posted by Trent Nelson <tn...@onresolve.com>.
I came up with the following for my users, who are all on Windows.  They just drop this file in the affected root (i.e. trunk) and run it.  Their issues are *always* dodgy svn:mergeinfo props being set on subtrees.

<paste>
@echo off
rem $Id: fix_dodgy_mergeinfo_props.bat 5 2009-01-23 11:22:03Z trent.p.nelson $
rem Recurse through a source directory and remove the svn:mergeinfo property
rem if set.  See http://supportex/wiki/svn/ReintegrateIssues.

setlocal enableextensions enabledelayedexpansion
set FILE=
set PROP=
set _i=0
for /f "usebackq tokens=1,2,3" %%i in (`svn pl -R`) do (
    if "%%i"=="Properties" (
        set FILE=%%k
        set FILE=!FILE:~1,-2!
    )
    set PROP=%%i
    set PROP=!PROP:*:=!
    if "!PROP!"=="mergeinfo" (
        if not "!FILE!"=="." (
            svn pd -q svn:mergeinfo !FILE!
            echo removed svn:mergeinfo property from !FILE!
            set /a _i=!_i! + 1
        )
    )
)
endlocal & set COUNT=%_i%

if "%COUNT%"=="0" (
    echo no affected files/folders found.
) else (
    echo removed svn:mergeinfo from %COUNT% files/folders
    echo *** MAKE SURE YOU SVN COMMIT TO SAVE CHANGES! ***
)
</paste>

I've since implemented a pre-commit hook that prevents a commit if erroneous svn:mergeinfo is set on any subtree paths.  Turns out this was actually easier than upgrading to 1.5.5+ clients:

<paste>
class SubtreeMergeinfo(RepositoryHook):
    id = 'subtree-mergeinfo'
    
    def pre_commit(self, txn):
        pathmatcher = self.repo.pathmatcher
        changeset = self.repo.changeset(txn)
        analysis = changeset.analysis
        path = changeset.root_dir
        root_details = pathmatcher.get_root_details(path)
        if not root_details:
            return
        root_dir, root_type, root_name = root_details
        
        skip = None
        if not analysis.is_subtree_change:
            skip = changeset.root_change
        
        for change in changeset.changes.values():
            if skip and change == skip:
                continue
            if not change.is_remove:
                if 'svn:mergeinfo' in change.proplist():
                    self.terminate('svn:mergeinfo property erroneously set on '
                                   'file %s, please remove before committing' %\
                                   change.path)
</paste>

From: Ryan Meador [mailto:rmeador@softscape.com] 
Sent: 19 May 2009 16:55
To: dev@subversion.tigris.org
Subject: script to force SVN to elide mergeinfo on child paths

Hi all,
I’ve cooked up a perl script that will run a giant --record-only merge on the root of a branch in an attempt to get SVN to elide all the mergeinfo on the child paths.  This is very much a work in progress and is semi-specific to my case (some hardcoded paths), but should be possible to generalize.  I’m not 100% sure it works, since the mergeinfo in my repository is very messed up, but some of it gets elided, which gives me hope.  Pburba has been a huge help to me in creating this script, and he suggested I send it to this list.  You can do whatever you want with it, including releasing it as open source, if you wish.  I’m probably going to continue development on it until my mergeinfo problems are solved, so I’ll send out another version if I make any changes of note.

Ryan
This e-mail communication and any attachments are confidential and intended only for the person or
entity to which it is addressed.  Any review, retransmission, dissemination or other use of, or taking
of any action in reliance upon this information by persons or entities other than the intended recipient
is prohibited.  If you are not the intended recipient, any review, disclosure, dissemination,
distribution or copying of it or its contents is prohibited.  If you have received this communication
in error, please notify the sender immediately and destroy all copies of this communication and any attachments.

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2352897