On 11/18/25 14:31, Daniel Sahlberg
wrote:
Den tis 18 nov. 2025 kl 22:02 skrev Orion Poplawski <[email protected]>:* xz support (available in python 3.3+)
* add --no-increment option to avoid incremented version backups
diff -u ./subversion-1.14.5/tools/backup/hot-backup.py.in.orig
./subversion-1.14.5/tools/backup/hot-backup.py.in
--- ./subversion-1.14.5/tools/backup/hot-backup.py.in.orig 2025-11-18
13:12:03.909124112 -0700
+++ ./subversion-1.14.5/tools/backup/hot-backup.py.in 2025-11-18
13:12:32.105055197 -0700
@@ -54,6 +54,7 @@
archive_map = {
'gz' : ".tar.gz",
'bz2' : ".tar.bz2",
+ 'xz' : ".tar.xz",
'zip' : ".zip",
'zip64' : ".zip"
}
@@ -104,8 +105,10 @@
--archive-type=FMT Create an archive of the backup. FMT can be one of:
bz2 : Creates a bzip2 compressed tar file.
gz : Creates a gzip compressed tar file.
+ xz : Creates a xz compressed tar file.
zip : Creates a compressed zip file.
zip64: Creates a zip64 file (can be > 2GB).
+ --no-increment Do not create an incremented backup version if the
revision already exists.
--num-backups=N Number of prior backups to keep around (0 to keep all).
--verify Verify the backup.
--help -h Print this help message and exit.
@@ -115,6 +118,7 @@
try:
opts, args = getopt.gnu_getopt(sys.argv[1:], "h?", ["archive-type=",
+ "no-increment",
"num-backups=",
"verify",
"help"])
@@ -125,11 +129,14 @@
sys.exit(2)
archive_type = None
+no_increment = False
verify_copy = False
for o, a in opts:
if o == "--archive-type":
archive_type = a
+ elif o == "--no-increment":
+ no_increment = True
elif o == "--num-backups":
num_backups = int(a)
elif o == "--verify":
@@ -138,7 +145,7 @@
usage()
sys.exit()
-if archive_type not in (None, 'bz2', 'gz', 'zip', 'zip64'):
+if archive_type not in (None, 'bz2', 'gz', 'xz', 'zip', 'zip64'):
sys.stderr.write("ERROR: Bad --archive-type\n")
usage(sys.stderr)
sys.exit(2)
@@ -256,6 +263,10 @@
directory_list = os.listdir(backup_dir)
young_list = [x for x in directory_list if regexp.search(x)]
if young_list:
+ if no_increment:
+ print(f"Backup of revision {youngest} already exists, not doing
incremented backup.")
+ sys.exit(0)
+
young_list.sort(key = functools.cmp_to_key(comparator))
increment = regexp.search(young_list.pop()).groupdict()['increment']
if increment:
@@ -294,7 +305,7 @@
err_msg = ""
print("Archiving backup to '" + archive_path + "'...")
- if archive_type == 'gz' or archive_type == 'bz2':
+ if archive_type in ('gz', 'bz2', 'xz'):
try:
import tarfile
tar = tarfile.open(archive_path, 'w:' + archive_type)
PS - not subscribed so please cc me in replies.
FYI - zstd is in Python 3.14.
--
Orion Poplawski
he/him/his - surely the least important thing about me
Manager of IT Systems 720-772-5637
NWRA, Boulder Office FAX: 303-415-9702
3380 Mitchell Lane [email protected]
Boulder, CO 80301 https://www.nwra.com/
Hi,
Thanks for your contribution! I just took a cursory look but it looks good to me. Not tested yet though.
Do I understand correctly that support for xz only exists in Python 3.14? In that case, may I suggest that the xz option is only added if Python version is at least 3.14?
Cheers,Daniel
No, xz was added in 3.3 so I think it's safe without a conditional. zstd was added in 3.14. It would be good to support it - but I'm not sure the best way to do it.
Orion
-- Orion Poplawski he/him/his - surely the least important thing about me Manager of IT Systems 720-772-5637 NWRA, Boulder Office FAX: 303-415-9702 3380 Mitchell Lane [email protected] Boulder, CO 80301 https://www.nwra.com/
smime.p7s
Description: S/MIME Cryptographic Signature

