• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python delta.make_editor函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中svn.delta.make_editor函数的典型用法代码示例。如果您正苦于以下问题:Python make_editor函数的具体用法?Python make_editor怎么用?Python make_editor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了make_editor函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_do_diff2

  def test_do_diff2(self):

    class ChangeReceiver(delta.Editor):
        def __init__(self):
            self.textdeltas = []

        def apply_textdelta(self, file_baton, base_checksum):
            def textdelta_handler(textdelta):
                if textdelta is not None:
                    self.textdeltas.append(textdelta)
            return textdelta_handler

    editor = ChangeReceiver()

    e_ptr, e_baton = delta.make_editor(editor)

    fs_revnum = fs.youngest_rev(self.fs)

    sess_url = ra.get_session_url(self.ra_ctx)
    try:
        ra.reparent(self.ra_ctx, REPOS_URL+"/trunk")
        reporter, reporter_baton = ra.do_diff2(self.ra_ctx, fs_revnum,
                                               "README.txt", 0, 0, 1,
                                               REPOS_URL+"/trunk/README.txt",
                                               e_ptr, e_baton)
        reporter.set_path(reporter_baton, "", 0, True, None)
        reporter.finish_report(reporter_baton)
    finally:
        ra.reparent(self.ra_ctx, sess_url)
      
    self.assertEqual("A test.\n", editor.textdeltas[0].new_data)
    self.assertEqual(1, len(editor.textdeltas))
开发者ID:vocho,项目名称:openqnx,代码行数:32,代码来源:ra.py


示例2: _print_tree

  def _print_tree(self, e_factory, base_rev=None, pass_root=0):
    if base_rev is None:
      # a specific base rev was not provided. use the transaction base,
      # or the previous revision
      if self.txn_ptr:
        base_rev = fs.txn_base_revision(self.txn_ptr)
      else:
        base_rev = self.rev - 1

    # get the current root
    if self.txn_ptr:
      root = fs.txn_root(self.txn_ptr)
    else:
      root = fs.revision_root(self.fs_ptr, self.rev)

    # the base of the comparison
    base_root = fs.revision_root(self.fs_ptr, base_rev)

    if pass_root:
      editor = e_factory(root, base_root)
    else:
      editor = e_factory()

    # construct the editor for printing these things out
    e_ptr, e_baton = delta.make_editor(editor)

    # compute the delta, printing as we go
    def authz_cb(root, path, pool):
      return 1
    repos.dir_delta(base_root, '', '', root, '',
		    e_ptr, e_baton, authz_cb, 0, 1, 0, 0)
开发者ID:AsherBond,项目名称:MondocosmOS-Dependencies,代码行数:31,代码来源:svnlook.py


示例3: inner

def inner(pool, path, rev):
    repos_ptr = repos.svn_repos_open(path, pool)
    fs_ptr = repos.svn_repos_fs(repos_ptr)

    root = fs.revision_root(fs_ptr, rev, pool)
    base_rev = rev - 1

    # get all changes
    editor = repos.RevisionChangeCollector(fs_ptr, rev, pool)
    e_ptr, e_baton = delta.make_editor(editor, pool)
    repos.svn_repos_replay(root, e_ptr, e_baton, pool)

    changelist = editor.changes.items()
    changelist.sort()

    base_root = fs.revision_root(fs_ptr, base_rev, pool)

    l = []
    for filepath, change in changelist:
        d = {'path': filepath, 'info': ''}
        if change.path:
            if change.added:
                d['action'] = 'new'
            else:
                d['action'] = 'modify'
                differ = fs.FileDiff(base_root, change.path, root, filepath,
                    pool, '-L \t(original) -L \t(new) -u'.split(' '))
                d['info'] = differ.get_pipe().read()
        else:
            d['action'] = 'delete'
        l.append(d)
    return l
开发者ID:BackupTheBerlios,项目名称:cctools-svn,代码行数:32,代码来源:revision_info.py


示例4: main

def main(pool, repos_dir, txn):
  # Construct a ChangeCollector to fetch our changes.
  fs_ptr = repos.svn_repos_fs(repos.svn_repos_open(repos_dir, pool))
  root = fs.txn_root(fs.open_txn(fs_ptr, txn, pool), pool)
  cc = repos.ChangeCollector(fs_ptr, root, pool)

  # Call the transaction property validator.  Might as well get the
  # cheap checks outta the way first.
  retval = test_props(cc.get_root_props())
  if retval:
    return retval

  # Generate the path-based changes list.
  e_ptr, e_baton = delta.make_editor(cc, pool)
  repos.svn_repos_replay(root, e_ptr, e_baton, pool)

  # Call the path change validator.
  changes = cc.get_changes()
  paths = changes.keys()
  paths.sort(lambda a, b: core.svn_path_compare_paths(a, b))
  for path in paths:
    change = changes[path]
    retval = test_path_change(path, change)
    if retval:
      return retval
    
  return 0
开发者ID:jiangxin,项目名称:pySvnManager,代码行数:27,代码来源:pre-commit-check.py


示例5: load

    def load(self, repo_path):
	repo_path = core.svn_path_canonicalize(repo_path)
	repos_ptr = repos.open(repo_path)
	fs_ptr = repos.fs(repos_ptr)
	rev = fs.youngest_rev(fs_ptr)
	base_root = fs.revision_root(fs_ptr, 0)
	root = fs.revision_root(fs_ptr, rev)
	hist = fs.node_history(root, self.root)
	while hist is not None:
	    hist = fs.history_prev(hist,0)
	    dummy,rev = fs.history_location(hist)
	    d = fs.revision_prop(fs_ptr, rev, core.SVN_PROP_REVISION_DATE)
	    author = fs.revision_prop(fs_ptr, rev, \
		    core.SVN_PROP_REVISION_AUTHOR)
	    if author == 'svnadmin':
		continue
	    self.last_author = author
	    self.last_date = core.svn_time_from_cstring(d) / 1000000
	    self.last_rev = rev
	    def authz_cb(root, path, pool):
		return 1
	    editor = SvnDumperEditor(self)
	    e_ptr, e_baton = delta.make_editor(editor)
	    repos.dir_delta(base_root, '', '', root, self.root, e_ptr, e_baton,
		authz_cb, 0, 1, 0, 0)
	    break
开发者ID:juanfra684,项目名称:cvs2gitdump,代码行数:26,代码来源:cvs2svndump.py


示例6: _print_tree

  def _print_tree(self, e_factory, rootpath='', base_rev=None, pass_root=0):
    # It no longer prints, it returns the editor made by e_factory which
    # contains the tree in a list.
    if base_rev is None:
      # a specific base rev was not provided. use the transaction base,
      # or the previous revision
      if self.txn_ptr:
        base_rev = fs.txn_base_revision(self.txn_ptr)
      else:
        base_rev = self.rev - 1

    # get the current root
    if self.txn_ptr:
      root = fs.txn_root(self.txn_ptr, self.pool)
    else:
      root = fs.revision_root(self.fs_ptr, self.rev, self.pool)

    # the base of the comparison
    base_root = fs.revision_root(self.fs_ptr, base_rev, self.pool)

    if pass_root:
      editor = e_factory(root, base_root)
    else:
      editor = e_factory()

    # construct the editor for printing these things out
    e_ptr, e_baton = delta.make_editor(editor, self.pool)

    # compute the delta, printing as we go
    def authz_cb(root, path, pool):
      return 1
    repos.dir_delta(base_root, '', '', root, rootpath.encode('utf-8'),
                    e_ptr, e_baton, authz_cb, 0, 1, 0, 0, self.pool)
    return editor
开发者ID:gotgit,项目名称:doc-svn_hooks,代码行数:34,代码来源:check-case-insensitive.py


示例7: get_changes

 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)
开发者ID:cyphactor,项目名称:lifecyclemanager,代码行数:59,代码来源:svn_fs.py


示例8: get_revision

    def get_revision(self, revision, editor):
        ''' feed the contents of the given revision to the given editor '''

        e_ptr, e_baton = delta.make_editor(editor)

        reporter, reporter_baton = ra.do_update(self.ra, revision, "", True,
                                                e_ptr, e_baton)

        reporter.set_path(reporter_baton, "", revision, True, None)
        reporter.finish_report(reporter_baton)
开发者ID:avuori,项目名称:dotfiles,代码行数:10,代码来源:svn_swig_wrapper.py


示例9: test_unnamed_editor

 def test_unnamed_editor(self):
     """Test editor object without reference from interpreter"""
     # Check that the delta.Editor object has proper lifetime. Without
     # increment of the refcount in make_baton, the object was destroyed
     # immediately because the interpreter does not hold a reference to it.
     this_root = fs.revision_root(self.fs, self.rev)
     prev_root = fs.revision_root(self.fs, self.rev-1)
     e_ptr, e_baton = delta.make_editor(ChangeReceiver(this_root, prev_root))
     repos.dir_delta(prev_root, '', '', this_root, '', e_ptr, e_baton,
             _authz_callback, 1, 1, 0, 0)
开发者ID:gunjanms,项目名称:svnmigration,代码行数:10,代码来源:repository.py


示例10: check_po

def check_po(pool, repos_path, txn):
    def authz_cb(root, path, pool):
        return 1

    fs_ptr = repos.fs(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.dir_delta(base_root, "", "", txn_root, "", e_ptr, e_baton, authz_cb, 0, 1, 0, 0, pool)
开发者ID:gotgit,项目名称:doc-svn_hooks,代码行数:11,代码来源:verify-po.py


示例11: test_update

  def test_update(self):
    class TestEditor(delta.Editor):
        pass

    editor = TestEditor()

    e_ptr, e_baton = delta.make_editor(editor)

    reporter, reporter_baton = ra.do_update(self.ra_ctx, 10, "", True, e_ptr, e_baton)

    reporter.set_path(reporter_baton, "", 0, True, None)

    reporter.finish_report(reporter_baton)
开发者ID:vocho,项目名称:openqnx,代码行数:13,代码来源:ra.py


示例12: test_dir_delta

  def test_dir_delta(self):
    """Test scope of dir_delta callbacks"""
    # Run dir_delta
    this_root = fs.revision_root(self.fs, self.rev)
    prev_root = fs.revision_root(self.fs, self.rev-1)
    editor = ChangeReceiver(this_root, prev_root)
    e_ptr, e_baton = delta.make_editor(editor)
    repos.dir_delta(prev_root, '', '', this_root, '', e_ptr, e_baton,
                    _authz_callback, 1, 1, 0, 0)

    # Check results
    self.assertEqual(editor.textdeltas[0].new_data, "This is a test.\n")
    self.assertEqual(editor.textdeltas[1].new_data, "A test.\n")
    self.assertEqual(len(editor.textdeltas),2)
开发者ID:vocho,项目名称:openqnx,代码行数:14,代码来源:repository.py


示例13: get_changes

    def get_changes(self):
        root = fs.revision_root(self.fs_ptr, self.rev)
        editor = repos.RevisionChangeCollector(self.fs_ptr, self.rev)
        e_ptr, e_baton = delta.make_editor(editor)
        repos.svn_repos_replay(root, e_ptr, e_baton)

        idx = 0
        copies, deletions = {}, {}
        changes = []
        for path, change in editor.changes.items():
            if not self.authz.has_permission(path):
                # FIXME: what about base_path?
                continue
            if not path.startswith(self.scope[1:]):
                continue
            base_path = None
            if change.base_path:
                if change.base_path.startswith(self.scope):
                    base_path = change.base_path[len(self.scope):]
                else:
                    base_path = None
            action = ''
            if not change.path:
                action = Changeset.DELETE
                deletions[change.base_path] = idx
            elif change.added:
                if change.base_path and change.base_rev:
                    action = Changeset.COPY
                    copies[change.base_path] = idx
                else:
                    action = Changeset.ADD
            else:
                action = Changeset.EDIT
            kind = _kindmap[change.item_kind]
            path = path[len(self.scope) - 1:]
            changes.append([path, kind, action, base_path, change.base_rev])
            idx += 1

        moves = []
        for k,v in copies.items():
            if k in deletions:
                changes[v][2] = Changeset.MOVE
                moves.append(deletions[k])
        offset = 0
        for i in moves:
            del changes[i - offset]
            offset += 1

        for change in changes:
            yield tuple(change)
开发者ID:vocho,项目名称:openqnx,代码行数:50,代码来源:svn_fs.py


示例14: get_replay

 def get_replay(self, revision, editor, oldest_rev_i_have=0):
     # this method has a tendency to chew through RAM if you don't re-init
     self.init_ra_and_client()
     e_ptr, e_baton = delta.make_editor(editor)
     try:
         ra.replay(self.ra, revision, oldest_rev_i_have, True, e_ptr,
                   e_baton, self.pool)
     except core.SubversionException, e: #pragma: no cover
         # can I depend on this number being constant?
         if (e.apr_err == core.SVN_ERR_RA_NOT_IMPLEMENTED or
             e.apr_err == core.SVN_ERR_UNSUPPORTED_FEATURE):
             raise SubversionRepoCanNotReplay, ('This Subversion server '
                'is older than 1.4.0, and cannot satisfy replay requests.')
         else:
             raise
开发者ID:chaptastic,项目名称:config_files,代码行数:15,代码来源:svn_swig_wrapper.py


示例15: get_revision_info

def get_revision_info(svnrepos, rev):
  fsroot = svnrepos._getroot(rev)

  # Get the changes for the revision
  cps = ChangedPathSet()
  editor = repos.ChangeCollector(svnrepos.fs_ptr, fsroot,
                                 svnrepos.pool, cps.add_change)
  e_ptr, e_baton = delta.make_editor(editor, svnrepos.pool)
  repos.svn_repos_replay(fsroot, e_ptr, e_baton, svnrepos.pool)

  # Now get the revision property info.  Would use
  # editor.get_root_props(), but something is broken there...
  datestr, author, msg = _fs_rev_props(svnrepos.fs_ptr, rev, svnrepos.pool)
  date = _datestr_to_date(datestr, svnrepos.pool)

  return date, author, msg, cps.get_changes()
开发者ID:pombredanne,项目名称:fusionforge,代码行数:16,代码来源:__init__.py


示例16: test_dir_delta

  def test_dir_delta(self):
    """Test scope of dir_delta callbacks"""
    # Run dir_delta
    this_root = fs.revision_root(self.fs, self.rev)
    prev_root = fs.revision_root(self.fs, self.rev-1)
    editor = ChangeReceiver(this_root, prev_root)
    e_ptr, e_baton = delta.make_editor(editor)
    repos.dir_delta(prev_root, '', '', this_root, '', e_ptr, e_baton,
                    _authz_callback, 1, 1, 0, 0)

    # Check results.
    # Ignore the order in which the editor delivers the two sibling files.
    self.assertEqual(set([editor.textdeltas[0].new_data,
                          editor.textdeltas[1].new_data]),
                     set(["This is a test.\n", "A test.\n"]))
    self.assertEqual(len(editor.textdeltas), 2)
开发者ID:gunjanms,项目名称:svnmigration,代码行数:16,代码来源:repository.py


示例17: __init__

  def __init__(self, path, rev, txn):
    self.repo_root_path = core.svn_path_canonicalize(path)
    
    root_ptr = repos.open(self.repo_root_path)
    self.fs_ptr = repos.fs(root_ptr)

    # Set the revision/transaction
    if txn:
      self.txn_ptr = fs.open_txn(self.fs_ptr, txn)
    else:
      self.txn_ptr = None
      if rev is None:
          rev = fs.youngest_rev(self.fs_ptr)
    self.rev = rev

    # Set the root
    if self.txn_ptr:
      self.root = fs.txn_root(self.txn_ptr)
    else:
      self.root = fs.revision_root(self.fs_ptr, self.rev)

    # Set the base revision/transaction
    if self.txn_ptr:
      self.base_rev = fs.txn_base_revision(self.txn_ptr)
    else:
      self.base_rev = self.rev - 1

    # Set the base root of the comparison
    self.base_root = fs.revision_root(self.fs_ptr, self.base_rev)

    # Get all the changes and sort by path
    editor = repos.ChangeCollector(self.fs_ptr, self.root)
    e_ptr, e_baton = delta.make_editor(editor)
    repos.replay(self.root, e_ptr, e_baton)

    self.changelist = editor.get_changes().items()

    self.changelist.sort()
开发者ID:marcellodesales,项目名称:svnedge-integration-ctf,代码行数:38,代码来源:SubversionUtil.py


示例18: get_changes

 def get_changes(self):
     pool = Pool(self.pool)
     tmp = Pool(pool)
     root = fs.revision_root(self.fs_ptr, self.rev, pool())
     editor = repos.RevisionChangeCollector(self.fs_ptr, self.rev, pool())
     e_ptr, e_baton = delta.make_editor(editor, pool())
     repos.svn_repos_replay(root, e_ptr, e_baton, pool())
     
     idx = 0
     copies, deletions = {}, {}
     changes = []
     revroots = {}
     for path, change in editor.changes.items():
         if not (_is_path_within_scope(self.scope, path)):
             continue
         
         path = change.path
         base_path = change.base_path
         base_rev = change.base_rev
         
         if not (_is_path_within_scope(self.scope, base_path)):
             base_path, base_rev = None, -1
         
         if not path:
             if base_path:
                 if base_path in deletions:
                     continue
                 action = 'D'
                 deletions[base_path] = idx
             elif self.scope == '/':
                 action = 'E'
             else:
                 continue
         elif change.added or not base_path:
             action = 'A'
             if base_path and base_rev:
                 action = 'C'
                 copies[base_path] = idx
         else:
             action = 'E'
             if revroots.has_key(base_rev):
                 b_root = revroots[base_rev]
             else:
                 b_root = fs.revision_root(self.fs_ptr, base_rev, pool())
                 revroots[base_rev] = b_root
             tmp.clear()
             cbase_path = fs.node_created_path(b_root, base_path, tmp())
             cbase_rev = fs.node_created_rev(b_root, base_path, tmp())
             
             if _is_path_within_scope(self.scope, cbase_path):
                 base_path, base_rev = cbase_path, cbase_rev
         kind = _kindmap[change.item_kind]
         path = _path_within_scope(self.scope, _from_svn(path or base_path))
         base_path = _path_within_scope(self.scope, _from_svn(base_path))
         changes.append({'path': path, 'kind': kind, 'action': action,
                         'base_path': base_path, 'base_rev': base_rev})
         idx += 1
     
     moves = []
     for k,v in copies.items():
         if k in deletions:
             changes[v]['action'] = 'M'
             moves.append(deletions[k])
     offset = 0
     moves.sort()
     for i in moves:
         del changes[i - offset]
         offset += 1
     
     changes.sort()
     for change in changes:
         yield change
开发者ID:damoxc,项目名称:snakepit,代码行数:72,代码来源:svnclient.py


示例19: get_changes

    def get_changes(self):
        pool = Pool(self.pool)
        tmp = Pool(pool)
        root = fs.revision_root(self.fs_ptr, self.rev, pool())
        editor = repos.RevisionChangeCollector(self.fs_ptr, self.rev, pool())
        e_ptr, e_baton = delta.make_editor(editor, pool())
        repos.svn_repos_replay(root, e_ptr, e_baton, pool())

        idx = 0
        copies, deletions = {}, {}
        changes = []
        revroots = {}
        for path, change in editor.changes.items():
            
            # Filtering on `path`
            if not (_is_path_within_scope(self.scope, path) and \
                    self.authz.has_permission(path)):
                continue

            path = change.path
            base_path = change.base_path
            base_rev = change.base_rev

            # Ensure `base_path` is within the scope
            if not (_is_path_within_scope(self.scope, base_path) and \
                    self.authz.has_permission(base_path)):
                base_path, base_rev = None, -1

            # Determine the action
            if not path:                # deletion
                if base_path:
                    if base_path in deletions:
                        continue # duplicates on base_path are possible (#3778)
                    action = Changeset.DELETE
                    deletions[base_path] = idx
                elif self.scope:        # root property change
                    action = Changeset.EDIT
                else:                   # deletion outside of scope, ignore
                    continue
            elif change.added or not base_path: # add or copy
                action = Changeset.ADD
                if base_path and base_rev:
                    action = Changeset.COPY
                    copies[base_path] = idx
            else:
                action = Changeset.EDIT
                # identify the most interesting base_path/base_rev
                # in terms of last changed information (see r2562)
                if revroots.has_key(base_rev):
                    b_root = revroots[base_rev]
                else:
                    b_root = fs.revision_root(self.fs_ptr, base_rev, pool())
                    revroots[base_rev] = b_root
                tmp.clear()
                cbase_path = fs.node_created_path(b_root, base_path, tmp())
                cbase_rev = fs.node_created_rev(b_root, base_path, tmp()) 
                # give up if the created path is outside the scope
                if _is_path_within_scope(self.scope, cbase_path):
                    base_path, base_rev = cbase_path, cbase_rev

            kind = _kindmap[change.item_kind]
            path = _path_within_scope(self.scope, _from_svn(path or base_path))
            base_path = _path_within_scope(self.scope, _from_svn(base_path))
            changes.append([path, kind, action, base_path, base_rev])
            idx += 1

        moves = []
        for k,v in copies.items():
            if k in deletions:
                changes[v][2] = Changeset.MOVE
                moves.append(deletions[k])
        offset = 0
        moves.sort()
        for i in moves:
            del changes[i - offset]
            offset += 1

        changes.sort()
        for change in changes:
            yield tuple(change)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:80,代码来源:svn_fs.py


示例20: get_changes

    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)
开发者ID:pkdevbox,项目名称:trac,代码行数:76,代码来源:svn_fs.py



注:本文中的svn.delta.make_editor函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python fs.check_path函数代码示例发布时间:2022-05-27
下一篇:
Python core.svn_pool_create函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap