0

I am working on svn repo, which has many checkins.

I want to exclude one checkin and build code.

If it is latest checkin revision then can take just one previous to it and build. But need to exclude one checkin older one.

Note: We can revert that code and make checkin. I don't want to do in this way. Instead exclude that checkin.

At last I need single svn command which can do this task for me.

Could please help here?

Thanks.

peter roy
  • 9
  • 2
  • I think in svn you cannot rewrite history the same way you can do in git. You could create a separate branch from the commit _previous_ to the one you want to remove and then cherry-pick the ones that follow the one you want to remove... that should give you something like what you are asking _but_ it's a different branch altogether. – eftshift0 Apr 26 '23 at 11:11

1 Answers1

2

What you are asking for is not possible with a single subversion command.

To undo a specific commit, perform a reverse-merge like this: svn merge -c -BROKEN_REVISION. A merge, however, can only be done on a working copy. This is because a merge might create a conflict and conflict resolution has to be done locally.

Also see the answers to How do I revert an SVN commit?

To have a single command that undoes a commit, you can write a script roughly like this:

# Skip this if you already have a working copy
svn checkout ${REPO_URL}/${BRANCH} ${WC_PATH}
# Undo the offending commit
svn merge --change -${BROKEN_REVISION} ${WC_PATH}
# Try to commit the changes
# In case of a conflict, this will fail; resolve and commit the change
# If you plan to build locally, you can skip this line altogether
svn commit --message "Undo ${BROKEN_REVISION}" ${WC_PATH}

This, of course, will download a working copy from the subversion server, undo the commit locally and attempt to upload the changes, creating a new revision in the process.

Note that it's a fundamental premise of subversion that any change to the repository will create a new revision. So no matter how and where you change things, the revision will be incremented. The only way around this would be to manipulate your repository using the svnadmin command. See Delete all traces of a SVN commit

Friedrich
  • 2,011
  • 2
  • 17
  • 19
  • I feel that one important note is needed: only an admin with full access to the server computer (and its storage) can manipulate revision history. Regular users who access the repository over HTTP(S) or svn:// don't have such access and cannot manipulate revision history. – bahrep Apr 27 '23 at 16:40