Completely clear the wrong submitted SVN version

This paper mainly introduces how to clear the wrong submitted version of SVN through the dump and load commands of svnadmin. It mainly includes the following aspects:

  • svnadmin command
  • Back up and record the wrong version number
  • Dump version warehouse
  • Create a new version warehouse
  • Recover warehouse dump file
  • Check out the new version warehouse
  • Update log cache

Software version used in this article:

  • FreeBSD 13.0
  • subversion 1.14.0
  • TortoiseSVN 1.12.2(Windows 64-bit)

Subversion (SVN) is a free and open source version control system. By establishing a central version warehouse (Repository) to store the version and modification information of all files and directories, and record who, when and why the changes occurred, it is allowed to extract all the information of the historical versions of these files at any time. Subversion is a general-purpose system that can be used to manage any type of file, including program source code. Subversion can also be used in scenarios where many people work together. It can realize resource sharing and work collaboration through centralized management of versions and branches.

Usually, SVN is used to manage document versions. Therefore, whether the correct version or the wrong version will be recorded in the warehouse. Even if the document contains some unnecessary or incorrect content, this is a complete version control. However, in some cases, due to careless operation or poor consideration, wrong documents will be submitted in the document directory, such as a document without warehousing, a document containing sensitive information, or a huge program installation package. Although these missubmitted documents can be deleted in later versions, they leave a permanent figure in the storage warehouse. These irrelevant files can be extracted by version number at any time. In particular, these files also take up a lot of storage space, which is unbearable for a qualified warehouse keeper. He has to get rid of it quickly.

The following figure shows the version log of an SVN document warehouse. You can see that a new file is added in version 95, but this file is unnecessary. So how can this file be completely deleted from the warehouse?

Although there is no special command to delete the warehouse file in SVN, the warehouse file can be completely deleted by exporting and restoring the specific version of SVN.

1 svnadmin command

svnadmin is the management tool of SVN warehouse. It is generally installed with SVN server. The command usage is as follows:

# svnadmin SUBCOMMAND REPOS_PATH [options] [args]

Of which:

SUBCOMMAND is a specific management command, usually including help, create, hotcopy, dump, load, etc;

REPOS_PATH is the local path of the warehouse to be managed.

[options] [args] are optional parameters and options related to specific commands.

2 back up and record the wrong version number

Before starting, you must remember to back up, so as not to cause permanent damage to the warehouse due to misoperation. Backup can use tar, 7-zip and other packaging compression tools, or directly copy to U SB flash disk.

The next important task is to record the wrong version number. Use the "show log" command of TortoiseSVN to display the log information, check carefully, find the version number to be cleared and record it on paper. As shown in the figure is the version log of an SVN document warehouse. You can see that a new file has been added in version 95 and changed in versions 96, 104 and 105, but this file is unnecessary. To delete this file, all subsequent versions involving this file must also be recorded and deleted together, so this step must be careful!

3. Dump version warehouse

When using the dump command to dump the version warehouse, there are two important parameters. One is -- revision, which is used to set the version number to be dumped. Multiple consecutive versions can be separated by colons; The other is -- incremental, which is used to set the incremental format dump, that is, only dump the contents added in the current version. Enter the following two commands on the console:

# svnadmin dump Textbook -r 1:94 --incremental > Textbook_1-94.dump
# svnadmin dump Textbook -r 97:103 --incremental > Textbook_97-103.dump

The execution result of the command is as follows:

These two commands incrementally dump the contents of versions 1-94 and 97-103 respectively, and skip versions 95, 96, 104 and 105. These four versions are the historical versions that need to be deleted. Of course, the incremental dump of version 1 in the first command doesn't make much sense.

4. Create a new version warehouse

Use svnadmin's create command to create a new warehouse.

# svnadmin create Textbook

If you still want to use the original warehouse name, you can rename the old warehouse folder before creating a new warehouse.

5 restore warehouse dump file

Use the load command to restore the version warehouse. When in use, redirect the input of the previously dumped file. Enter the following two commands on the console:

# svnadmin load Textbook < Textbook_1-94.dump
# svnadmin load Textbook < Textbook_97-103.dump

These two commands must be entered in order, which is why the version number suffix is added after the two dump file names. The execution result of the last command is as follows:

# svnadmin load Textbook < Textbook_97-103.dump
<<< Started new transaction, based on original revision 97
     * editing path : C++??????/?13? ??????.docx ... done.

------- Committed new rev 95 (loaded from original rev 97) >>>

<<< Started new transaction, based on original revision 98
     * editing path : C++??????/?13? ??????.docx ... done.

------- Committed new rev 96 (loaded from original rev 98) >>>

<<< Started new transaction, based on original revision 99
     * editing path : C++??????/?13? ??????.docx ... done.

------- Committed new rev 97 (loaded from original rev 99) >>>

<<< Started new transaction, based on original revision 100
     * editing path : C++??????/??.docx ... done.

------- Committed new rev 98 (loaded from original rev 100) >>>

<<< Started new transaction, based on original revision 101
     * editing path : Python????/?7? ???????.docx ... done.

------- Committed new rev 99 (loaded from original rev 101) >>>

<<< Started new transaction, based on original revision 102
     * editing path : Python????/?7? ???????.docx ... done.

------- Committed new rev 100 (loaded from original rev 102) >>>

<<< Started new transaction, based on original revision 103
     * editing path : Python????/?7? ???????.docx ... done.

------- Committed new rev 101 (loaded from original rev 103) >>>

6 check out the new version warehouse

Back to the client, use TortoiseSVN to recheck out the new version warehouse.

For the SVN warehouse accessed using HTTP protocol, the HTTP server caches the SVN warehouse, so the check-out failure error may occur:

At this time, just restart the HTTP service. If you use the following command to restart the Apache server under FreeBSD

# service apache24 restart

After the restart is completed, it can be checked out successfully.

7 update log cache

Use the "show log" command of TortoiseSVN to display the log information of the new library. It is found that there are only 101 versions left of the original 105 versions, of which 4 versions have been completely cleared.

After careful checking, it is found that the 95 version seems to be the original content, and the version that has been cleared is still there. Is there something wrong? This is actually a disaster caused by caching. TortoiseSVN will cache all the contents in the central version library locally, so that you don't have to request data from the server every time.

Open the "settings" dialog box of TortoiseSVN and clear the log message in "Saved Data".

 

Then, select the URL of the warehouse in "Log Caching" and "Cached Repositories", click the "Update" button, connect to the remote warehouse and download the missing log data.

After clearing the cache, when you view the log again, everything is normal.

 

Keywords: Operation & Maintenance svn Operating System server freebsd

Added by moberemk on Sat, 05 Feb 2022 11:07:49 +0200