def run(self): RepositoryRevisionCommand.run(self) rev = self.rev root_path = format_dir(self.root_path) root_type = self.root_type assert root_type in ('tag', 'trunk', 'branch') rc0 = self.r0_revprop_conf self.ensure_readonly() if not rc0.get('root_hints'): rc0.root_hints = {} if not rc0['root_hints'].get(rev): rc0['root_hints'][rev] = {} hints = rc0['root_hints'][rev] if root_path in hints: msg = "hint already exists for %s@%d" % (root_path, rev) raise CommandError(msg) from evn.change import ChangeSet opts = Options() cs = ChangeSet(self.path, self.rev, opts) cs.load() import svn.fs from svn.core import ( svn_node_dir, svn_node_file, svn_node_none, svn_node_unknown, ) svn_root = cs._get_root(rev) node_kind = svn.fs.check_path(svn_root, root_path, self.pool) if node_kind == svn_node_none: msg = "no such path %s in revision %d" raise CommandError(msg % (root_path, rev)) elif node_kind == svn_node_unknown: msg = "unexpected node type 'unknown' for path %s in revision %d" raise CommandError(msg % (root_path, rev)) elif node_kind == svn_node_file: msg = "path %s was a file in revision %d, not a directory" raise CommandError(msg % (root_path, rev)) else: assert node_kind == svn_node_dir, node_kind change = cs.get_change_for_path(root_path) if not change: msg = ( "path %s already existed in revision %d; specify the revision " "it was created in when adding a root hint (tip: try running " "`svn log --stop-on-copy --limit 1 %s%s@%d` to get the " "correct revision to use)" % ( root_path, rev, self.uri, root_path, rev, ) ) raise CommandError(msg) if change.is_remove or change.is_modify: msg = ( "path %s wasn't created in revision %d; you need to specify " "the revision it was created in when adding a root hint " "(tip: try running `svn log --stop-on-copy --limit 1 %s%s@%d`" " to get the correct revision to use)" % ( root_path, rev, self.uri, root_path, rev, ) ) raise CommandError(msg) hints[root_path] = root_type repo_name = self.conf.repo_name msg = 'Added root hint for %s@%d to %s.' % (root_path, rev, repo_name) self._out(msg) last_rev = rev-1 if rc0.last_rev <= last_rev: msg = ( 'evn:last_rev (%d) is already set less than or equal to the ' 'new would-be evn:last_rev (%d) based on the revision used ' 'for this root hint (%d); run `evnadmin analyze %s` when ' 'ready to restart analysis from revision %d.' % ( rc0.last_rev, last_rev, rev, repo_name, rc0.last_rev, ) ) else: rc0.last_rev = last_rev msg = ( 'evn:last_rev has been reset from %d to %d; ' 'run `evnadmin analyze %s` when ready to ' 'restart analysis from revision %d.' % ( rev, last_rev, repo_name, last_rev, ) ) self._out(msg)