简体   繁体   中英

SVN pre-commit hook for Conflicted files

I have a file named test.txt .
When ever file conflict occurs. we get 4 files eg

test.txt
test.txt.min
test.txt.r1
test.txt.r2

In test.txt we get some text like

<<<<<<< .mine
>>>>>>> .r2

So my question is that
Is there a way to prevent user to commit the conflicted file?
I mean,

  • User cant commit a file containing text <<<<<<< .mine >>>>>>> .r2

  • User cant commit some extra files created

    I am using tortoiseSVN with visualSVserver in Windows

The Easy way :

This problem seems easily solvable by software(eg a hook script), however the real problem will be worse(believe me, I implemented it once for a customer!). Your people will start to remove the conflict markers and will rename these files to unmatch your regex in your hook script resulting in flooding your repository with all kind of conflicted files. Worse than that: Nobody can reconstruct the underlying conflicts as the conflict markers are gone!

The correct way :

You should explain your users how this conflicts occur. If they are happening very often, usually another (external) problem is responsible(bad software design, no team communication, etc.). SVN forbids to commit a conflicted file. You should show how to resolve this conflict. In standard SVN usecases conflicts are not a big issue (except on merging)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM