def run(self): RepositoryCommand.run(self) self.__init_rev_or_txn() self.result = ChangeSet(**self.changeset_kwds) self.result.load()
def _find_merges(self): CSC = ChangeSetCommand revs = (self._start_rev, self._end_rev+1) for i in xrange(*revs): with Pool() as pool: k = CSC.get_changeset_kwds_for_rev_or_txn(self, i, pool) with ChangeSet(**k) as cs: cs.load() yield (i, cs.has_merges)
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()
class ChangeSetCommand(RepositoryCommand): rev_or_txn = None @property def changeset_kwds(self): k = ChangeSetCommand.get_changeset_kwds(self) k.fs = self.fs #k.pool = self.pool k.root = self.root return k @classmethod def get_changeset_kwds(cls, obj): k = Dict() k.conf = obj.conf k.estream = obj.estream k.ostream = obj.ostream k.istream = obj.istream k.options = obj.options return k @classmethod def get_root_for_rev_or_txn(cls, fs, rev_or_txn, pool): try: rev = int(rev_or_txn) is_rev = True assert rev >= 0 except: assert isinstance(rev_or_txn, str) is_rev = False txn_name = rev_or_txn txn = svn.fs.open_txn(fs, txn_name, pool) if is_rev: root = svn.fs.revision_root(fs, rev, pool) else: root = svn.fs.txn_root(txn, pool) return root @classmethod def get_changeset_kwds_for_rev_or_txn(cls, obj, rev_or_txn, pool): k = Dict() k.fs = obj.fs #k.pool = pool k.conf = obj.conf k.estream = obj.estream k.ostream = obj.ostream k.istream = obj.istream k.options = obj.options #args = (k.fs, rev_or_txn, pool) args = (k.fs, rev_or_txn) k.root = ChangeSetCommand.get_root_for_rev_or_txn(*args) return k @requires_context def __init_rev_or_txn(self): assert self.rev_or_txn is not None #p = self.pool try: self.rev = int(self.rev_or_txn) self.is_rev = True assert self.rev >= 0 except: assert isinstance(self.rev_or_txn, str) self.is_rev = False self.txn_name = self.rev_or_txn #self.txn = svn.fs.open_txn(self.fs, self.txn_name, p) self.txn = svn.fs.open_txn(self.fs, self.txn_name) if self.is_rev: #self.root = svn.fs.revision_root(self.fs, self.rev, p) self.root = svn.fs.revision_root(self.fs, self.rev) else: #self.root = svn.fs.txn_root(self.txn, p) self.root = svn.fs.txn_root(self.txn) @requires_context def run(self): RepositoryCommand.run(self) self.__init_rev_or_txn() self.result = ChangeSet(**self.changeset_kwds) self.result.load() #with ChangeSet(**self.changeset_kwds) as cs: # cs.load() # self.result = cs @classmethod def get_changeset(cls, path, rev_or_txn, **kwds): k = DecayDict(**kwds) estream = k.get('estream', sys.stderr) ostream = k.get('ostream', sys.stdout) istream = k.get('istream', sys.stdout) c = ChangeSetCommand(ostream, estream) c.path = path c.conf = k.get('conf', Config()) c.options = k.get('options', Options()) c.rev_or_txn = rev_or_txn k.assert_empty(cls) with c: c.run() return c.result
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)