def run(self): RepositoryRevisionCommand.run(self) fs = self.fs revproplist = svn.fs.revision_proplist d = revproplist(fs, self.rev) # Sample output: # ipdb> svn.fs.revision_proplist(self.fs, 0) # {'evn:version': '1', 'evn:component_depth': '0', 'evn:last_rev': '1', 'svn:date': '2015-03-23T20:36:45.498093Z'} # # ipdb> svn.fs.revision_proplist(self.fs, 1) # {'svn:log': '"Initializing repository."', 'evn:roots': "{'/trunk/': {'copies': {}, 'created': 1, 'creation_method': 'created'}}", 'svn:author': 'Trent', 'svn:date': '2015-03-23T20:36:45.522838Z'} r = {} for (key, value) in d.items(): ix = key.find(':') try: v = literal_eval(value) except: v = value if ix != -1: prefix = key[:ix] suffix = key[ix+1:] if prefix not in r: r[prefix] = {} r[prefix][suffix] = v else: r[key] = v m = "Showing revision properties for repository '%s' at r%d:" self._out(m % (self.name, self.rev)) pprint.pprint(r, self.ostream)
def run_old(self): RepositoryRevisionCommand.run(self) if not self.yield_values: m = "Finding merges between revisions %d:%d..." self._err(m % (self._start_rev, self._end_rev)) for (i, has_merges) in self: if has_merges: self.ostream.write('%d%s' % (i, os.linesep)) self._err('%d: merge' % i) self._flush() elif self._verbose: self._err('%d' % i) self._flush()
def run(self): RepositoryRevisionCommand.run(self) if self.rev == self.last_rev and self.rev < self.youngest_rev: m = ("Note: last analyzed revision of repository '%s' (r%d) lags " "behind HEAD (r%d).") self._out(m % (self.name, self.last_rev, self.youngest_rev)) k = dict(fs=self.fs, rev=self.rev, conf=self.conf) rc = RepositoryRevisionConfig(**k) roots = rc.roots if roots is None: m = "Repository '%s' has no roots defined at r%d." self._out(m % (self.name, self.rev)) else: m = "Showing roots for repository '%s' at r%d:" self._out(m % (self.name, self.rev)) pprint.pprint(roots, self.ostream)
def run(self): RepositoryRevisionCommand.run(self) if self.rev == self.last_rev and self.rev < self.youngest_rev: m = ( "Note: last analyzed revision of repository '%s' (r%d) lags " "behind HEAD (r%d)." ) self._out(m % (self.name, self.last_rev, self.youngest_rev)) k = dict(fs=self.fs, rev=self.rev, conf=self.conf) rc = RepositoryRevisionConfig(**k) roots = rc.roots if roots is None: m = "Repository '%s' has no roots defined at r%d." self._out(m % (self.name, self.rev)) else: m = "Showing roots for repository '%s' at r%d:" self._out(m % (self.name, self.rev)) pprint.pprint(roots, self.ostream)
def run(self): RepositoryRevisionCommand.run(self) CSC = ChangeSetCommand if not self.yield_values: m = "Finding merges between revisions %d:%d..." self._err(m % (self._start_rev, self._end_rev)) revs = (self._start_rev, self._end_rev+1) for i in xrange(*revs): with Pool(self.pool) as pool: k = CSC.get_changeset_kwds_for_rev_or_txn(self, i, pool) with ChangeSet(**k) as cs: cs.load() if cs.has_merges: self.ostream.write('%d%s' % (i, os.linesep)) self._err('%d: merge' % i) elif self._verbose: self._err('%d' % i) self._flush()
def run(self): RepositoryRevisionCommand.run(self) root_path = format_dir(self.root_path) rev = self.rev rc0 = self.r0_revprop_conf if not rc0.get('root_hints'): raise CommandError("no such root hint: %s" % root_path) hints = rc0['root_hints'].get(rev) if not hints: msg = "no such root hint at r%d: %s" % (rev, root_path) raise CommandError(msg) if root_path not in hints: msg = "no such root hint at r%d: %s" % (rev, root_path) raise CommandError(msg) del hints[root_path] msg = "Removed root hint %r for r%d from %s." repo_name = self.conf.repo_name self._out(msg % (hint, rev, repo_name))
def run(self): RepositoryRevisionCommand.run(self) assert self.root_path and isinstance(self.root_path, str) p = format_dir(self.root_path) k = dict(fs=self.fs, rev=self.rev, conf=self.conf) rc = RepositoryRevisionConfig(**k) roots = rc.roots if not roots: m = "Repository '%s' has no roots defined at r%d" self._out(m % (self.name, self.rev)) return root = roots.get(p) if not root: m = "No root named '%s' is present in repository '%s' at r%d." self._out(m % (p, self.name, self.rev)) return created = root['created'] m = "Found root '%s' in repository '%s' at r%d (created at r%d)." self._verbose(m % (p, self.name, self.rev, created)) k = dict(fs=self.fs, rev=created, conf=self.conf) rc = RepositoryRevisionConfig(**k) roots = rc.roots assert roots root = roots[p] assert root m = "Displaying root info for '%s' from r%d:" self._verbose(m % (p, created)) d = { p : root } if self.options.json: import json json.dump(d, self.ostream, sort_keys=True, indent=4) return buf = StringIO.StringIO() w = buf.write w("'%s': {\n" % p) if root['copies']: w(" 'copies': {\n") copies = pprint.pformat(root['copies']) indent = ' ' * 8 w(indent) w(copies[1:-1].replace('\n', '\n' + indent)) w("\n },\n") else: w(" 'copies': { },\n") for (k, v) in root.items(): if k == 'copies': continue w(" '%s': %s,\n" % (k, pprint.pformat(v))) w("}\n") buf.seek(0) self.ostream.write(buf.read())
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)