You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2012/10/21 04:00:47 UTC

svn commit: r1400556 [3/29] - in /subversion/branches/ev2-export: ./ build/ build/ac-macros/ build/generator/ build/generator/templates/ build/hudson/ contrib/client-side/emacs/ contrib/client-side/svn-push/ contrib/client-side/svnmerge/ contrib/hook-s...

Modified: subversion/branches/ev2-export/notes/directory-index/dirindex.py
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/notes/directory-index/dirindex.py?rev=1400556&r1=1400555&r2=1400556&view=diff
==============================================================================
--- subversion/branches/ev2-export/notes/directory-index/dirindex.py (original)
+++ subversion/branches/ev2-export/notes/directory-index/dirindex.py Sun Oct 21 02:00:31 2012
@@ -15,44 +15,48 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import division, with_statement
 
-import collections
 import datetime
 import logging
+import re
 import sqlite3
+import unicodedata
 
 
 class Error(Exception):
     def __init__(self, msg, *args, **kwargs):
-        opcode = kwargs.pop("action", None)
-        if opcode is not None:
-            msg = Dirent._opname(opcode) + msg
+        action = kwargs.pop("action", None)
+        if action is not None:
+            msg = "%s %s" % (NodeRev._opname(action), msg)
         super(Error, self).__init__(msg, *args, **kwargs)
 
 
-class SQL(object):
+class SQLclass(object):
     """Named index of SQL schema definitions and statements.
 
     Parses "schema.sql" and creates a class-level attribute for each
     script and statement in that file.
     """
 
-    @classmethod
-    def _load_statements(cls):
+    def __init__(self):
         import cStringIO
         import pkgutil
-        import re
 
         comment_rx = re.compile(r"\s*--.*$")
-        header_rx = re.compile(r"^---(STATEMENT|SCRIPT)"
+        header_rx = re.compile(r"^---(?P<kind>STATEMENT|SCRIPT)"
                                r"\s+(?P<name>[_A-Z]+)$")
 
+        kind = None
         name = None
         content = None
 
         def record_current_statement():
             if name is not None:
-                setattr(cls, name, content.getvalue())
+                if kind == "SCRIPT":
+                    self.__record_script(name, content.getvalue())
+                else:
+                    self.__record_statement(name, content.getvalue())
 
         schema = cStringIO.StringIO(pkgutil.get_data(__name__, "schema.sql"))
         for line in schema:
@@ -63,6 +67,7 @@ class SQL(object):
             header = header_rx.match(line)
             if header:
                 record_current_statement()
+                kind = header.group("kind")
                 name = header.group("name")
                 content = cStringIO.StringIO()
                 continue
@@ -75,159 +80,511 @@ class SQL(object):
                 content.write(line)
                 content.write("\n")
         record_current_statement()
-SQL._load_statements()
 
+    class __statement(object):
+        __slots__ = ("execute", "query")
+        def __init__(self, sql, query):
+            self.execute = sql._execute
+            self.query = query
+
+        def __call__(self, cursor, **kwargs):
+            if len(kwargs):
+                return self.execute(cursor, self.query, kwargs)
+            return self.execute(cursor, self.query)
+
+    def __record_statement(self, name, statement):
+        setattr(self, name, self.__statement(self, statement))
+
+    class __script(object):
+        __slots__ = ("execute", "query")
+        def __init__(self, sql, query):
+            self.execute = sql._executescript
+            self.query = query
+
+        def __call__(self, cursor):
+            return self.execute(cursor, self.query)
+
+    def __record_script(self, name, script):
+        setattr(self, name, self.__script(self, script))
+
+    LOGLEVEL = (logging.NOTSET + logging.DEBUG) // 2
+    if logging.getLevelName(LOGLEVEL) == 'Level %s' % LOGLEVEL:
+        logging.addLevelName(LOGLEVEL, 'SQL')
+
+    def _log(self, *args, **kwargs):
+        return logging.log(self.LOGLEVEL, *args, **kwargs)
+
+    __stmt_param_rx = re.compile(r':([a-z]+)')
+    def _execute(self, cursor, statement, parameters=None):
+        if parameters is not None:
+            fmt = statement.replace("%", "%%")
+            fmt = self.__stmt_param_rx.sub(r'%(\1)r', fmt)
+            self._log("EXECUTE: " + fmt, parameters)
+            return cursor.execute(statement, parameters)
+        else:
+            self._log("EXECUTE: %s", statement)
+            return cursor.execute(statement)
+
+    def _executescript(self, cursor, script):
+        self._log("EXECUTE: %s", script)
+        return cursor.executescript(script)
+SQL = SQLclass()
 
-class SQLobject(object):
+
+class SQLobject(dict):
     """Base for ORM abstractions."""
 
-    __slots__ = ()
     def __init__(self, **kwargs):
-        for name, val in kwargs.items():
-            setattr(self, name, val)
-        for name in self.__slots__:
-            if not hasattr(self, name):
-                setattr(self, name, None)
-
-    def _put(self, cursor):
-        raise NotImplementedError("SQLobject._insert")
+        super(SQLobject, self).__init__(**kwargs)
+        for name in self._columns:
+            super(SQLobject, self).setdefault(name, None)
+
+    def __getattr__(self, name):
+        return self.__getitem__(name)
+
+    def __setattr__(self, name, value):
+        return self.__setitem__(name, value)
+
+    def __delattr__(self, name):
+        return self.__delitem__(name)
+
+    def _put(self, _cursor):
+        self._put_statement(_cursor, **self)
+        if self.id is None:
+            self.id = _cursor.lastrowid
+        else:
+            assert self.id == _cursor.lastrowid
 
     @classmethod
-    def _get(self, cursor, pkey):
-        raise NotImplementedError("SQLobject._insert")
+    def _get(self, _cursor, pkey):
+        self._get_statement(_cursor, id=pkey)
+        return cls._from_row(_cursor.fetchone())
 
     @classmethod
     def _from_row(cls, row):
         if row is not None:
-            return cls(**dict((col, row[col]) for col in row.keys()))
+            return cls(**row)
         return None
 
-    LOGLEVEL = (logging.NOTSET + logging.DEBUG) // 2
-    if logging.getLevelName(LOGLEVEL) == 'Level %s' % LOGLEVEL:
-        logging.addLevelName(LOGLEVEL, 'SQL')
+    def _clone(self):
+        return self.__class__(**self)
 
-    @classmethod
-    def _log(cls, *args, **kwargs):
-        return logging.log(cls.LOGLEVEL, *args, **kwargs)
 
-    @classmethod
-    def _execute(cls, cursor, statement, parameters=None):
-        if parameters is not None:
-            fmt = statement.replace("%", "%%").replace("?", "%r")
-            cls._log("EXECUTE: " + fmt, *parameters)
-            return cursor.execute(statement, parameters)
-        else:
-            cls._log("EXECUTE: %s", statement)
-            return cursor.execute(statement)
+class Txn(SQLobject):
+    """O/R mapping for the "txn" table."""
 
+    _columns = ("id", "treeid", "revision", "created", "author", "state")
+    _put_statement = SQL.TXN_INSERT
+    _get_statement = SQL.TXN_GET
 
-class Revent(SQLobject):
-    """O/R mapping for the "revision" table."""
+    # state
+    TRANSIENT = "T"
+    PERMANENT = "P"
+    DEAD = "D"
 
-    __slots__ = ("version", "created", "author", "log")
+    def __init__(self, **kwargs):
+        super(Txn, self).__init__(**kwargs)
+        if self.state is None:
+            self.state = self.TRANSIENT
 
-    def _put(self, cursor):
-        if self.created is None:
-            now = datetime.datetime.utcnow()
-            self.created = now.strftime("%Y-%m-%dT%H:%M:%S.%fZ")
-        self._execute(cursor, SQL.INSERT_REVISION_RECORD,
-                      [self.version, self.created, self.author, self.log])
+    def __str__(self):
+        return "%d/%d %c %s" % (self.revision, self.treeid,
+                                self.state, self.created)
 
-    @classmethod
-    def _get(cls, cursor, pkey):
-        cursor.execute(SQL.GET_REVENT_BY_VERSION, [pkey])
-        return cls._from_row(cursor.fetchone())
+    @property
+    def _committed(self):
+        return self.state == self.PERMANENT
 
+    @property
+    def _uncommitted(self):
+        return self.state == self.TRANSIENT
 
-class Strent(SQLobject):
-    """O/R mapping for the "strindex" table."""
+    @property
+    def _dead(self):
+        return self.state == self.DEAD
 
-    __slots__ = ("strid", "content")
+    @staticmethod
+    def _now():
+        now = datetime.datetime.utcnow()
+        return (now.strftime("%Y%m%dT%H%M%S.%%03dZ")
+                % ((now.microsecond + 500) // 1000))
 
     def _put(self, cursor):
-        self._execute(cursor, SQL.INSERT_STRINDEX_RECORD, [self.content])
-        self.strid = cursor.lastrowid
+        if self.created is None:
+            self.created = self._now()
+        super(Txn, self)._put(cursor)
+        if self.treeid is None:
+            self.treeid = self.id
 
     @classmethod
-    def _get(cls, cursor, pkey):
-        cls._execute(cursor, SQL.GET_STRENT_BY_STRID, [pkey])
+    def _find_newest(cls, cursor):
+        SQL.TXN_FIND_NEWEST(cursor)
         return cls._from_row(cursor.fetchone())
 
     @classmethod
-    def _find(cls, cursor, content):
-        cls._execute(cursor, SQL.GET_STRENT_BY_CONTENT, [content])
+    def _find_by_revision(cls, cursor, revision):
+        SQL.TXN_FIND_BY_REVISION(cursor, revision = revision)
         return cls._from_row(cursor.fetchone())
 
+    @classmethod
+    def _find_by_revision_timestamp(cls, cursor, revision, created):
+        SQL.TXN_FIND_BY_REVISION_AND_TIMESTAMP(
+            cursor, revision = revision, created = creted)
+        return cls._from_row(cursor.fetchone())
 
-class Dirent(SQLobject):
-    """O/R mapping for a virtual non-materialized view representing
-    a join of the "dirindex" and "strindex" tables."""
-
-    __slots__ = ("rowid", "origin", "pathid", "version",
-                 "kind", "opcode", "subtree",
-                 "abspath")
+    def _commit(self, cursor, revision):
+        assert self._uncommitted
+        now = self._now()
+        SQL.TXN_COMMIT(cursor, id = self.id,
+                       revision = revision, created = now)
+        self.revision = revision
+        self.created = now
+        self.state = self.PERMANENT
+
+    def _abort(self, cursor):
+        assert self._uncommitted
+        SQL.TXN_ABORT(cursor, id = self.id)
+        self.state = self.DEAD
+
+    def _cleanup(self, cursor):
+        assert self._dead
+        SQL.TXN_CLEANUP(cursor, id = self.id)
+
+
+class NodeRev(SQLobject):
+    """O/R mapping for the noderev/string/nodeview table."""
+
+    _columns = ("id", "treeid", "nodeid", "origin", "parent", "branch",
+                "nameid", "name", "denameid", "dename",
+                "kind", "opcode", "state")
+    _put_statement = SQL.NODEREV_INSERT
+    _get_statement = SQL.NODEVIEW_GET
 
-    # Kinds
+    # kind
     DIR = "D"
     FILE = "F"
 
-    # Opcodes
+    # opcode
     ADD = "A"
     REPLACE = "R"
     MODIFY = "M"
     DELETE = "D"
     RENAME = "N"
+    BRANCH = "B"
+    LAZY = "L"
+    BREPLACE = "X"
+    LAZY_BREPLACE = "Z"
+
+    # state
+    TRANSIENT = "T"
+    PERMANENT = "P"
+
+    def __init__(self, **kwargs):
+        super(NodeRev, self).__init__(**kwargs)
+        if self.state is None:
+            self.state = self.TRANSIENT
+
+    def __str__(self):
+        return "%d(%d) %c %s%s" % (self.id, self.treeid, self.opcode,
+                                   self.name, self._isdir and '/' or '')
 
     # Opcode names
     __opnames = {ADD: "add",
                  REPLACE: "replace",
                  MODIFY: "modify",
                  DELETE: "delete",
-                 RENAME: "rename"}
+                 RENAME: "rename",
+                 BRANCH: "branch",
+                 LAZY: "branch",
+                 BREPLACE: "branch/replace",
+                 LAZY_BREPLACE: "branch/replace"}
 
     @classmethod
-    def _opname(cls, opcode):
+    def _opname(cls, change):
         return cls.__opnames.get(opcode)
 
     @property
     def _deleted(self):
         return (self.opcode == self.DELETE)
 
-    def __str__(self):
-        return "%d %c%c%c %c %s" % (
-            self.version,
-            self.subtree and "(" or " ",
-            self.opcode,
-            self.subtree and ")" or " ",
-            self.kind, self.abspath)
+    @property
+    def _lazy(self):
+        return (self.opcode in (self.LAZY, self.LAZY_BREPLACE))
+
+    @property
+    def _transient(self):
+        return (self.state == self.TRANSIENT)
+
+    @property
+    def _isdir(self):
+        return (self.kind == self.DIR)
+
+    @staticmethod
+    def __stringid(cursor, val):
+        SQL.STRING_FIND(cursor, val = val)
+        row = cursor.fetchone()
+        if row is not None:
+            return row['id']
+        SQL.STRING_INSERT(cursor, val = val)
+        return cursor.lastrowid
 
     def _put(self, cursor):
-        strent = Strent._find(cursor, self.abspath)
-        if strent is None:
-            strent = Strent(content = self.abspath)
-            strent._put(cursor)
-        self._execute(cursor, SQL.INSERT_DIRINDEX_RECORD,
-                      [self.origin, strent.strid, self.version,
-                       self.kind, self.opcode,self.subtree])
-        self.rowid = cursor.lastrowid
-        self.pathid = strent.strid
+        if self.nameid is None:
+            assert self.name is not None
+            self.nameid = self.__stringid(cursor, self.name)
+        if self.denameid is None:
+            if self.dename == self.name:
+                self.denameid = self.nameid
+            else:
+                assert self.dename is not None
+                self.denameid = self.__stringid(cursor, self.dename)
+        super(NodeRev, self)._put(cursor)
+        if self.nodeid is None:
+            self.nodeid = self.id
+        if self.branch is None:
+            self.branch = self.id
 
     @classmethod
-    def _get(cls, cursor, pkey):
-        cls._execute(cursor, SQL.GET_DIRENT_BY_ROWID, [pkey])
-        return cls._from_row(cursor.fetchone())
+    def _update_treeid(cls, cursor, new_txn, old_txn):
+        SQL.NODEREV_UPDATE_TREEID(cursor,
+                                  new_treeid = new_txn.treeid,
+                                  old_treeid = old_txn.treeid)
+
+    def _delazify(self, cursor):
+        assert self._lazy and self._isdir
+        opcode = self.opcode == self.LAZY and self.BRANCH or self.BREPLACE
+        SQL.NODEREV_UPDATE_OPCODE(cursor, id = self.id, opcode = opcode)
+        self.opcode = opcode
+
+    @classmethod
+    def _commit(cls, cursor, txn):
+        SQL.NODEREV_COMMIT(cursor, treeid = txn.treeid)
 
     @classmethod
-    def _find(cls, cursor, abspath, version):
-        cls._execute(cursor,
-                     SQL.GET_DIRENT_BY_ABSPATH_AND_VERSION,
-                     [abspath, version])
+    def _cleanup(cls, cursor, txn):
+        SQL.NODEREV_CLEANUP(cursor, treeid = txn.treeid)
+
+    @classmethod
+    def __find(cls, cursor, parent, name, txn):
+        if txn.state != txn.PERMANENT:
+            if parent is None:
+                finder = SQL.NODEVIEW_FIND_TRANSIENT_ROOT
+            else:
+                finder = SQL.NODEVIEW_FIND_TRANSIENT_BY_NAME
+        else:
+            if parent is None:
+                finder = SQL.NODEVIEW_FIND_ROOT
+            else:
+                finder = SQL.NODEVIEW_FIND_BY_NAME
+        finder(cursor, name = name, parent = parent, treeid = txn.treeid)
         return cls._from_row(cursor.fetchone())
 
+    @classmethod
+    def _find(cls, cursor, parent, name, txn):
+        return cls.__find(cursor, parent, cls.__normtext(name), txn)
+
+    @classmethod
+    def _commonprefix(cls, *args):
+        args = [arg.split('/') for arg in args]
+        prefix = []
+        arglen = min(len(parts) for parts in args)
+        while arglen > 0:
+            same = set(cls.__normtext(parts[0]) for parts in args)
+            if len(same) > 1:
+                break
+            for parts in args:
+                del parts[0]
+            prefix.append(same.pop())
+            arglen -= 1
+        return '/'.join(prefix), ['/'.join(parts) for parts in args]
+
+    @classmethod
+    def _lookup(cls, cursor, track, relpath, txn):
+        if track is None or track.path is None:
+            # Lookup from root
+            track = Track()
+            parent = cls.__find(cursor, None, "", txn)
+            if not relpath:
+                track.close(parent)
+                return track
+            track.append(parent)
+        else:
+            assert track.found
+            track = Track(track)
+            if not relpath:
+                track.close()
+                return track
+            parent = track.noderev
+        parts = cls.__normtext(relpath).split("/")
+        for name in parts[:-1]:
+            if not parent._isdir:
+                raise Error("ENOTDIR: " + track.path)
+            while parent._lazy:
+                parent = cls._get(cursor, id = parent.origin)
+            node = cls.__find(cursor, parent.branch, name, txn)
+            if node is None:
+                raise Error("ENODIR: " +  track.path + '/' + name)
+            parent = node
+            track.append(parent)
+        while parent._lazy:
+            parent = cls._get(cursor, id = parent.origin)
+        track.close(cls.__find(cursor, parent.branch, parts[-1], txn))
+        return track
+
+    def _listdir(self, cursor, txn):
+        assert self._isdir
+        if txn.state != txn.PERMANENT:
+            lister = SQL.NODEVIEW_LIST_TRANSIENT_DIRECTORY
+        else:
+            lister = SQL.NODEVIEW_LIST_DIRECTORY
+        lister(cursor, parent = self.id, treeid = txn.treeid)
+        for row in cursor:
+            yield self._from_row(row)
+
+    def _bubbledown(self, cursor, txn):
+        assert txn._uncommitted
+        assert self._lazy and self._isdir and self.origin is not None
+        originmap = dict()
+        origin = self
+        while origin._lazy:
+            origin = self._get(cursor, id = origin.origin)
+        for node in origin._listdir(cursor, txn):
+            newnode = node._branch(cursor, self, txn)
+            originmap[newnode.origin] == newnode
+        self._delazify(cursor)
+        return originmap
+
+    def _branch(self, cursor, parent, txn, replaced=False):
+        assert txn._uncommitted
+        if self._isdir:
+            opcode = replaced and self.LAZY_BREPLACE or self.LAZY
+        else:
+            opcode = replaced and self.BREPLACE or self.BRANCH
+        node = self._revise(opcode, txn)
+        node.parent = parent.id
+        node.branch = None
+        node._put(cursor)
+        return node
+
+    def _revise(self, opcode, txn):
+        assert txn._uncommitted
+        noderev = NodeRev._clone(self)
+        noderev.treeid = txn.treeid
+        noderev.origin = self.id
+        noderev.opcode = opcode
+        return noderev
+
+    __readonly = frozenset(("name",))
+    def __setitem__(self, key, value):
+        if key in self.__readonly:
+            raise Error("NodeRev.%s is read-only" % key)
+        if key == "dename":
+            name = self.__normtext(value)
+            value = self.__text(value)
+            if name != self.name:
+                super(NodeRev, self).__setitem__("name", name)
+                super(NodeRev, self).__setitem__("nameid", None)
+            super(NodeRev, self).__setitem__("denameid", None)
+        super(NodeRev, self).__setitem__(key, value)
+
+    def __getitem__(self, key):
+        if key == "dename":
+            dename = super(NodeRev, self).__getitem__(key)
+            if dename is not None:
+                return dename
+            key = "name"
+        return super(NodeRev, self).__getitem__(key)
+
+    @classmethod
+    def __text(cls, name):
+        if not isinstance(name, unicode):
+            return name.decode("UTF-8")
+        return name
+
+    @classmethod
+    def __normtext(cls, name):
+        return unicodedata.normalize('NFC', cls.__text(name))
+
+
+class Track(object):
+    __slots__ = ("nodelist", "noderev", "lazy")
+    def __init__(self, other=None):
+        if other is None:
+            self.nodelist = list()
+            self.noderev = None
+            self.lazy = None
+        else:
+            self.nodelist = list(other.nodelist)
+            self.noderev = other.noderev
+            self.lazy = other.lazy
+
+    def __str__(self):
+        return "%c%c %r" % (
+            self.found and self.noderev.kind or '-',
+            self.lazy is not None and 'L' or '-',
+            self.path)
+
+    @property
+    def found(self):
+        return (self.noderev is not None)
+
+    @property
+    def parent(self):
+        if self.noderev is not None:
+            index = len(self.nodelist) - 2;
+        else:
+            index = len(self.nodelist) - 1;
+        if index >= 0:
+            return self.nodelist[index]
+        return None
+
+    @property
+    def path(self):
+        if len(self.nodelist):
+            return '/'.join(n.name for n in self.nodelist[1:])
+        return None
+
+    @property
+    def open(self):
+        return not isinstance(self.nodelust, tuple)
+
+    def append(self, noderev):
+        if self.lazy is None and noderev._lazy:
+            self.lazy = len(self.nodelist)
+        self.nodelist.append(noderev)
+
+    def close(self, noderev=None):
+        if noderev is not None:
+            self.append(noderev)
+            self.noderev = noderev
+        self.nodelist = tuple(self.nodelist)
+
+    def bubbledown(self, cursor, txn):
+        if self.lazy is None:
+            return
+        closed = not self.open
+        if closed:
+            self.nodelist = list(self.nodelist)
+        tracklen = len(self.nodelist)
+        index = self.lazy
+        node = self.nodelist[index]
+        originmap = node._bubbledown(cursor, txn)
+        while index < tracklen:
+            node = originmap[self.nodelist[index].id]
+            self.nodelist[index] = node
+            if node._isdir:
+                originmap = node._bubbledown(cursor, txn)
+            else:
+                originmap = None
+            index += 1
+        self.lazy = None
+        if closed:
+            self.close()
+
 
 class Index(object):
     def __init__(self, database):
-        self.conn = sqlite3.connect(database, isolation_level = "IMMEDIATE")
+        self.conn = sqlite3.connect(database, isolation_level = "DEFERRED")
         self.conn.row_factory = sqlite3.Row
         self.cursor = self.conn.cursor()
         self.cursor.execute("PRAGMA page_size = 4096")
@@ -236,337 +593,226 @@ class Index(object):
         self.cursor.execute("PRAGMA case_sensitive_like = ON")
         self.cursor.execute("PRAGMA encoding = 'UTF-8'")
 
-    @staticmethod
-    def normpath(abspath):
-        return abspath.rstrip("/")
-
-    @staticmethod
-    def subtree_pattern(abspath):
-        return (abspath.rstrip("/")
-                .replace("#", "##")
-                .replace("%", "#%")
-                .replace("_", "#_")) + "/%"
-
     def initialize(self):
         try:
-            SQLobject._log("%s", SQL.CREATE_SCHEMA)
-            self.cursor.executescript(SQL.CREATE_SCHEMA)
+            SQL.CREATE_SCHEMA(self.cursor)
+            SQL._execute(
+                self.cursor,
+                "UPDATE txn SET created = :created WHERE id = 0",
+                {"created": Txn._now()})
             self.commit()
-        finally:
+        except:
             self.rollback()
+            raise
+
+    def begin(self):
+        SQL._execute(self.cursor, "BEGIN")
 
     def commit(self):
-        SQLobject._log("COMMIT")
-        return self.conn.commit()
+        SQL._log("COMMIT")
+        self.conn.commit()
 
     def rollback(self):
-        SQLobject._log("ROLLBACK")
-        return self.conn.rollback()
+        SQL._log("ROLLBACK")
+        self.conn.rollback()
 
     def close(self):
         self.rollback()
-        SQLobject._log("CLOSE")
-        return self.conn.close()
+        SQL._log("CLOSE")
+        self.conn.close()
 
-    def get_revision(self, version):
-        return Revent._get(self.cursor, version)
+    def get_txn(self, revision=None):
+        if revision is None:
+            return Txn._find_newest(self.cursor)
+        return Txn._find_by_revision(self.cursor, revision)
+
+    def new_txn(self, revision, created=None, author=None, base_txn = None):
+        assert base_txn is None or base_txn.revision == revision
+        txn = Txn(revision = revision, created = created, author = author,
+                  treeid = base_txn is not None and base_txn.treeid or None)
+        txn._put(self.cursor)
+        return txn
+
+    def commit_txn(self, txn, revision):
+        txn._commit(self.cursor, revision)
+        NodeRev._commit(self.cursor, txn)
+
+    def abort_txn(self, txn):
+        txn._abort(self.cursor)
+        NodeRev._cleanup(self.cursor, txn)
+        txn._cleanup(self.cursor)
+
+    def listdir(self, txn, noderev):
+        # FIXME: Query seems OK but no results returned?
+        return noderev._listdir(self.conn.cursor(), txn)
+
+    def lookup(self, txn, track=None, relpath=""):
+        return NodeRev._lookup(self.cursor, track, relpath, txn)
+
+    def __add(self, txn, track, name, kind, opcode, origintrack=None):
+        assert kind in (NodeRev.FILE, NodeRev.DIR)
+        assert opcode in (NodeRev.ADD, NodeRev.REPLACE)
+        if not txn._uncommitted:
+            raise Error("EREADONLY: txn " + str(txn))
+        if not track.found:
+            raise Error("ENOENT: " +  track.path)
+        if not track.noderev._isdir:
+            raise Error("ENOTDIR: " +  track.path)
+
+        parent = track.noderev
+        oldnode = NodeRev._find(self.cursor, parent.id, name, txn)
+        if opcode == NodeRev.ADD and oldnode is not None:
+            raise Error("EEXIST: " +  track.path + '/' + name)
+
+        if origintrack is not None:
+            # Treat add as copy
+            if not origintrack.found:
+                raise Error("ENOENT: (origin) " +  origintrack.path)
+            origin = origintrack.noderev
+            if origin.kind != kind:
+                raise Error("ENOTSAME: origin %c -> copy %c"
+                            % (origin.kind, kind))
+            ### Rename detection heuristics here ...
+            rename = False
+        else:
+            origin = None
+            rename = False
 
-    def new_revision(self, version, created=None, author=None, log=None):
-        revent = Revent(version = version,
-                        created = created,
-                        author = author,
-                        log = log)
-        revent._put(self.cursor)
-        return revent
-
-    def insert(self, dirent):
-        assert isinstance(dirent, Dirent)
-        dirent._put(self.cursor)
-        return dirent
-
-    def lookup(self, abspath, version):
-        SQLobject._execute(
-            self.cursor,
-            SQL.LOOKUP_ABSPATH_AT_REVISION,
-            [abspath, version])
-        row = self.cursor.fetchone()
-        if row is not None:
-            dirent = Dirent._from_row(row)
-            if not dirent._deleted:
-                return dirent
-        return None
+        if rename:
+            raise NotImplementedError("Rename detection heuristics")
+
+        track = Track(track)
+        track.bubbledown(self.cursor, txn)
+        if oldnode:
+            if parent.id != track.noderev.id:
+                # Bubbledown changed the track
+                parent = track.noderev
+                oldnode = NodeRev._find(self.cursor, parent.id, name, txn)
+                assert oldnode is not None
+            tombstone = oldnode._revise(oldnode.DELETE, txn)
+            tombstone.parent = parent.id
+            tombstone._put(self.cursor)
+        parent = track.noderev
+        if origin is not None:
+            newnode = origin._branch(self.cursor, parent.id, txn,
+                                     replaced = (oldnode is not None))
+        else:
+            newnode = NodeRev(treeid = txn.treeid,
+                              nodeid = None,
+                              branch = None,
+                              parent = parent.id,
+                              kind = kind,
+                              opcode = opcode)
+            newnode.dename = name
+            newnode._put(self.cursor)
+        track.close(newnode)
+        return track
+
+    def add(self, txn, track, name, kind, origintrack=None):
+        return self.__add(txn, track, name, kind, NodeRev.ADD, origintrack)
+
+    def replace(self, txn, track, name, kind, origintrack=None):
+        return self.__add(txn, track, name, kind, NodeRev.REPLACE, origintrack)
+
+#    def modify(self, txn, track):
+#        if not txn._uncommitted
+#            raise Error("EREADONLY: txn " + str(txn))
+#        if not track.found:
+#            raise Error("ENOENT: " +  track.path)
 
-    def subtree(self, abspath, version):
-        SQLobject._execute(
-            self.cursor,
-            SQL.LIST_SUBTREE_AT_REVISION,
-            [version, self.subtree_pattern(abspath)])
-        for row in self.cursor:
-            yield Dirent._from_row(row)
-
-    def predecessor(self, dirent):
-        assert isinstance(dirent, Dirent)
-        if dirent.origin is None:
-            return None
-        return Dirent._get(self.cursor, dirent.origin)
-
-    def successors(self, dirent):
-        assert isinstance(dirent, Dirent)
-        SQLobject._execute(
-            self.cursor,
-            SQL.LIST_DIRENT_SUCCESSORS,
-            [dirent.rowid])
-        for row in self.cursor:
-            yield Dirent._from_row(row)
-
-
-class Revision(object):
-    def __init__(self, index, version,
-                 created=None, author=None, log=None):
+
+
+class Tree(object):
+    def __init__(self, index):
         self.index = index
-        self.version = version
-        self.revent = index.get_revision(version)
-        self.__created = created
-        self.__author = author
-        self.__log = log
-        self.__context = None
+        self.context = None
         index.rollback()
 
-    class __Context(object):
-        def __init__(self, version, connection):
-            self.version = version
-            self.conn = connection
-            self.cursor = connection.cursor()
-            SQLobject._execute(self.cursor, SQL.CREATE_TRANSACTION_CONTEXT)
-
-        def clear(self):
-            SQLobject._execute(self.cursor, SQL.REMOVE_TRANSACTION_CONTEXT)
-
-        def __iter__(self):
-            SQLobject._execute(self.cursor, SQL.LIST_TRANSACTION_RECORDS)
-            for row in self.cursor:
-                dirent = Dirent._from_row(row)
-                dirent.version = self.version
-                yield dirent
-
-        def lookup(self, abspath):
-            SQLobject._execute(self.cursor,
-                               SQL.GET_TRANSACTION_RECORD,
-                               [abspath])
-            row = self.cursor.fetchone()
-            if row is not None:
-                dirent = Dirent._from_row(row)
-                dirent.version = self.version
-                return dirent
-            return None
-
-        def remove(self, abspath, purge=False):
-            target = self.lookup(abspath)
-            if not target:
-                raise Error("txn context: remove nonexistent " + abspath)
-            logging.debug("txn context: remove %s", abspath)
-            SQLobject._execute(self.cursor,
-                               SQL.REMOVE_TRANSACTION_RECORD,
-                               [abspath])
-            if purge:
-                logging.debug("txn context: purge %s/*", abspath)
-                SQLobject._execute(self.cursor,
-                                   SQL.REMOVE_TRANSACTION_SUBTREE,
-                                   [Index.subtree_pattern(abspath)])
-
-        def record(self, dirent, replace=False, purge=False):
-            target = self.lookup(dirent.abspath)
-            if target is not None:
-                if not replace:
-                    raise Error("txn context: record existing "
-                                + dirent.abspath)
-                elif not target.subtree:
-                    raise Error("txn context: replace conflict "
-                                + dirent.abspath)
-                self.remove(target.abspath, purge and target.kind == Dirent.DIR)
-            SQLobject._execute(self.cursor,
-                               SQL.INSERT_TRANSACTION_RECORD,
-                               [dirent.origin, dirent.abspath,
-                                dirent.kind, dirent.opcode, dirent.subtree])
-
-    def __enter__(self):
-        if self.revent is not None:
-            raise Error("revision is read-only")
-        self.__context = self.__Context(self.version, self.index.conn)
-        SQLobject._execute(self.index.cursor, "BEGIN")
-        self.revent = self.index.new_revision(
-            self.version, self.__created, self.__author, self.__log)
-        return self
 
-    def __exit__(self, exc_type, exc_value, traceback):
-        try:
-            if exc_type is None:
-                for dirent in self.__context:
-                    self.index.insert(dirent)
-                    logging.debug("insert: %s", dirent)
-                self.index.commit()
+__greek_tree = {
+    'iota': 'file',
+    'A': {
+        'mu': 'file',
+        'B': {
+            'lambda': 'file',
+            'E': {
+                'alpha': 'file',
+                'beta': 'file'},
+            'F': 'dir'},
+        'C': 'dir',
+        'D': {
+            'G': {
+                'pi': 'file',
+                'rho': 'file',
+                'tau': 'file'},
+            'H': {
+                'chi': 'file',
+                'psi': 'file',
+                'omega': 'file'}
+            }
+        }
+    }
+def greektree(ix, tx):
+    def populate(track, items):
+        print 'Populating', track
+        for name, kind in items.iteritems():
+            if kind == 'file':
+                node = ix.add(tx, track, name, NodeRev.FILE)
             else:
-                self.index.rollback()
-        except:
-            self.index.rollback()
-            raise
-        finally:
-            self.__context.clear()
-            self.__context = None
-
-    def __record(self, dirent, replace=False, purge=False):
-        self.__context.record(dirent, replace, purge)
-        logging.debug("record: %s", dirent)
-
-    def __check_writable(self, opcode):
-        if self.__context is None:
-            raise Error(" requires a transaction", action=opcode)
-
-    def __check_not_root(self, abspath, opcode):
-        if abspath.rstrip("/") == "":
-            raise Error(" not allowed on /", action=opcode)
-
-    def __find_target(self, abspath, opcode):
-        target = self.__context.lookup(abspath)
-        if target is not None:
-            if not target.subtree:
-                raise Error(" overrides explicit " + abspath, action=opcode)
-            return target, target.origin
-        target = self.index.lookup(abspath, self.version - 1)
-        if target is None:
-            raise Error(" target does not exist: " + abspath, action=opcode)
-        return target, target.rowid
+                node = ix.add(tx, track, name, NodeRev.DIR)
+            print 'Added', node, 'node:', node.noderev
+            if isinstance(kind, dict):
+                populate(node, kind)
 
-    def lookup(self, abspath):
-        try:
-            return self.index.lookup(self.index.normpath(abspath),
-                                     self.version)
-        finally:
-            if self.__context is None:
-                self.index.rollback()
-
-    def __add(self, opcode, abspath, kind, frompath, fromver):
-        origin = None
-        if frompath is not None:
-            frompath = self.index.normpath(frompath)
-            fromver = int(fromver)
-            origin = self.index.lookup(frompath, fromver)
-            if origin is None:
-                raise Error(" source does not exist: " + frompath, action=opcode)
-            if origin.kind != kind:
-                raise Error(" changes the source object kind", action=opcode)
-            origin = origin.rowid
-        dirent = Dirent(origin = origin,
-                        abspath = abspath,
-                        version = self.version,
-                        kind = kind,
-                        opcode = opcode,
-                        subtree = 0)
-        self.__record(dirent,
-                      replace=(opcode == Dirent.REPLACE),
-                      purge=(opcode == Dirent.REPLACE))
-        if frompath is not None and dirent.kind == Dirent.DIR:
-            prefix = dirent.abspath
-            offset = len(frompath)
-            for source in list(self.index.subtree(frompath, fromver)):
-                abspath = prefix + source.abspath[offset:]
-                self.__record(Dirent(origin = source.rowid,
-                                     abspath = abspath,
-                                     version = self.version,
-                                     kind = source.kind,
-                                     opcode = opcode,
-                                     subtree = 1))
-
-    def add(self, abspath, kind, frompath=None, fromver=None):
-        opcode = Dirent.ADD
-        abspath = self.index.normpath(abspath)
-        self.__check_writable(opcode)
-        self.__check_not_root(abspath, opcode)
-        return self.__add(opcode, abspath, kind, frompath, fromver)
-
-    def replace(self, abspath, kind, frompath=None, fromver=None):
-        opcode = Dirent.REPLACE
-        abspath = self.index.normpath(abspath)
-        self.__check_writable(opcode)
-        self.__check_not_root(abspath, opcode)
-        self.__find_target(abspath, opcode)
-        return self.__add(opcode, abspath, kind, frompath, fromver)
-
-    def modify(self, abspath):
-        opcode = Dirent.MODIFY
-        abspath = self.index.normpath(abspath)
-        self.__check_writable(opcode)
-        target, origin = self.__find_target(abspath, opcode)
-        dirent = Dirent(origin = origin,
-                        abspath = abspath,
-                        version = self.version,
-                        kind = target.kind,
-                        opcode = opcode,
-                        subtree = 0)
-        self.__record(dirent, replace=True)
-
-    def delete(self, abspath):
-        opcode = Dirent.DELETE
-        abspath = self.index.normpath(abspath)
-        self.__check_writable(opcode)
-        self.__check_not_root(abspath, opcode)
-        target, origin = self.__find_target(abspath, opcode)
-        dirent = Dirent(origin = origin,
-                        abspath = abspath,
-                        version = self.version,
-                        kind = target.kind,
-                        opcode = opcode,
-                        subtree = 0)
-        self.__record(dirent, replace=True, purge=True)
-        if target.version < self.version and dirent.kind == Dirent.DIR:
-            for source in self.index.subtree(abspath, self.version - 1):
-                self.__record(Dirent(origin = source.rowid,
-                                     abspath = source.abspath,
-                                     version = self.version,
-                                     kind = source.kind,
-                                     opcode = opcode,
-                                     subtree = 1))
+    root = ix.lookup(tx)
+    populate(root, __greek_tree)
 
 
 def simpletest(database):
     ix = Index(database)
     ix.initialize()
-    with Revision(ix, 1) as rev:
-        rev.add(u'/A', Dirent.DIR)
-        rev.add(u'/A/B', Dirent.DIR)
-        rev.add(u'/A/B/c', Dirent.FILE)
-    with Revision(ix, 2) as rev:
-        rev.add(u'/A/B/d', Dirent.FILE)
-    with Revision(ix, 3) as rev:
-        rev.add(u'/X', Dirent.DIR, u'/A', 1)
-        rev.add(u'/X/B/d', Dirent.FILE, u'/A/B/d', 2)
-    with Revision(ix, 4) as rev:
-        # rev.rename(u'/X/B/d', u'/X/B/x')
-        rev.delete(u'/X/B/d')
-        rev.add(u'/X/B/x', Dirent.FILE, u'/X/B/d', 3)
-    with Revision(ix, 5) as rev:
-        rev.delete(u'/A')
-
-    for r in (0, 1, 2, 3, 4, 5):
-        print "Revision: %d" % r
-        for dirent in list(ix.subtree('/', r)):
-            origin = ix.predecessor(dirent)
-            if origin is None:
-                print "   " + str(dirent)
-            else:
-                print "   %-17s  <- %s" % (dirent, origin)
-
-    dirent = ix.lookup('/A/B/c', 4)
-    print "/A/B/c@4 -> %s@%d" % (dirent.abspath, dirent.version)
-    for succ in ix.successors(dirent):
-        print "%11s %s %s@%d" % (
-            "", succ._deleted and "x_x" or "-->",
-            succ.abspath, succ.version)
 
-    ix.close()
+    try:
+        print "Lookup root"
+        tx = ix.get_txn()
+        print "transaction:", tx
+        root = ix.lookup(tx)
+        print "root track:", root
+        print "root noderev", root.noderev
+
+        print 'Create greek tree'
+        tx = ix.new_txn(0)
+        print "transaction:", tx
+        greektree(ix, tx)
+        ix.commit_txn(tx, 1)
+        ix.commit()
+
+
+        def listdir(noderev, prefix):
+            for n in ix.listdir(tx, noderev):
+                print prefix, str(n)
+                if n._isdir:
+                    listdir(n, prefix + "  ")
+
+        print "List contents"
+        tx = ix.get_txn()
+        print "transaction:", tx
+        root = ix.lookup(tx)
+        print str(root.noderev)
+        listdir(root.noderev, " ")
+
+        print "Lookup iota"
+        track = ix.lookup(tx, None, "iota")
+        print str(track), str(track.noderev)
+
+        print "Lookup A/D/H/psi"
+        track = ix.lookup(tx, None, "A/D/H/psi")
+        print str(track), str(track.noderev)
+    finally:
+        ix.close()
 
 def loggedsimpletest(database):
     import sys
-    logging.basicConfig(level=logging.DEBUG, #SQLobject.LOGLEVEL,
+    logging.basicConfig(level=SQL.LOGLEVEL,
                         stream=sys.stderr)
     simpletest(database)

Modified: subversion/branches/ev2-export/notes/directory-index/schema.sql
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/notes/directory-index/schema.sql?rev=1400556&r1=1400555&r2=1400556&view=diff
==============================================================================
--- subversion/branches/ev2-export/notes/directory-index/schema.sql (original)
+++ subversion/branches/ev2-export/notes/directory-index/schema.sql Sun Oct 21 02:00:31 2012
@@ -19,165 +19,259 @@
 
 ---SCRIPT CREATE_SCHEMA
 
-DROP TABLE IF EXISTS dirindex;
-DROP TABLE IF EXISTS strindex;
-DROP TABLE IF EXISTS revision;
-
--- Revision record
-
-CREATE TABLE revision (
-  version integer NOT NULL PRIMARY KEY,
-  created timestamp NOT NULL,
-  author  varchar NULL,
-  log     varchar NULL
-);
+DROP VIEW IF EXISTS nodeview;
+DROP TABLE IF EXISTS noderev;
+DROP TABLE IF EXISTS string;
+DROP TABLE IF EXISTS txn;
+
+
+-- Transactions
+CREATE TABLE txn (
+  -- transaction number
+  id        integer NOT NULL PRIMARY KEY,
+
+  -- the version of the tree associated with this transaction;
+  -- initially the same as id, but may refer to the originator
+  -- transaction when tracking revprop changes and/or modified trees
+  -- (q.v., obliterate)
+  treeid    integer NULL REFERENCES txn(id),
+
+  -- the revision that this transaction represents; for uncommitted
+  -- transactions, the revision in which it was created
+  revision  integer NULL,
+
+  -- creation date, independent of the svn:date property
+  created   timestamp NOT NULL,
+
+  -- transaction author, independent of the svn:author property; may
+  -- be null if the repository allows anonymous modifications
+  author    varchar NULL,
+
+  -- transaction state
+  -- T = transient (uncommitted), P = permanent (committed), D = dead
+  state     character(1) NOT NULL DEFAULT 'T',
 
--- Path lookup table
+  -- sanity check: enumerated value validation
+  CONSTRAINT enumeration_validation CHECK (state IN ('T', 'P', 'D'))
 
-CREATE TABLE strindex (
-  strid   integer NOT NULL PRIMARY KEY,
-  content varchar NOT NULL UNIQUE
+  -- other attributes:
+     -- revision properties
 );
 
--- Versioned directory tree
-
-CREATE TABLE dirindex (
-  -- unique id of this node revision, used for
-  -- predecessor/successor links
-  rowid   integer NOT NULL PRIMARY KEY,
-
-  -- link to this node's immediate predecessor
-  origin  integer NULL REFERENCES dirindex(rowid),
+CREATE INDEX txn_revision_idx ON txn(revision);
 
-  -- absolute (repository) path
-  pathid  integer NOT NULL REFERENCES strindex(strid),
+CREATE TRIGGER txn_ensure_treeid AFTER INSERT ON txn
+BEGIN
+  UPDATE txn SET treeid = NEW.id WHERE treeid IS NULL AND id = NEW.id;
+END;
 
-  -- revision number
-  version integer NOT NULL REFERENCES revision(version),
 
-  -- node kind (D = dir, F = file, etc.)
-  kind    character(1) NOT NULL,
-
-  -- the operation that produced this entry:
-  -- A = add, R = replace, M = modify, D = delete, N = rename
-  opcode  character(1) NOT NULL,
-
-  -- the index entry is the result of an implicit subtree operation
-  subtree boolean NOT NULL
+-- File names -- lookup table of strings
+CREATE TABLE string (
+  id        integer NOT NULL PRIMARY KEY,
+  val       varchar NOT NULL UNIQUE
 );
-CREATE UNIQUE INDEX dirindex_versioned_tree ON dirindex(pathid, version DESC);
-CREATE INDEX dirindex_successor_list ON dirindex(origin);
-CREATE INDEX dirindex_operation ON dirindex(opcode);
-
--- Repository root
-
-INSERT INTO revision (version, created, author, log)
-  VALUES (0, 'EPOCH', NULL, NULL);
-INSERT INTO strindex (strid, content) VALUES (0, '/');
-INSERT INTO dirindex (rowid, origin, pathid, version, kind, opcode, subtree)
-  VALUES (0, NULL, 0, 0, 'D', 'A', 0);
-
-
----STATEMENT INSERT_REVISION_RECORD
-
-INSERT INTO revision (version, created, author, log)
-  VALUES (?, ?, ?, ?);
-
----STATEMENT GET_REVENT_BY_VERSION
-
-SELECT * FROM revision WHERE version = ?;
-
----STATEMENT INSERT_STRINDEX_RECORD
-
-INSERT INTO strindex (content) VALUES (?);
-
----STATEMENT GET_STRENT_BY_STRID
-
-SELECT * FROM strindex WHERE strid = ?;
-
----STATEMENT GET_STRENT_BY_CONTENT
-
-SELECT * FROM strindex WHERE content = ?;
-
----STATEMENT INSERT_DIRINDEX_RECORD
-
-INSERT INTO dirindex (origin, pathid, version, kind, opcode, subtree)
-  VALUES (?, ?, ?, ?, ?, ?);
-
----STATEMENT GET_DIRENT_BY_ROWID
-
-SELECT dirindex.*, strindex.content FROM dirindex
-  JOIN strindex ON dirindex.pathid = strindex.strid
-WHERE dirindex.rowid = ?;
 
----STATEMENT GET_DIRENT_BY_ABSPATH_AND_VERSION
 
-SELECT dirindex.*, strindex.content AS abspath FROM dirindex
-  JOIN strindex ON dirindex.pathid = strindex.strid
-WHERE abspath = ? AND dirindex.version = ?;
-
----STATEMENT LOOKUP_ABSPATH_AT_REVISION
-
-SELECT dirindex.*, strindex.content AS abspath FROM dirindex
-  JOIN strindex ON dirindex.pathid = strindex.strid
-WHERE abspath = ? AND dirindex.version <= ?
-ORDER BY abspath ASC, dirindex.version DESC
-LIMIT 1;
-
----STATEMENT LIST_SUBTREE_AT_REVISION
-
-SELECT dirindex.*, strindex.content AS abspath FROM dirindex
-  JOIN strindex ON dirindex.pathid = strindex.strid
-  JOIN (SELECT pathid, MAX(version) AS maxver FROM dirindex
-        WHERE version <= ? GROUP BY pathid)
-    AS filtered
-    ON dirindex.pathid == filtered.pathid
-        AND dirindex.version == filtered.maxver
-WHERE abspath LIKE ? ESCAPE '#'
-      AND dirindex.opcode <> 'D'
-ORDER BY abspath ASC;
-
----STATEMENT LIST_DIRENT_SUCCESSORS
-
-SELECT dirindex.*, strindex.content AS abspath FROM dirindex
-  JOIN strindex ON dirindex.pathid = strindex.strid
-WHERE dirindex.origin = ?
-ORDER BY abspath ASC, dirindex.version ASC;
-
-
--- Temporary transaction
-
----SCRIPT CREATE_TRANSACTION_CONTEXT
-
-CREATE TEMPORARY TABLE txncontext (
-  origin  integer NULL,
-  abspath varchar NOT NULL UNIQUE,
-  kind    character(1) NOT NULL,
-  opcode  character(1) NOT NULL,
-  subtree boolean NOT NULL
+-- Node revisions -- DAG of versioned node changes
+CREATE TABLE noderev (
+  -- node revision identifier
+  id        integer NOT NULL PRIMARY KEY,
+
+  -- the transaction in which the node was changed
+  treeid    integer NOT NULL REFERENCES txn(id),
+
+  -- the node identifier
+  -- a new node will get the ID of its initial noderev.id
+  nodeid    integer NULL REFERENCES noderev(id),
+
+  -- this node revision's immediate predecessor
+  origin    integer NULL REFERENCES noderev(id),
+
+  -- the parent (directory) of this node revision -- tree graph
+  parent    integer NULL REFERENCES noderev(id),
+
+  -- the branch that this node revision belongs to -- history graph
+  -- a new branch will get the ID of its initial noderev.id
+  branch    integer NULL REFERENCES noderev(id),
+
+  -- the indexable, NFC-normalized name of this noderev within its parent
+  nameid    integer NOT NULL REFERENCES string(id),
+
+  -- the original, denormalized, non-indexable name
+  denameid  integer NOT NULL REFERENCES string(id),
+
+  -- the node kind; immutable within the node
+  -- D = directory, F = file, etc.
+  kind      character(1) NOT NULL,
+
+  -- the change that produced this node revision
+  -- A = added, D = deleted, M = modified, N = renamed, R = replaced
+  -- B = branched (added + origin <> null)
+  -- L = lazy branch, indicates that child lookup should be performed
+  --     on the origin (requires kind=D + added + origin <> null)
+  -- X = replaced by branch (R + B)
+  -- Z = lazy replace by branch (Like L but implies X instead of B)
+  opcode    character(1) NOT NULL,
+
+  -- mark noderevs of uncommitted transactions so that they can be
+  -- ignored by tree traversals
+  -- T = transient (uncommitted), P = permanent (committed)
+  state     character(1) NOT NULL DEFAULT 'T',
+
+  -- sanity check: enumerated value validation
+  CONSTRAINT enumeration_validation CHECK (
+    kind IN ('D', 'F')
+    AND state IN ('T', 'P')
+    AND opcode IN ('A', 'D', 'M', 'N', 'R', 'B', 'L', 'X', 'Z')),
+
+  -- sanity check: only directories can be lazy
+  CONSTRAINT lazy_copies_make_more_work CHECK (
+    opcode NOT IN ('B', 'L', 'X', 'Z')
+    OR (opcode IN ('B', 'X') AND origin IS NOT NULL)
+    OR (opcode IN ('L', 'Z') AND kind = 'D' AND origin IS NOT NULL)),
+
+  -- sanity check: ye can't be yer own daddy
+  CONSTRAINT genetic_diversity CHECK (id <> origin),
+
+  -- sanity check: ye can't be yer own stepdaddy, either
+  CONSTRAINT escher_avoidance CHECK (parent <> branch)
+
+  -- other attributes:
+     -- versioned properties
+     -- contents reference
 );
 
----SCRIPT REMOVE_TRANSACTION_CONTEXT
-
-DROP TABLE IF EXISTS temp.txncontext;
-
----STATEMENT INSERT_TRANSACTION_RECORD
-
-INSERT INTO temp.txncontext (origin, abspath, kind, opcode, subtree)
-  VALUES (?, ?, ?, ?, ?);
-
----STATEMENT GET_TRANSACTION_RECORD
-
-SELECT * FROM temp.txncontext WHERE abspath = ?;
-
----STATEMENT REMOVE_TRANSACTION_RECORD
-
-DELETE FROM temp.txncontext WHERE abspath = ?;
-
----STATEMENT REMOVE_TRANSACTION_SUBTREE
-
-DELETE FROM temp.txncontext WHERE abspath LIKE ? ESCAPE '#';
-
----STATEMENT LIST_TRANSACTION_RECORDS
-
-SELECT * FROM temp.txncontext ORDER BY abspath ASC;
+CREATE UNIQUE INDEX noderev_tree_idx ON noderev(parent,nameid,treeid,opcode);
+CREATE INDEX noderev_txn_idx ON noderev(treeid);
+CREATE INDEX nodefev_node_idx ON noderev(nodeid);
+CREATE INDEX noderev_branch_idx ON noderev(branch);
+CREATE INDEX noderev_successor_idx ON noderev(origin);
+
+CREATE TRIGGER noderev_ensure_node_and_branch AFTER INSERT ON noderev
+BEGIN
+    UPDATE noderev SET nodeid = NEW.id WHERE nodeid IS NULL AND id = NEW.id;
+    UPDATE noderev SET branch = NEW.id WHERE branch IS NULL AND id = NEW.id;
+END;
+
+
+CREATE VIEW nodeview AS
+  SELECT
+    noderev.*,
+    ns.val AS name,
+    ds.val AS dename
+  FROM
+    noderev JOIN string AS ns ON noderev.nameid = ns.id
+    JOIN string AS ds ON noderev.denameid = ds.id;
+
+
+-- Root directory
+
+INSERT INTO txn (id, treeid, revision, created, state)
+  VALUES (0, 0, 0, 'EPOCH', 'P');
+INSERT INTO string (id, val) VALUES (0, '');
+INSERT INTO noderev (id, treeid, nodeid, branch,
+                     nameid, denameid, kind, opcode, state)
+  VALUES (0, 0, 0, 0, 0, 0, 'D', 'A', 'P');
+
+
+---STATEMENT TXN_INSERT
+INSERT INTO txn (treeid, revision, created, author)
+  VALUES (:treeid, :revision, :created, :author);
+
+---STATEMENT TXN_GET
+SELECT * FROM txn WHERE id = :id;
+
+---STATEMENT TXN_FIND_NEWEST
+SELECT * FROM txn WHERE state = 'P' ORDER BY id DESC LIMIT 1;
+
+---STATEMENT TXN_FIND_BY_REVISION
+SELECT * FROM txn WHERE revision = :revision AND state = 'P'
+ORDER BY id DESC LIMIT 1;
+
+---STATEMENT TXN_FIND_BY_REVISION_AND_TIMESTAMP
+SELECT * FROM txn
+WHERE revision = :revision AND created <= :created AND state = 'P'
+ORDER BY id DESC LIMIT 1;
+
+---STATEMENT TXN_COMMIT
+UPDATE txn SET
+  revision = :revision,
+  created = :created,
+  state = 'P'
+WHERE id = :id;
+
+---STATEMENT TXN_ABORT
+UPDATE txn SET state = 'D' WHERE id = :id;
+
+---STATEMENT TXN_CLEANUP
+DELETE FROM txn WHERE id = :id;
+
+---STATEMENT STRING_INSERT
+INSERT INTO string (val) VALUES (:val);
+
+---STATEMENT STRING_FIND
+SELECT * FROM string WHERE val = :val;
+
+---STATEMENT NODEREV_INSERT
+INSERT INTO noderev (nodeid, treeid, origin, parent, branch,
+                     nameid, denameid, kind, opcode)
+  VALUES (:nodeid, :treeid, :origin, :parent, :branch,
+          :nameid, :denameid, :kind, :opcode);
+
+---STATEMENT NODEREV_UPDATE_TREEID
+UPDATE noderev SET treeid = :new_treeid WHERE treeid = :old_treeid;
+
+---STATEMENT NODEREV_UPDATE_OPCODE
+UPDATE noderev SET opcode = :opcode WHERE id = :id;
+
+---STATEMENT NODEVIEW_GET
+SELECT * FROM nodeview WHERE id = :id;
+
+---STATEMENT NODEREV_COMMIT
+UPDATE noderev SET state = 'P' WHERE treeid = :treeid;
+
+---STATEMENT NODEREV_CLEANUP
+DELETE FROM noderev WHERE treeid = :treeid;
+
+---STATEMENT NODEVIEW_FIND_ROOT
+SELECT * FROM nodeview
+WHERE parent IS NULL AND name = ''
+      AND treeid <= :treeid AND state = 'P'
+ORDER BY treeid DESC LIMIT 1;
+
+---STATEMENT NODEVIEW_FIND_BY_NAME
+SELECT * FROM nodeview
+WHERE parent = :parent AND name = :name
+      AND treeid <= :treeid AND state = 'P'
+ORDER BY treeid DESC LIMIT 1;
+
+---STATEMENT NODEVIEW_FIND_TRANSIENT_ROOT
+SELECT * FROM nodeview
+WHERE parent IS NULL AND name = ''
+      AND (treeid < :treeid AND state = 'P' OR treeid = :treeid)
+ORDER BY treeid DESC LIMIT 1;
+
+---STATEMENT NODEVIEW_FIND_TRANSIENT_BY_NAME
+SELECT * FROM nodeview
+WHERE parent = :parent AND name = :name
+      AND (treeid < :treeid AND state = 'P' OR treeid = :treeid)
+ORDER BY treeid DESC LIMIT 1;
+
+---STATEMENT NODEVIEW_LIST_DIRECTORY
+SELECT * FROM nodeview
+  JOIN (SELECT nameid, MAX(treeid) AS treeid FROM noderev
+        WHERE treeid <= :treeid AND state = 'P'
+        GROUP BY nameid) AS filter
+    ON nodeview.nameid = filter.nameid AND nodeview.treeid = filter.treeid
+WHERE parent = :parent AND opcode <> 'D'
+ORDER BY nodeview.name ASC;
+
+---STATEMENT NODEVIEW_LIST_TRANSIENT_DIRECTORY
+SELECT * FROM nodeview
+  JOIN (SELECT nameid, MAX(treeid) AS treeid FROM noderev
+        WHERE treeid < :treeid AND state = 'P' OR treeid = :treeid
+        GROUP BY nameid) AS filter
+    ON nodeview.nameid = filter.name AND nodeview.treeid = filter.treeid
+WHERE parent = :parent AND opcode <> 'D'
+ORDER BY nodeview.name ASC;

Modified: subversion/branches/ev2-export/notes/merge-tracking/func-spec.html
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/notes/merge-tracking/func-spec.html?rev=1400556&r1=1400555&r2=1400556&view=diff
==============================================================================
--- subversion/branches/ev2-export/notes/merge-tracking/func-spec.html (original)
+++ subversion/branches/ev2-export/notes/merge-tracking/func-spec.html Sun Oct 21 02:00:31 2012
@@ -672,7 +672,7 @@ Whitespace fixes.  No functional change.
 
   <p>The <code>--verbose</code> flag also triggers additional information.
   In addition to the date of the revision, <code>--verbose</code>, in
-  combination with <code>-g</code>, also displays the the original path, relative
+  combination with <code>-g</code>, also displays the original path, relative
   to the repository root, where the modifications were made.  Given the above
   example, <code>svn blame -g --verbose</code> will be something like this:</p>
   <pre>

Propchange: subversion/branches/ev2-export/notes/obliterate/design-audit.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: subversion/branches/ev2-export/notes/obliterate/design-authz.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: subversion/branches/ev2-export/notes/obliterate/design-repos.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: subversion/branches/ev2-export/notes/obliterate/design-wc.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: subversion/branches/ev2-export/notes/obliterate/plan-milestones.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: subversion/branches/ev2-export/notes/ra-serf-testing.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: subversion/branches/ev2-export/notes/tree-conflicts/all-add-vs-add-tree-conflicts.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: subversion/branches/ev2-export/notes/wc_node_walkers.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: subversion/branches/ev2-export/subversion/bindings/javahl/native/BlameCallback.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/bindings/javahl/native/BlameCallback.cpp?rev=1400556&r1=1400555&r2=1400556&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/bindings/javahl/native/BlameCallback.cpp (original)
+++ subversion/branches/ev2-export/subversion/bindings/javahl/native/BlameCallback.cpp Sun Oct 21 02:00:31 2012
@@ -61,11 +61,9 @@ BlameCallback::callback(void *baton,
                         apr_pool_t *pool)
 {
   if (baton)
-    return ((BlameCallback *)baton)->singleLine(start_revnum, end_revnum,
-                                                line_no, revision, rev_props,
-                                                merged_revision,
-                                                merged_rev_props, merged_path,
-                                                line, local_change, pool);
+    return static_cast<BlameCallback *>(baton)->singleLine(start_revnum,
+        end_revnum, line_no, revision, rev_props, merged_revision,
+        merged_rev_props, merged_path, line, local_change, pool);
 
   return SVN_NO_ERROR;
 }

Modified: subversion/branches/ev2-export/subversion/bindings/javahl/native/ChangelistCallback.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/bindings/javahl/native/ChangelistCallback.cpp?rev=1400556&r1=1400555&r2=1400556&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/bindings/javahl/native/ChangelistCallback.cpp (original)
+++ subversion/branches/ev2-export/subversion/bindings/javahl/native/ChangelistCallback.cpp Sun Oct 21 02:00:31 2012
@@ -53,7 +53,8 @@ ChangelistCallback::callback(void *baton
                              apr_pool_t *pool)
 {
   if (baton)
-    ((ChangelistCallback *)baton)->doChangelist(path, changelist, pool);
+    static_cast<ChangelistCallback *>(baton)->doChangelist(path, changelist,
+            pool);
 
   return SVN_NO_ERROR;
 }

Modified: subversion/branches/ev2-export/subversion/bindings/javahl/native/ClientContext.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/bindings/javahl/native/ClientContext.cpp?rev=1400556&r1=1400555&r2=1400556&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/bindings/javahl/native/ClientContext.cpp (original)
+++ subversion/branches/ev2-export/subversion/bindings/javahl/native/ClientContext.cpp Sun Oct 21 02:00:31 2012
@@ -71,7 +71,8 @@ ClientContext::ClientContext(jobject jsv
 
     env->DeleteLocalRef(jctx);
 
-    SVN_JNI_ERR(svn_client_create_context(&m_context, pool.getPool()),
+    SVN_JNI_ERR(svn_client_create_context2(&m_context, NULL,
+                                           pool.getPool()),
                 );
 
     /* Clear the wc_ctx as we don't want to maintain this unconditionally
@@ -323,7 +324,7 @@ ClientContext::cancelOperation()
 svn_error_t *
 ClientContext::checkCancel(void *cancelBaton)
 {
-    ClientContext *that = (ClientContext *)cancelBaton;
+    ClientContext *that = static_cast<ClientContext *>(cancelBaton);
     if (that->m_cancelOperation)
         return svn_error_create(SVN_ERR_CANCELLED, NULL,
                                 _("Operation cancelled"));

Modified: subversion/branches/ev2-export/subversion/bindings/javahl/native/CommitCallback.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/bindings/javahl/native/CommitCallback.cpp?rev=1400556&r1=1400555&r2=1400556&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/bindings/javahl/native/CommitCallback.cpp (original)
+++ subversion/branches/ev2-export/subversion/bindings/javahl/native/CommitCallback.cpp Sun Oct 21 02:00:31 2012
@@ -57,7 +57,7 @@ CommitCallback::callback(const svn_commi
                          apr_pool_t *pool)
 {
   if (baton)
-    return ((CommitCallback *)baton)->commitInfo(commit_info, pool);
+    return static_cast<CommitCallback *>(baton)->commitInfo(commit_info, pool);
 
   return SVN_NO_ERROR;
 }

Modified: subversion/branches/ev2-export/subversion/bindings/javahl/native/CommitMessage.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/bindings/javahl/native/CommitMessage.cpp?rev=1400556&r1=1400555&r2=1400556&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/bindings/javahl/native/CommitMessage.cpp (original)
+++ subversion/branches/ev2-export/subversion/bindings/javahl/native/CommitMessage.cpp Sun Oct 21 02:00:31 2012
@@ -50,9 +50,9 @@ CommitMessage::callback(const char **log
                         void *baton,
                         apr_pool_t *pool)
 {
-  if (baton && ((CommitMessage *)baton)->m_jcommitMessage)
-    return ((CommitMessage *)baton)->getCommitMessage(log_msg, tmp_file,
-                                                      commit_items, pool);
+  if (baton && static_cast<CommitMessage *>(baton)->m_jcommitMessage)
+    return static_cast<CommitMessage *>(baton)->getCommitMessage(
+            log_msg, tmp_file, commit_items, pool);
 
   *log_msg = NULL;
   *tmp_file = NULL;

Modified: subversion/branches/ev2-export/subversion/bindings/javahl/native/CreateJ.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/bindings/javahl/native/CreateJ.cpp?rev=1400556&r1=1400555&r2=1400556&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/bindings/javahl/native/CreateJ.cpp (original)
+++ subversion/branches/ev2-export/subversion/bindings/javahl/native/CreateJ.cpp Sun Oct 21 02:00:31 2012
@@ -911,7 +911,7 @@ CreateJ::CommitInfo(const svn_commit_inf
 }
 
 jobject
-CreateJ::RevisionRangeList(apr_array_header_t *ranges)
+CreateJ::RevisionRangeList(svn_rangelist_t *ranges)
 {
   JNIEnv *env = JNIUtil::getEnv();
 

Modified: subversion/branches/ev2-export/subversion/bindings/javahl/native/CreateJ.h
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/bindings/javahl/native/CreateJ.h?rev=1400556&r1=1400555&r2=1400556&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/bindings/javahl/native/CreateJ.h (original)
+++ subversion/branches/ev2-export/subversion/bindings/javahl/native/CreateJ.h Sun Oct 21 02:00:31 2012
@@ -74,7 +74,7 @@ class CreateJ
   CommitInfo(const svn_commit_info_t *info);
 
   static jobject
-  RevisionRangeList(apr_array_header_t *ranges);
+  RevisionRangeList(svn_rangelist_t *ranges);
 
   static jobject
   StringSet(apr_array_header_t *strings);

Modified: subversion/branches/ev2-export/subversion/bindings/javahl/native/DiffSummaryReceiver.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/bindings/javahl/native/DiffSummaryReceiver.cpp?rev=1400556&r1=1400555&r2=1400556&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/bindings/javahl/native/DiffSummaryReceiver.cpp (original)
+++ subversion/branches/ev2-export/subversion/bindings/javahl/native/DiffSummaryReceiver.cpp Sun Oct 21 02:00:31 2012
@@ -46,7 +46,7 @@ DiffSummaryReceiver::summarize(const svn
                                apr_pool_t *pool)
 {
   if (baton)
-    return ((DiffSummaryReceiver *) baton)->onSummary(diff, pool);
+    return static_cast<DiffSummaryReceiver *>(baton)->onSummary(diff, pool);
 
   return SVN_NO_ERROR;
 }

Modified: subversion/branches/ev2-export/subversion/bindings/javahl/native/InfoCallback.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/bindings/javahl/native/InfoCallback.cpp?rev=1400556&r1=1400555&r2=1400556&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/bindings/javahl/native/InfoCallback.cpp (original)
+++ subversion/branches/ev2-export/subversion/bindings/javahl/native/InfoCallback.cpp Sun Oct 21 02:00:31 2012
@@ -52,7 +52,7 @@ InfoCallback::callback(void *baton,
                        apr_pool_t *pool)
 {
   if (baton)
-    return ((InfoCallback *)baton)->singleInfo(path, info, pool);
+    return static_cast<InfoCallback *>(baton)->singleInfo(path, info, pool);
 
   return SVN_NO_ERROR;
 }

Modified: subversion/branches/ev2-export/subversion/bindings/javahl/native/InputStream.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/bindings/javahl/native/InputStream.cpp?rev=1400556&r1=1400555&r2=1400556&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/bindings/javahl/native/InputStream.cpp (original)
+++ subversion/branches/ev2-export/subversion/bindings/javahl/native/InputStream.cpp Sun Oct 21 02:00:31 2012
@@ -70,7 +70,7 @@ svn_error_t *InputStream::read(void *bat
 {
   JNIEnv *env = JNIUtil::getEnv();
   // An object of our class is passed in as the baton.
-  InputStream *that = (InputStream*)baton;
+  InputStream *that = static_cast<InputStream *>(baton);
 
   // The method id will not change during the time this library is
   // loaded, so it can be cached.

Modified: subversion/branches/ev2-export/subversion/bindings/javahl/native/JNIUtil.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/bindings/javahl/native/JNIUtil.cpp?rev=1400556&r1=1400555&r2=1400556&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/bindings/javahl/native/JNIUtil.cpp (original)
+++ subversion/branches/ev2-export/subversion/bindings/javahl/native/JNIUtil.cpp Sun Oct 21 02:00:31 2012
@@ -37,9 +37,13 @@
 #include <apr_lib.h>
 
 #include "svn_pools.h"
+#include "svn_fs.h"
+#include "svn_ra.h"
+#include "svn_utf.h"
 #include "svn_wc.h"
 #include "svn_dso.h"
 #include "svn_path.h"
+#include "svn_cache_config.h"
 #include <apr_file_info.h>
 #include "svn_private_config.h"
 #ifdef WIN32
@@ -175,6 +179,19 @@ bool JNIUtil::JNIGlobalInit(JNIEnv *env)
       apr_allocator_max_free_set(allocator, 1);
     }
 
+  svn_utf_initialize(g_pool); /* Optimize character conversions */
+  svn_fs_initialize(g_pool); /* Avoid some theoretical issues */
+  svn_ra_initialize(g_pool);
+
+  /* We shouldn't fill the JVMs memory with FS cache data unless explictly
+     requested. */
+  {
+    svn_cache_config_t settings = *svn_cache_config_get();
+    settings.cache_size = 0;
+    settings.file_handle_count = 0;
+    settings.single_threaded = FALSE;
+    svn_cache_config_set(&settings);
+  }
 
 #ifdef ENABLE_NLS
 #ifdef WIN32
@@ -240,6 +257,8 @@ bool JNIUtil::JNIGlobalInit(JNIEnv *env)
     }
 #endif
 
+  svn_error_set_malfunction_handler(svn_error_raise_on_malfunction);
+
   // Build all mutexes.
   g_finalizedObjectsMutex = new JNIMutex(g_pool);
   if (isExceptionThrown())

Modified: subversion/branches/ev2-export/subversion/bindings/javahl/native/ListCallback.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/bindings/javahl/native/ListCallback.cpp?rev=1400556&r1=1400555&r2=1400556&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/bindings/javahl/native/ListCallback.cpp (original)
+++ subversion/branches/ev2-export/subversion/bindings/javahl/native/ListCallback.cpp Sun Oct 21 02:00:31 2012
@@ -57,8 +57,8 @@ ListCallback::callback(void *baton,
                        apr_pool_t *pool)
 {
   if (baton)
-    return ((ListCallback *)baton)->doList(path, dirent, lock, abs_path,
-                                           pool);
+    return static_cast<ListCallback *>(baton)->doList(
+            path, dirent, lock, abs_path, pool);
 
   return SVN_NO_ERROR;
 }

Modified: subversion/branches/ev2-export/subversion/bindings/javahl/native/LogMessageCallback.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/bindings/javahl/native/LogMessageCallback.cpp?rev=1400556&r1=1400555&r2=1400556&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/bindings/javahl/native/LogMessageCallback.cpp (original)
+++ subversion/branches/ev2-export/subversion/bindings/javahl/native/LogMessageCallback.cpp Sun Oct 21 02:00:31 2012
@@ -57,7 +57,8 @@ LogMessageCallback::callback(void *baton
                              apr_pool_t *pool)
 {
   if (baton)
-    return ((LogMessageCallback *)baton)->singleMessage(log_entry, pool);
+    return static_cast<LogMessageCallback *>(baton)->singleMessage(
+            log_entry, pool);
 
   return SVN_NO_ERROR;
 }

Modified: subversion/branches/ev2-export/subversion/bindings/javahl/native/OutputStream.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/bindings/javahl/native/OutputStream.cpp?rev=1400556&r1=1400555&r2=1400556&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/bindings/javahl/native/OutputStream.cpp (original)
+++ subversion/branches/ev2-export/subversion/bindings/javahl/native/OutputStream.cpp Sun Oct 21 02:00:31 2012
@@ -76,7 +76,7 @@ svn_error_t *OutputStream::write(void *b
   JNIEnv *env = JNIUtil::getEnv();
 
   // An object of our class is passed in as the baton.
-  OutputStream *that = (OutputStream*)baton;
+  OutputStream *that = static_cast<OutputStream *>(baton);
 
   // The method id will not change during the time this library is
   // loaded, so it can be cached.

Modified: subversion/branches/ev2-export/subversion/bindings/javahl/native/PatchCallback.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/bindings/javahl/native/PatchCallback.cpp?rev=1400556&r1=1400555&r2=1400556&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/bindings/javahl/native/PatchCallback.cpp (original)
+++ subversion/branches/ev2-export/subversion/bindings/javahl/native/PatchCallback.cpp Sun Oct 21 02:00:31 2012
@@ -54,10 +54,9 @@ PatchCallback::callback(void *baton,
                         apr_pool_t *pool)
 {
   if (baton)
-    return ((PatchCallback *)baton)->singlePatch(filtered,
-                                                 canon_path_from_patchfile,
-                                                 patch_abspath, reject_abspath,
-                                                 pool);
+    return static_cast<PatchCallback *>(baton)->singlePatch(
+            filtered, canon_path_from_patchfile, patch_abspath, reject_abspath,
+            pool);
 
   return SVN_NO_ERROR;
 }

Modified: subversion/branches/ev2-export/subversion/bindings/javahl/native/Prompter.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/bindings/javahl/native/Prompter.cpp?rev=1400556&r1=1400555&r2=1400556&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/bindings/javahl/native/Prompter.cpp (original)
+++ subversion/branches/ev2-export/subversion/bindings/javahl/native/Prompter.cpp Sun Oct 21 02:00:31 2012
@@ -427,7 +427,7 @@ svn_error_t *Prompter::simple_prompt(svn
                                      svn_boolean_t may_save,
                                      apr_pool_t *pool)
 {
-  Prompter *that = (Prompter*)baton;
+  Prompter *that = static_cast<Prompter *>(baton);
   svn_auth_cred_simple_t *ret =
     (svn_auth_cred_simple_t*)apr_pcalloc(pool, sizeof(*ret));
   if (!that->prompt(realm, username, may_save ? true : false))
@@ -460,7 +460,7 @@ svn_error_t *Prompter::username_prompt(s
                                        svn_boolean_t may_save,
                                        apr_pool_t *pool)
 {
-  Prompter *that = (Prompter*)baton;
+  Prompter *that = static_cast<Prompter *>(baton);
   svn_auth_cred_username_t *ret =
     (svn_auth_cred_username_t*)apr_pcalloc(pool, sizeof(*ret));
   const char *user = that->askQuestion(realm, _("Username: "), true,
@@ -484,7 +484,7 @@ Prompter::ssl_server_trust_prompt(svn_au
                                   svn_boolean_t may_save,
                                   apr_pool_t *pool)
 {
-  Prompter *that = (Prompter*)baton;
+  Prompter *that = static_cast<Prompter *>(baton);
   svn_auth_cred_ssl_server_trust_t *ret =
     (svn_auth_cred_ssl_server_trust_t*)apr_pcalloc(pool, sizeof(*ret));
 
@@ -550,7 +550,7 @@ Prompter::ssl_client_cert_prompt(svn_aut
                                  svn_boolean_t may_save,
                                  apr_pool_t *pool)
 {
-  Prompter *that = (Prompter*)baton;
+  Prompter *that = static_cast<Prompter *>(baton);
   svn_auth_cred_ssl_client_cert_t *ret =
     (svn_auth_cred_ssl_client_cert_t*)apr_pcalloc(pool, sizeof(*ret));
   const char *cert_file =
@@ -572,7 +572,7 @@ Prompter::ssl_client_cert_pw_prompt(svn_
                                     svn_boolean_t may_save,
                                     apr_pool_t *pool)
 {
-  Prompter *that = (Prompter*)baton;
+  Prompter *that = static_cast<Prompter *>(baton);
   svn_auth_cred_ssl_client_cert_pw_t *ret =
     (svn_auth_cred_ssl_client_cert_pw_t*)apr_pcalloc(pool, sizeof(*ret));
   const char *info = that->askQuestion(realm,
@@ -593,7 +593,7 @@ Prompter::plaintext_prompt(svn_boolean_t
                            void *baton,
                            apr_pool_t *pool)
 {
-  Prompter *that = (Prompter *) baton;
+  Prompter *that = static_cast<Prompter *>(baton);
 
   bool result = that->askYesNo(realmstring,
                                _("Store password unencrypted?"),
@@ -610,7 +610,7 @@ Prompter::plaintext_passphrase_prompt(sv
                                       void *baton,
                                       apr_pool_t *pool)
 {
-  Prompter *that = (Prompter *) baton;
+  Prompter *that = static_cast<Prompter *>(baton);
 
   bool result = that->askYesNo(realmstring,
                                _("Store passphrase unencrypted?"),

Modified: subversion/branches/ev2-export/subversion/bindings/javahl/native/ProplistCallback.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/bindings/javahl/native/ProplistCallback.cpp?rev=1400556&r1=1400555&r2=1400556&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/bindings/javahl/native/ProplistCallback.cpp (original)
+++ subversion/branches/ev2-export/subversion/bindings/javahl/native/ProplistCallback.cpp Sun Oct 21 02:00:31 2012
@@ -54,7 +54,8 @@ ProplistCallback::callback(void *baton,
                            apr_pool_t *pool)
 {
   if (baton)
-    return ((ProplistCallback *)baton)->singlePath(path, prop_hash, pool);
+    return static_cast<ProplistCallback *>(baton)->singlePath(
+            path, prop_hash, pool);
 
   return SVN_NO_ERROR;
 }

Modified: subversion/branches/ev2-export/subversion/bindings/javahl/native/ReposNotifyCallback.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/bindings/javahl/native/ReposNotifyCallback.cpp?rev=1400556&r1=1400555&r2=1400556&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/bindings/javahl/native/ReposNotifyCallback.cpp (original)
+++ subversion/branches/ev2-export/subversion/bindings/javahl/native/ReposNotifyCallback.cpp Sun Oct 21 02:00:31 2012
@@ -49,7 +49,7 @@ ReposNotifyCallback::notify(void *baton,
                             apr_pool_t *pool)
 {
   if (baton)
-    ((ReposNotifyCallback *)baton)->onNotify(notify, pool);
+    static_cast<ReposNotifyCallback *>(baton)->onNotify(notify, pool);
 }
 
 /**

Modified: subversion/branches/ev2-export/subversion/bindings/javahl/native/SVNClient.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/bindings/javahl/native/SVNClient.cpp?rev=1400556&r1=1400555&r2=1400556&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/bindings/javahl/native/SVNClient.cpp (original)
+++ subversion/branches/ev2-export/subversion/bindings/javahl/native/SVNClient.cpp Sun Oct 21 02:00:31 2012
@@ -44,6 +44,7 @@
 #include "StatusCallback.h"
 #include "ChangelistCallback.h"
 #include "ListCallback.h"
+#include "ImportFilterCallback.h"
 #include "JNIByteArray.h"
 #include "CommitMessage.h"
 #include "EnumMapper.h"
@@ -553,7 +554,9 @@ jlong SVNClient::doSwitch(const char *pa
 void SVNClient::doImport(const char *path, const char *url,
                          CommitMessage *message, svn_depth_t depth,
                          bool noIgnore, bool ignoreUnknownNodeTypes,
-                         RevpropTable &revprops, CommitCallback *callback)
+                         RevpropTable &revprops,
+                         ImportFilterCallback *ifCallback,
+                         CommitCallback *commitCallback)
 {
     SVN::Pool subPool(pool);
     SVN_JNI_NULL_PTR_EX(path, "path", );
@@ -567,10 +570,11 @@ void SVNClient::doImport(const char *pat
     if (ctx == NULL)
         return;
 
-    SVN_JNI_ERR(svn_client_import4(intPath.c_str(), intUrl.c_str(), depth,
+    SVN_JNI_ERR(svn_client_import5(intPath.c_str(), intUrl.c_str(), depth,
                                    noIgnore, ignoreUnknownNodeTypes,
                                    revprops.hash(subPool),
-                                   CommitCallback::callback, callback,
+                                   ImportFilterCallback::callback, ifCallback,
+                                   CommitCallback::callback, commitCallback,
                                    ctx, subPool.getPool()), );
 }
 
@@ -760,7 +764,7 @@ SVNClient::getMergeinfo(const char *targ
 
         jstring jpath = JNIUtil::makeJString((const char *) path);
         jobject jranges =
-            CreateJ::RevisionRangeList((apr_array_header_t *) val);
+            CreateJ::RevisionRangeList((svn_rangelist_t *) val);
 
         env->CallVoidMethod(jmergeinfo, addRevisions, jpath, jranges);
 
@@ -816,7 +820,8 @@ void SVNClient::getMergeinfoLog(int type
  * Get a property.
  */
 jbyteArray SVNClient::propertyGet(const char *path, const char *name,
-                                  Revision &revision, Revision &pegRevision)
+                                  Revision &revision, Revision &pegRevision,
+                                  StringArray &changelists)
 {
     SVN::Pool subPool(pool);
     SVN_JNI_NULL_PTR_EX(path, "path", NULL);
@@ -829,11 +834,11 @@ jbyteArray SVNClient::propertyGet(const 
         return NULL;
 
     apr_hash_t *props;
-    SVN_JNI_ERR(svn_client_propget4(&props, name,
+    SVN_JNI_ERR(svn_client_propget5(&props, NULL, name,
                                     intPath.c_str(), pegRevision.revision(),
                                     revision.revision(), NULL, svn_depth_empty,
-                                    NULL, ctx, subPool.getPool(),
-                                    subPool.getPool()),
+                                    changelists.array(subPool), ctx,
+                                    subPool.getPool(), subPool.getPool()),
                 NULL);
 
     apr_hash_index_t *hi;
@@ -1187,7 +1192,6 @@ void SVNClient::blame(const char *path, 
 {
     SVN::Pool subPool(pool);
     SVN_JNI_NULL_PTR_EX(path, "path", );
-    apr_pool_t *pool = subPool.getPool();
     Path intPath(path, subPool);
     SVN_JNI_ERR(intPath.error_occured(), );
 
@@ -1195,13 +1199,12 @@ void SVNClient::blame(const char *path, 
     if (ctx == NULL)
         return;
 
-    SVN_JNI_ERR(svn_client_blame5(intPath.c_str(), pegRevision.revision(),
-                                  revisionStart.revision(),
-                                  revisionEnd.revision(),
-                                  svn_diff_file_options_create(pool),
-                                  ignoreMimeType, includeMergedRevisions,
-                                  BlameCallback::callback, callback, ctx,
-                                  pool),
+    SVN_JNI_ERR(svn_client_blame5(
+          intPath.c_str(), pegRevision.revision(), revisionStart.revision(),
+          revisionEnd.revision(),
+          svn_diff_file_options_create(subPool.getPool()), ignoreMimeType,
+          includeMergedRevisions, BlameCallback::callback, callback, ctx,
+          subPool.getPool()),
         );
 }
 

Modified: subversion/branches/ev2-export/subversion/bindings/javahl/native/SVNClient.h
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/bindings/javahl/native/SVNClient.h?rev=1400556&r1=1400555&r2=1400556&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/bindings/javahl/native/SVNClient.h (original)
+++ subversion/branches/ev2-export/subversion/bindings/javahl/native/SVNClient.h Sun Oct 21 02:00:31 2012
@@ -46,6 +46,7 @@ class LogMessageCallback;
 class InfoCallback;
 class CommitCallback;
 class ListCallback;
+class ImportFilterCallback;
 class StatusCallback;
 class OutputStream;
 class PatchCallback;
@@ -107,7 +108,8 @@ class SVNClient :public SVNBase
                         const char *localPath, bool dryRun);
   void doImport(const char *path, const char *url, CommitMessage *message,
                 svn_depth_t depth, bool noIgnore, bool ignoreUnknownNodeTypes,
-                RevpropTable &revprops, CommitCallback *callback);
+                RevpropTable &revprops, ImportFilterCallback *ifCallback,
+                CommitCallback *commitCallback);
   jlong doSwitch(const char *path, const char *url, Revision &revision,
                  Revision &pegRevision, svn_depth_t depth,
                  bool depthIsSticky, bool ignoreExternals,
@@ -171,7 +173,8 @@ class SVNClient :public SVNBase
                          bool lastChanged);
   void upgrade(const char *path);
   jbyteArray propertyGet(const char *path, const char *name,
-                         Revision &revision, Revision &pegRevision);
+                         Revision &revision, Revision &pegRevision,
+                         StringArray &changelists);
   void diff(const char *target1, Revision &revision1,
             const char *target2, Revision &revision2,
             const char *relativeToDir, OutputStream &outputStream,

Modified: subversion/branches/ev2-export/subversion/bindings/javahl/native/SVNRepos.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/bindings/javahl/native/SVNRepos.cpp?rev=1400556&r1=1400555&r2=1400556&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/bindings/javahl/native/SVNRepos.cpp (original)
+++ subversion/branches/ev2-export/subversion/bindings/javahl/native/SVNRepos.cpp Sun Oct 21 02:00:31 2012
@@ -68,7 +68,7 @@ void SVNRepos::cancelOperation()
 svn_error_t *
 SVNRepos::checkCancel(void *cancelBaton)
 {
-  SVNRepos *that = (SVNRepos *)cancelBaton;
+  SVNRepos *that = static_cast<SVNRepos *>(cancelBaton);
   if (that->m_cancelOperation)
     return svn_error_create(SVN_ERR_CANCELLED, NULL,
                             _("Operation cancelled"));
@@ -248,7 +248,7 @@ void SVNRepos::dump(File &path, OutputSt
 }
 
 void SVNRepos::hotcopy(File &path, File &targetPath,
-                       bool cleanLogs)
+                       bool cleanLogs, bool incremental)
 {
   SVN::Pool requestPool;
 
@@ -264,9 +264,12 @@ void SVNRepos::hotcopy(File &path, File 
       return;
     }
 
-  SVN_JNI_ERR(svn_repos_hotcopy(path.getInternalStyle(requestPool),
-                                targetPath.getInternalStyle(requestPool),
-                                cleanLogs, requestPool.getPool()), );
+  SVN_JNI_ERR(svn_repos_hotcopy2(path.getInternalStyle(requestPool),
+                                 targetPath.getInternalStyle(requestPool),
+                                 cleanLogs, incremental,
+                                 checkCancel, this /* cancel callback/baton */,
+                                 requestPool.getPool()),
+             );
 }
 
 static void

Modified: subversion/branches/ev2-export/subversion/bindings/javahl/native/SVNRepos.h
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/bindings/javahl/native/SVNRepos.h?rev=1400556&r1=1400555&r2=1400556&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/bindings/javahl/native/SVNRepos.h (original)
+++ subversion/branches/ev2-export/subversion/bindings/javahl/native/SVNRepos.h Sun Oct 21 02:00:31 2012
@@ -58,7 +58,7 @@ class SVNRepos : public SVNBase
   void listUnusedDBLogs(File &path,
                         MessageReceiver &messageReceiver);
   void listDBLogs(File &path, MessageReceiver &messageReceiver);
-  void hotcopy(File &path, File &targetPath, bool cleanLogs);
+  void hotcopy(File &path, File &targetPath, bool cleanLogs, bool incremental);
   void dump(File &path, OutputStream &dataOut, Revision &revsionStart,
             Revision &RevisionEnd, bool incremental, bool useDeltas,
             ReposNotifyCallback *notifyCallback);

Modified: subversion/branches/ev2-export/subversion/bindings/javahl/native/StatusCallback.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/bindings/javahl/native/StatusCallback.cpp?rev=1400556&r1=1400555&r2=1400556&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/bindings/javahl/native/StatusCallback.cpp (original)
+++ subversion/branches/ev2-export/subversion/bindings/javahl/native/StatusCallback.cpp Sun Oct 21 02:00:31 2012
@@ -55,7 +55,8 @@ StatusCallback::callback(void *baton,
                          apr_pool_t *pool)
 {
   if (baton)
-    return ((StatusCallback *)baton)->doStatus(local_abspath, status, pool);
+    return static_cast<StatusCallback *>(baton)->doStatus(
+            local_abspath, status, pool);
 
   return SVN_NO_ERROR;
 }