Exemplo n.º 1
0
 def get_changes(self, old_path, old_rev, new_path, new_rev,
                 ignore_ancestry=0):
     old_node = new_node = None
     old_rev = self.normalize_rev(old_rev)
     new_rev = self.normalize_rev(new_rev)
     if self.has_node(old_path, old_rev):
         old_node = self.get_node(old_path, old_rev)
     else:
         raise NoSuchNode(old_path, old_rev, 'The Base for Diff is invalid')
     if self.has_node(new_path, new_rev):
         new_node = self.get_node(new_path, new_rev)
     else:
         raise NoSuchNode(new_path, new_rev, 'The Target for Diff is invalid')
     if new_node.kind != old_node.kind:
         raise TracError('Diff mismatch: Base is a %s (%s in revision %s) '
                         'and Target is a %s (%s in revision %s).' \
                         % (old_node.kind, old_path, old_rev,
                            new_node.kind, new_path, new_rev))
     subpool = Pool(self.pool)
     if new_node.isdir:
         editor = DiffChangeEditor()
         e_ptr, e_baton = delta.make_editor(editor, subpool())
         old_root = fs.revision_root(self.fs_ptr, old_rev, subpool())
         new_root = fs.revision_root(self.fs_ptr, new_rev, subpool())
         def authz_cb(root, path, pool): return 1
         text_deltas = 0 # as this is anyway re-done in Diff.py...
         entry_props = 0 # "... typically used only for working copy updates"
         repos.svn_repos_dir_delta(old_root,
                                   _to_svn(self.scope + old_path), '',
                                   new_root,
                                   _to_svn(self.scope + new_path),
                                   e_ptr, e_baton, authz_cb,
                                   text_deltas,
                                   1, # directory
                                   entry_props,
                                   ignore_ancestry,
                                   subpool())
         for path, kind, change in editor.deltas:
             path = _from_svn(path)
             old_node = new_node = None
             if change != Changeset.ADD:
                 old_node = self.get_node(posixpath.join(old_path, path),
                                          old_rev)
             if change != Changeset.DELETE:
                 new_node = self.get_node(posixpath.join(new_path, path),
                                          new_rev)
             else:
                 kind = _kindmap[fs.check_path(old_root,
                                               _to_svn(self.scope,
                                                       old_node.path),
                                               subpool())]
             yield  (old_node, new_node, kind, change)
     else:
         old_root = fs.revision_root(self.fs_ptr, old_rev, subpool())
         new_root = fs.revision_root(self.fs_ptr, new_rev, subpool())
         if fs.contents_changed(old_root, _to_svn(self.scope, old_path),
                                new_root, _to_svn(self.scope, new_path),
                                subpool()):
             yield (old_node, new_node, Node.FILE, Changeset.EDIT)
Exemplo n.º 2
0
def check_tabs(pool, repos_path, txn):
    def authz_cb(root, path, pool):
        return 1
 
    fs_ptr = repos.svn_repos_fs(repos.svn_repos_open(repos_path, pool))
    txn_ptr = fs.open_txn(fs_ptr, txn, pool)
    txn_root = fs.txn_root(txn_ptr, pool)
    base_root = fs.revision_root(fs_ptr, fs.txn_base_revision(txn_ptr), pool)
    editor = ChangeReceiver(txn_root, base_root, pool)
    e_ptr, e_baton = delta.make_editor(editor, pool)
    repos.svn_repos_dir_delta(base_root, '', '', txn_root, '',
                              e_ptr, e_baton, authz_cb, 0, 1, 0, 0, pool)
Exemplo n.º 3
0
def check_tabs(pool, repos_path, txn):
    def authz_cb(root, path, pool):
        return 1

    fs_ptr = repos.svn_repos_fs(repos.svn_repos_open(repos_path, pool))
    txn_ptr = fs.open_txn(fs_ptr, txn, pool)
    txn_root = fs.txn_root(txn_ptr, pool)
    base_root = fs.revision_root(fs_ptr, fs.txn_base_revision(txn_ptr), pool)
    editor = ChangeReceiver(txn_root, base_root, pool)
    e_ptr, e_baton = delta.make_editor(editor, pool)
    repos.svn_repos_dir_delta(base_root, '', '', txn_root, '', e_ptr, e_baton,
                              authz_cb, 0, 1, 0, 0, pool)
Exemplo n.º 4
0
Arquivo: svn_fs.py Projeto: pirapu/raj
 def get_deltas(self, old_path, old_rev, new_path, new_rev, ignore_ancestry=0):
     old_node = new_node = None
     old_rev = self.normalize_rev(old_rev)
     new_rev = self.normalize_rev(new_rev)
     if self.has_node(old_path, old_rev):
         old_node = self.get_node(old_path, old_rev)
     else:
         raise TracError, ('The Base for Diff is invalid: path %s'
                           ' doesn\'t exist in revision %s' \
                           % (old_path, old_rev))
     if self.has_node(new_path, new_rev):
         new_node = self.get_node(new_path, new_rev)
     else:
         raise TracError, ('The Target for Diff is invalid: path %s'
                           ' doesn\'t exist in revision %s' \
                           % (new_path, new_rev))
     if new_node.kind != old_node.kind:
         raise TracError, ('Diff mismatch: Base is a %s (%s in revision %s) '
                           'and Target is a %s (%s in revision %s).' \
                           % (old_node.kind, old_path, old_rev,
                              new_node.kind, new_path, new_rev))
     if new_node.isdir:
         editor = DiffChangeEditor()
         e_ptr, e_baton = delta.make_editor(editor)
         old_root = fs.revision_root(self.fs_ptr, old_rev)
         new_root = fs.revision_root(self.fs_ptr, new_rev)
         def authz_cb(root, path, pool): return 1
         text_deltas = 0 # as this is anyway re-done in Diff.py...
         entry_props = 0 # ("... typically used only for working copy updates")
         repos.svn_repos_dir_delta(old_root, old_path, '',
                                   new_root, new_path,
                                   e_ptr, e_baton, authz_cb,
                                   text_deltas,
                                   1, # directory
                                   entry_props,
                                   ignore_ancestry)
         for path, kind, change in editor.deltas:
             old_node = new_node = None
             if change != Changeset.ADD:
                 old_node = self.get_node(posixpath.join(old_path, path), old_rev)
             if change != Changeset.DELETE:
                 new_node = self.get_node(posixpath.join(new_path, path), new_rev)
             else:
                 kind = _kindmap[fs.check_path(old_root, old_node.path)]
             yield  (old_node, new_node, kind, change)
     else:
         old_root = fs.revision_root(self.fs_ptr, old_rev)
         new_root = fs.revision_root(self.fs_ptr, new_rev)
         if fs.contents_changed(old_root, old_path, new_root, new_path):
             yield (old_node, new_node, Node.FILE, Changeset.EDIT)
Exemplo n.º 5
0
def insert_change(pool, fs_ptr, rev, cursor):
    class ChangeEditor(delta.Editor):
        def __init__(self, rev, old_root, new_root, cursor):
            self.rev = rev
            self.cursor = cursor
            self.old_root = old_root
            self.new_root = new_root

        def delete_entry(self, path, revision, parent_baton, pool):
            self.cursor.execute(
                'INSERT INTO node_change (rev, name, change) '
                'VALUES (%s, %s, \'D\')', self.rev, path)

        def add_directory(self, path, parent_baton, copyfrom_path,
                          copyfrom_revision, dir_pool):
            self.cursor.execute(
                'INSERT INTO node_change (rev, name, change) '
                'VALUES (%s, %s, \'A\')', self.rev, path)

        def add_file(self, path, parent_baton, copyfrom_path,
                     copyfrom_revision, file_pool):
            self.cursor.execute(
                'INSERT INTO node_change (rev, name, change) '
                'VALUES (%s, %s, \'A\')', self.rev, path)

        def open_file(self, path, parent_baton, base_revision, file_pool):
            self.cursor.execute(
                'INSERT INTO node_change (rev, name, change) '
                'VALUES (%s, %s, \'M\')', self.rev, path)

    old_root = fs.revision_root(fs_ptr, rev - 1, pool)
    new_root = fs.revision_root(fs_ptr, rev, pool)

    editor = ChangeEditor(rev, old_root, new_root, cursor)
    e_ptr, e_baton = delta.make_editor(editor, pool)

    def authz_cb(root, path, pool):
        return 1

    repos.svn_repos_dir_delta(old_root, '', '', new_root, '', e_ptr, e_baton,
                              authz_cb, 0, 1, 0, 1, pool)
Exemplo n.º 6
0
Arquivo: svn_fs.py Projeto: t2y/trac
    def get_changes(self, old_path, old_rev, new_path, new_rev,
                    ignore_ancestry=0):
        """Determine differences between two arbitrary pairs of paths
        and revisions.

        (wraps ``repos.svn_repos_dir_delta``)
        """
        old_node = new_node = None
        old_rev = self.normalize_rev(old_rev)
        new_rev = self.normalize_rev(new_rev)
        if self.has_node(old_path, old_rev):
            old_node = self.get_node(old_path, old_rev)
        else:
            raise NoSuchNode(old_path, old_rev, 'The Base for Diff is invalid')
        if self.has_node(new_path, new_rev):
            new_node = self.get_node(new_path, new_rev)
        else:
            raise NoSuchNode(new_path, new_rev,
                             'The Target for Diff is invalid')
        if new_node.kind != old_node.kind:
            raise TracError(_('Diff mismatch: Base is a %(oldnode)s '
                              '(%(oldpath)s in revision %(oldrev)s) and '
                              'Target is a %(newnode)s (%(newpath)s in '
                              'revision %(newrev)s).', oldnode=old_node.kind,
                              oldpath=old_path, oldrev=old_rev,
                              newnode=new_node.kind, newpath=new_path,
                              newrev=new_rev))
        subpool = Pool(self.pool)
        if new_node.isdir:
            editor = DiffChangeEditor()
            e_ptr, e_baton = delta.make_editor(editor, subpool())
            old_root = fs.revision_root(self.fs_ptr, old_rev, subpool())
            new_root = fs.revision_root(self.fs_ptr, new_rev, subpool())
            def authz_cb(root, path, pool):
                return 1
            text_deltas = 0 # as this is anyway re-done in Diff.py...
            entry_props = 0 # "... typically used only for working copy updates"
            repos.svn_repos_dir_delta(old_root,
                                      _to_svn(subpool(), self.scope, old_path),
                                      '', new_root,
                                      _to_svn(subpool(), self.scope, new_path),
                                      e_ptr, e_baton, authz_cb,
                                      text_deltas,
                                      1, # directory
                                      entry_props,
                                      ignore_ancestry,
                                      subpool())
            # sort deltas by path before creating `SubversionNode`s to reduce
            # memory usage (#10978)
            deltas = sorted(((_from_svn(path), kind, change)
                             for path, kind, change in editor.deltas),
                            key=lambda entry: entry[0])
            for path, kind, change in deltas:
                old_node = new_node = None
                if change != Changeset.ADD:
                    old_node = self.get_node(posixpath.join(old_path, path),
                                             old_rev)
                if change != Changeset.DELETE:
                    new_node = self.get_node(posixpath.join(new_path, path),
                                             new_rev)
                else:
                    kind = _kindmap[fs.check_path(old_root,
                                                  _to_svn(subpool(),
                                                          self.scope,
                                                          old_node.path),
                                                  subpool())]
                yield  (old_node, new_node, kind, change)
        else:
            old_root = fs.revision_root(self.fs_ptr, old_rev, subpool())
            new_root = fs.revision_root(self.fs_ptr, new_rev, subpool())
            if fs.contents_changed(old_root,
                                   _to_svn(subpool(), self.scope, old_path),
                                   new_root,
                                   _to_svn(subpool(), self.scope, new_path),
                                   subpool()):
                yield (old_node, new_node, Node.FILE, Changeset.EDIT)
Exemplo n.º 7
0
    def _get_changes(self, old_path, old_rev, new_path, new_rev,
                     ignore_ancestry):
        old_node = new_node = None
        old_rev = self.normalize_rev(old_rev)
        new_rev = self.normalize_rev(new_rev)
        if self.has_node(old_path, old_rev):
            old_node = self.get_node(old_path, old_rev)
        else:
            raise NoSuchNode(old_path, old_rev, 'The Base for Diff is invalid')
        if self.has_node(new_path, new_rev):
            new_node = self.get_node(new_path, new_rev)
        else:
            raise NoSuchNode(new_path, new_rev,
                             'The Target for Diff is invalid')
        if new_node.kind != old_node.kind:
            raise TracError(
                _(
                    'Diff mismatch: Base is a %(oldnode)s '
                    '(%(oldpath)s in revision %(oldrev)s) and '
                    'Target is a %(newnode)s (%(newpath)s in '
                    'revision %(newrev)s).',
                    oldnode=old_node.kind,
                    oldpath=old_path,
                    oldrev=old_rev,
                    newnode=new_node.kind,
                    newpath=new_path,
                    newrev=new_rev))
        subpool = Pool(self.pool)
        if new_node.isdir:
            editor = DiffChangeEditor()
            e_ptr, e_baton = delta.make_editor(editor, subpool())
            old_root = fs.revision_root(self.fs_ptr, old_rev, subpool())
            new_root = fs.revision_root(self.fs_ptr, new_rev, subpool())

            def authz_cb(root, path, pool):
                return 1

            text_deltas = 0  # as this is anyway re-done in Diff.py...
            entry_props = 0  # "... typically used only for working copy updates"
            repos.svn_repos_dir_delta(
                old_root,
                _to_svn(subpool(), self.scope, old_path),
                '',
                new_root,
                _to_svn(subpool(), self.scope, new_path),
                e_ptr,
                e_baton,
                authz_cb,
                text_deltas,
                1,  # directory
                entry_props,
                ignore_ancestry,
                subpool())
            for path, kind, change in editor.deltas:
                path = _from_svn(path)
                old_node = new_node = None
                if change != Changeset.ADD:
                    old_node = self.get_node(posixpath.join(old_path, path),
                                             old_rev)
                if change != Changeset.DELETE:
                    new_node = self.get_node(posixpath.join(new_path, path),
                                             new_rev)
                else:
                    kind = _kindmap[fs.check_path(
                        old_root, _to_svn(subpool(), self.scope,
                                          old_node.path), subpool())]
                yield (old_node, new_node, kind, change)
        else:
            old_root = fs.revision_root(self.fs_ptr, old_rev, subpool())
            new_root = fs.revision_root(self.fs_ptr, new_rev, subpool())
            if fs.contents_changed(old_root,
                                   _to_svn(subpool(), self.scope, old_path),
                                   new_root,
                                   _to_svn(subpool(), self.scope, new_path),
                                   subpool()):
                yield (old_node, new_node, Node.FILE, Changeset.EDIT)
Exemplo n.º 8
0
    def get_changes(self, old_path, old_rev, new_path, new_rev,
                    ignore_ancestry=0):
        """Determine differences between two arbitrary pairs of paths
        and revisions.

        (wraps ``repos.svn_repos_dir_delta``)
        """
        old_node = new_node = None
        old_rev = self.normalize_rev(old_rev)
        new_rev = self.normalize_rev(new_rev)
        if self.has_node(old_path, old_rev):
            old_node = self.get_node(old_path, old_rev)
        else:
            raise NoSuchNode(old_path, old_rev, 'The Base for Diff is invalid')
        if self.has_node(new_path, new_rev):
            new_node = self.get_node(new_path, new_rev)
        else:
            raise NoSuchNode(new_path, new_rev,
                             'The Target for Diff is invalid')
        if new_node.kind != old_node.kind:
            raise TracError(_('Diff mismatch: Base is a %(oldnode)s '
                              '(%(oldpath)s in revision %(oldrev)s) and '
                              'Target is a %(newnode)s (%(newpath)s in '
                              'revision %(newrev)s).', oldnode=old_node.kind,
                              oldpath=old_path, oldrev=old_rev,
                              newnode=new_node.kind, newpath=new_path,
                              newrev=new_rev))
        subpool = Pool(self.pool)
        if new_node.isdir:
            editor = DiffChangeEditor()
            e_ptr, e_baton = delta.make_editor(editor, subpool())
            old_root = fs.revision_root(self.fs_ptr, old_rev, subpool())
            new_root = fs.revision_root(self.fs_ptr, new_rev, subpool())
            def authz_cb(root, path, pool):
                return 1
            text_deltas = 0 # as this is anyway re-done in Diff.py...
            entry_props = 0 # "... typically used only for working copy updates"
            repos.svn_repos_dir_delta(old_root,
                                      _to_svn(subpool(), self.scope, old_path),
                                      '', new_root,
                                      _to_svn(subpool(), self.scope, new_path),
                                      e_ptr, e_baton, authz_cb,
                                      text_deltas,
                                      1, # directory
                                      entry_props,
                                      ignore_ancestry,
                                      subpool())
            # sort deltas by path before creating `SubversionNode`s to reduce
            # memory usage (#10978)
            deltas = sorted(((_from_svn(path), kind, change)
                             for path, kind, change in editor.deltas),
                            key=lambda entry: entry[0])
            for path, kind, change in deltas:
                old_node = new_node = None
                if change != Changeset.ADD:
                    old_node = self.get_node(posixpath.join(old_path, path),
                                             old_rev)
                if change != Changeset.DELETE:
                    new_node = self.get_node(posixpath.join(new_path, path),
                                             new_rev)
                else:
                    kind = _kindmap[fs.check_path(old_root,
                                                  _to_svn(subpool(),
                                                          self.scope,
                                                          old_node.path),
                                                  subpool())]
                yield  (old_node, new_node, kind, change)
        else:
            old_root = fs.revision_root(self.fs_ptr, old_rev, subpool())
            new_root = fs.revision_root(self.fs_ptr, new_rev, subpool())
            if fs.contents_changed(old_root,
                                   _to_svn(subpool(), self.scope, old_path),
                                   new_root,
                                   _to_svn(subpool(), self.scope, new_path),
                                   subpool()):
                yield (old_node, new_node, Node.FILE, Changeset.EDIT)
Exemplo n.º 9
0
    def get_changes(self,
                    old_path,
                    old_rev,
                    new_path,
                    new_rev,
                    ignore_ancestry=0):
        old_node = new_node = None
        old_rev = self.normalize_rev(old_rev)
        new_rev = self.normalize_rev(new_rev)
        if self.has_node(old_path, old_rev):
            old_node = self.get_node(old_path, old_rev)
        else:
            raise NoSuchNode(
                old_path, old_rev, u'La base pour le calcul des '
                u'différences est invalide')
        if self.has_node(new_path, new_rev):
            new_node = self.get_node(new_path, new_rev)
        else:
            raise NoSuchNode(
                new_path, new_rev, u'La cible pour le calcul des '
                u'différences est invalide')
        if new_node.kind != old_node.kind:
            raise TracError(u'Erreur de calcul des différences: La base est un'
                            u'%s (%s en révision %s) '
                            u'et la cible est un %s (%s en révision %s).' \
                              % (old_node.kind, old_path, old_rev,
                                 new_node.kind, new_path, new_rev))
        subpool = Pool(self.pool)
        if new_node.isdir:
            editor = DiffChangeEditor()
            e_ptr, e_baton = delta.make_editor(editor, subpool())
            old_root = fs.revision_root(self.fs_ptr, old_rev, subpool())
            new_root = fs.revision_root(self.fs_ptr, new_rev, subpool())

            def authz_cb(root, path, pool):
                return 1

            text_deltas = 0  # as this is anyway re-done in Diff.py...
            entry_props = 0  # "... typically used only for working copy updates"
            repos.svn_repos_dir_delta(
                old_root,
                _to_svn(self.scope + old_path),
                '',
                new_root,
                _to_svn(self.scope + new_path),
                e_ptr,
                e_baton,
                authz_cb,
                text_deltas,
                1,  # directory
                entry_props,
                ignore_ancestry,
                subpool())
            for path, kind, change in editor.deltas:
                path = _from_svn(path)
                old_node = new_node = None
                if change != Changeset.ADD:
                    old_node = self.get_node(posixpath.join(old_path, path),
                                             old_rev)
                if change != Changeset.DELETE:
                    new_node = self.get_node(posixpath.join(new_path, path),
                                             new_rev)
                else:
                    kind = _kindmap[fs.check_path(
                        old_root, _to_svn(self.scope, old_node.path),
                        subpool())]
                yield (old_node, new_node, kind, change)
        else:
            old_root = fs.revision_root(self.fs_ptr, old_rev, subpool())
            new_root = fs.revision_root(self.fs_ptr, new_rev, subpool())
            if fs.contents_changed(old_root, _to_svn(self.scope, old_path),
                                   new_root, _to_svn(self.scope, new_path),
                                   subpool()):
                yield (old_node, new_node, Node.FILE, Changeset.EDIT)