SVN: set properties for directories only

In SVN, is there a way to set (bugtraq) properties on all directories in a tree without checking the whole tree?

I cannot set properties in the repository directly without setting intercepts. Even if I'm not sure if this will help, you cannot set recursive properties using Tortoise, and I suspect that it would not be easy with the command line client.

There are rare checks, but if I set the depth empty for each directory, then setting the properties recursively will not work, even if I manually check each subdirectory.

I could check the entire repository and use Tortoise to recursively define bugtraq properties in directories (they do not apply to files by default). But this will require me to check the entire repository just for this.

Is there a better way to do this that I am missing?

Edit:

I tried to check the entire repository and change the properties in the root, but the commit violated our commit hook: it is impossible to change the properties in the tags. Without removing the hook, it seems I will need to manually change the properties (on everything except the tags).

+3
source share
2 answers

Getting a list of all directories can be a good first step. Here is one way to do this without checking anything:

-, .

, :

svn propset myprop myvalue --targets just_directories.txt

, , . (https://myrepository.com/svn/path/to/root/directory) svn propset myprop mypropvalue - just_directories.txt, error: svn: https://myrepository.com/svn/path/to/root/directory/subdir1 ' . , .

+4

script, , pysvn ( ). , - .

import sys
import os
from optparse import OptionParser
import pysvn
import re

usage = """%prog [path] property-name property-value

Set property-name to property-value on all non-tag subdirectories in an svn working copy.

path is an optional argument and defaults to "."
"""

class Usage(Exception):
    def __init__(self, msg):
        self.msg = msg

def main():
    try:
        parser = OptionParser(usage)
        (options, args) = parser.parse_args()

        if len(args) < 2:
            raise Usage("Must specify property-name and property-value")
        elif len(args) == 2:
            directory = "."
            property_name = args[0]
            property_value = args[1]
        elif len(args) == 3:
            directory = args[0]
            property_name = args[1]
            property_value = args[2]
        elif len(args) > 3:
            raise Usage("Too many arguments specified")

        print "Setting property %s to %s for non-tag subdirectories of %s" % (property_name, property_value, directory)

        client = pysvn.Client()
        for path_info in client.info2(directory):
            path = path_info[0]
            if path_info[1]["kind"] != pysvn.node_kind.dir:
                #print "Ignoring file directory: %s" % path
                continue
            remote_path = path_info[1]["URL"]
            if not re.search('(?i)(\/tags$)|(\/tags\/)', remote_path):
                print "%s" % path
                client.propset(property_name, property_value, path, depth=pysvn.depth.empty)
            else:
                print "Ignoring tag directory: %s" % path
    except Usage, err:
        parser.error(err.msg)
        return 2


if __name__ == "__main__":
    sys.exit(main())
+4

Source: https://habr.com/ru/post/1712870/


All Articles