当前位置: 首页>>代码示例>>Python>>正文


Python KeyGenerator.gen_id方法代码示例

本文整理汇总了Python中cvs2svn_lib.key_generator.KeyGenerator.gen_id方法的典型用法代码示例。如果您正苦于以下问题:Python KeyGenerator.gen_id方法的具体用法?Python KeyGenerator.gen_id怎么用?Python KeyGenerator.gen_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cvs2svn_lib.key_generator.KeyGenerator的用法示例。


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

示例1: ExternalBlobGenerator

# 需要导入模块: from cvs2svn_lib.key_generator import KeyGenerator [as 别名]
# 或者: from cvs2svn_lib.key_generator.KeyGenerator import gen_id [as 别名]
class ExternalBlobGenerator(RevisionCollector):
    """Have generate_blobs.py output file revisions to a blob file."""

    def __init__(self, blob_filename):
        self.blob_filename = blob_filename

    def start(self):
        self._mark_generator = KeyGenerator()
        logger.normal("Starting generate_blobs.py...")
        self._popen = subprocess.Popen(
            [sys.executable, os.path.join(os.path.dirname(__file__), "generate_blobs.py"), self.blob_filename],
            stdin=subprocess.PIPE,
        )

    def _process_symbol(self, cvs_symbol, cvs_file_items):
        """Record the original source of CVS_SYMBOL.

    Determine the original revision source of CVS_SYMBOL, and store it
    as the symbol's revision_reader_token."""

        cvs_source = cvs_symbol.get_cvs_revision_source(cvs_file_items)
        cvs_symbol.revision_reader_token = cvs_source.revision_reader_token

    def process_file(self, cvs_file_items):
        marks = {}
        for lod_items in cvs_file_items.iter_lods():
            for cvs_rev in lod_items.cvs_revisions:
                if not isinstance(cvs_rev, CVSRevisionDelete):
                    mark = self._mark_generator.gen_id()
                    cvs_rev.revision_reader_token = mark
                    marks[cvs_rev.rev] = mark

        # A separate pickler is used for each dump(), so that its memo
        # doesn't grow very large.  The default ASCII protocol is used so
        # that this works without changes on systems that distinguish
        # between text and binary files.
        pickle.dump((cvs_file_items.cvs_file.rcs_path, marks), self._popen.stdin)
        self._popen.stdin.flush()

        # Now that all CVSRevisions' revision_reader_tokens are set,
        # iterate through symbols and set their tokens to those of their
        # original source revisions:
        for lod_items in cvs_file_items.iter_lods():
            if lod_items.cvs_branch is not None:
                self._process_symbol(lod_items.cvs_branch, cvs_file_items)
            for cvs_tag in lod_items.cvs_tags:
                self._process_symbol(cvs_tag, cvs_file_items)

    def finish(self):
        self._popen.stdin.close()
        logger.normal("Waiting for generate_blobs.py to finish...")
        returncode = self._popen.wait()
        if returncode:
            raise FatalError("generate_blobs.py failed with return code %s." % (returncode,))
        else:
            logger.normal("generate_blobs.py is done.")
开发者ID:GymWenFLL,项目名称:tpp_libs,代码行数:58,代码来源:external_blob_generator.py

示例2: project_id

# 需要导入模块: from cvs2svn_lib.key_generator import KeyGenerator [as 别名]
# 或者: from cvs2svn_lib.key_generator.KeyGenerator import gen_id [as 别名]
class MetadataLogger:
  """Store and generate IDs for the metadata associated with CVSRevisions.

  We want CVSRevisions that might be able to be combined to have the
  same metadata ID, so we want a one-to-one relationship id <->
  metadata.  We could simply construct a map {metadata : id}, but the
  map would grow too large.  Therefore, we generate a digest
  containing the significant parts of the metadata, and construct a
  map {digest : id}.

  To get the ID for a new set of metadata, we first create the digest.
  If there is already an ID registered for that digest, we simply
  return it.  If not, we generate a new ID, store the metadata in the
  metadata database under that ID, record the mapping {digest : id},
  and return the new id.

  What metadata is included in the digest?  The author, log_msg,
  project_id (if Ctx().cross_project_commits is not set), and
  branch_name (if Ctx().cross_branch_commits is not set)."""

  def __init__(self, metadata_db):
    self._metadata_db = metadata_db

    # A map { digest : id }:
    self._digest_to_id = {}

    # A key_generator to generate keys for metadata that haven't been
    # seen yet:
    self.key_generator = KeyGenerator()

  def store(self, project, branch_name, author, log_msg):
    """Store the metadata and return its id.

    Locate the record for a commit with the specified (PROJECT,
    BRANCH_NAME, AUTHOR, LOG_MSG) and return its id.  (Depending on
    policy, not all of these items are necessarily used when creating
    the unique id.)  If there is no such record, create one and return
    its newly-generated id."""

    key = [author, log_msg]
    if not Ctx().cross_project_commits:
      key.append('%x' % project.id)
    if not Ctx().cross_branch_commits:
      key.append(branch_name or '')

    digest = sha.new('\0'.join(key)).digest()
    try:
      # See if it is already known:
      return self._digest_to_id[digest]
    except KeyError:
      id = self.key_generator.gen_id()
      self._digest_to_id[digest] = id
      self._metadata_db[id] = Metadata(id, author, log_msg)
      return id
开发者ID:c0ns0le,项目名称:cygwin,代码行数:56,代码来源:metadata_database.py

示例3: __init__

# 需要导入模块: from cvs2svn_lib.key_generator import KeyGenerator [as 别名]
# 或者: from cvs2svn_lib.key_generator.KeyGenerator import gen_id [as 别名]
class Substituter:
    def __init__(self, template):
        self.template = template
        self.key_generator = KeyGenerator(1)

        # A map from old values to new ones.
        self.substitutions = {}

    def get_substitution(self, s):
        r = self.substitutions.get(s)
        if r == None:
            r = self.template % self.key_generator.gen_id()
            self.substitutions[s] = r
        return r
开发者ID:akiernan,项目名称:cvs2svn,代码行数:16,代码来源:destroy_repository.py

示例4: start_commit

# 需要导入模块: from cvs2svn_lib.key_generator import KeyGenerator [as 别名]
# 或者: from cvs2svn_lib.key_generator.KeyGenerator import gen_id [as 别名]

#.........这里部分代码省略.........

    lod_history = self._get_lod_history(lod)
    id = lod_history.get_id(revnum)
    return OldMirrorDirectory(self, id, self._node_db[id])

  def get_old_path(self, cvs_path, lod, revnum):
    """Return the node for CVS_PATH from LOD at REVNUM.

    If CVS_PATH is a CVSDirectory, then return an instance of
    OldMirrorDirectory.  If CVS_PATH is a CVSFile, return None.

    If CVS_PATH does not exist in the specified LOD and REVNUM, raise
    KeyError."""

    node = self.get_old_lod_directory(lod, revnum)

    for sub_path in cvs_path.get_ancestry()[1:]:
      node = node[sub_path]

    return node

  def get_current_lod_directory(self, lod):
    """Return the directory for the root path of LOD in the current revision.

    Return an instance of CurrentMirrorDirectory.  Raise KeyError if
    the path doesn't already exist."""

    lod_history = self._get_lod_history(lod)
    id = lod_history.get_current_id()
    try:
      return self._new_nodes[id]
    except KeyError:
      return _CurrentMirrorReadOnlyLODDirectory(
          self, id, lod, self._node_db[id]
          )

  def get_current_path(self, cvs_path, lod):
    """Return the node for CVS_PATH from LOD in the current revision.

    If CVS_PATH is a CVSDirectory, then return an instance of
    CurrentMirrorDirectory.  If CVS_PATH is a CVSFile, return None.

    If CVS_PATH does not exist in the current revision of the
    specified LOD, raise KeyError."""

    node = self.get_current_lod_directory(lod)

    for sub_path in cvs_path.get_ancestry()[1:]:
      node = node[sub_path]

    return node

  def add_lod(self, lod):
    """Create a new LOD in this repository.

    Return the CurrentMirrorDirectory that was created.  If the LOD
    already exists, raise LODExistsError."""

    lod_history = self._get_lod_history(lod)
    if lod_history.exists():
      raise LODExistsError(
          'Attempt to create %s in repository mirror when it already exists.'
          % (lod,)
          )
    new_node = _CurrentMirrorWritableLODDirectory(
        self, self._key_generator.gen_id(), lod, {}
        )
    lod_history.update(self._youngest, new_node.id)
    self._new_nodes[new_node.id] = new_node
    return new_node

  def copy_lod(self, src_lod, dest_lod, src_revnum):
    """Copy all of SRC_LOD at SRC_REVNUM to DST_LOD.

    In the youngest revision of the repository, the destination LOD
    *must not* already exist.

    Return the new node at DEST_LOD, as a CurrentMirrorDirectory."""

    # Get the node of our src_path
    src_node = self.get_old_lod_directory(src_lod, src_revnum)

    dest_lod_history = self._get_lod_history(dest_lod)
    if dest_lod_history.exists():
      raise LODExistsError(
          'Attempt to copy to %s in repository mirror when it already exists.'
          % (dest_lod,)
          )

    dest_lod_history.update(self._youngest, src_node.id)

    # Return src_node, except packaged up as a CurrentMirrorDirectory:
    return self.get_current_lod_directory(dest_lod)

  def close(self):
    """Free resources and close databases."""

    self._lod_histories = None
    self._node_db.close()
    self._node_db = None
开发者ID:SEGaL-Group,项目名称:scm2pgsql,代码行数:104,代码来源:repository_mirror.py

示例5: GitOutputOption

# 需要导入模块: from cvs2svn_lib.key_generator import KeyGenerator [as 别名]
# 或者: from cvs2svn_lib.key_generator.KeyGenerator import gen_id [as 别名]
class GitOutputOption(DVCSOutputOption):
  """An OutputOption that outputs to a git-fast-import formatted file.

  Members:

    dump_filename -- (string) the name of the file to which the
        git-fast-import commands for defining revisions will be
        written.

    author_transforms -- a map from CVS author names to git full name
        and email address.  See
        DVCSOutputOption.normalize_author_transforms() for information
        about the form of this parameter.

  """

  name = "Git"

  # The first mark number used for git-fast-import commit marks.  This
  # value needs to be large to avoid conflicts with blob marks.
  _first_commit_mark = 1000000000

  def __init__(
        self, dump_filename, revision_writer,
        author_transforms=None,
        tie_tag_fixup_branches=False,
        ):
    """Constructor.

    DUMP_FILENAME is the name of the file to which the git-fast-import
    commands for defining revisions should be written.  (Please note
    that depending on the style of revision writer, the actual file
    contents might not be written to this file.)

    REVISION_WRITER is a GitRevisionWriter that is used to output
    either the content of revisions or a mark that was previously used
    to label a blob.

    AUTHOR_TRANSFORMS is a map {cvsauthor : (fullname, email)} from
    CVS author names to git full name and email address.  All of the
    contents should either be Unicode strings or 8-bit strings encoded
    as UTF-8.

    TIE_TAG_FIXUP_BRANCHES means whether after finishing with a tag
    fixup branch, it should be psuedo-merged (ancestry linked but no
    content changes) back into its source branch, to dispose of the
    open head.

    """
    DVCSOutputOption.__init__(self)
    self.dump_filename = dump_filename
    self.revision_writer = revision_writer

    self.author_transforms = self.normalize_author_transforms(
        author_transforms
        )

    self.tie_tag_fixup_branches = tie_tag_fixup_branches

    self._mark_generator = KeyGenerator(GitOutputOption._first_commit_mark)

  def register_artifacts(self, which_pass):
    DVCSOutputOption.register_artifacts(self, which_pass)
    self.revision_writer.register_artifacts(which_pass)

  def check_symbols(self, symbol_map):
    # FIXME: What constraints does git impose on symbols?
    pass

  def setup(self, svn_rev_count):
    DVCSOutputOption.setup(self, svn_rev_count)
    self.f = open(self.dump_filename, 'wb')

    # The youngest revnum that has been committed so far:
    self._youngest = 0

    # A map {lod : [(revnum, mark)]} giving each of the revision
    # numbers in which there was a commit to lod, and the mark active
    # at the end of the revnum.
    self._marks = {}

    self.revision_writer.start(self._mirror, self.f)

  def _create_commit_mark(self, lod, revnum):
    mark = self._mark_generator.gen_id()
    self._set_lod_mark(lod, revnum, mark)
    return mark

  def _set_lod_mark(self, lod, revnum, mark):
    """Record MARK as the status of LOD for REVNUM.

    If there is already an entry for REVNUM, overwrite it.  If not,
    append a new entry to the self._marks list for LOD."""

    assert revnum >= self._youngest
    entry = (revnum, mark)
    try:
      modifications = self._marks[lod]
    except KeyError:
      # This LOD hasn't appeared before; create a new list and add the
#.........这里部分代码省略.........
开发者ID:robinst,项目名称:cvs2svn,代码行数:103,代码来源:git_output_option.py

示例6: GitRevisionRecorder

# 需要导入模块: from cvs2svn_lib.key_generator import KeyGenerator [as 别名]
# 或者: from cvs2svn_lib.key_generator.KeyGenerator import gen_id [as 别名]
class GitRevisionRecorder(FulltextRevisionRecorder):
  """Output file revisions to git-fast-import."""

  def __init__(self, blob_filename):
    self.blob_filename = blob_filename

  def start(self):
    self.dump_file = open(self.blob_filename, 'wb')
    self._mark_generator = KeyGenerator()

  def start_file(self, cvs_file_items):
    self._cvs_file_items = cvs_file_items

  def _get_original_source(self, cvs_rev):
    """Return the original source of the contents of CVS_REV.

    Return the first non-delete CVSRevision with the same contents as
    CVS_REV.  'First' here refers to deltatext order; i.e., the very
    first revision is HEAD on trunk, then backwards to the root of a
    branch, then out to the tip of a branch.

    The candidates are all revisions along the CVS delta-dependency
    chain until the next one that has a deltatext (inclusive).  Of the
    candidates, CVSRevisionDeletes are disqualified because, even
    though CVS records their contents, it is impossible to extract
    their fulltext using commands like 'cvs checkout -p'.

    If there is no other CVSRevision that has the same content, return
    CVS_REV itself."""

    # Keep track of the "best" source CVSRevision found so far:
    best_source_rev = None

    for cvs_rev in itertools.chain(
          [cvs_rev], self._cvs_file_items.iter_deltatext_ancestors(cvs_rev)
          ):
      if not isinstance(cvs_rev, CVSRevisionDelete):
        best_source_rev = cvs_rev

      if cvs_rev.deltatext_exists:
        break

    return best_source_rev

  def record_fulltext(self, cvs_rev, log, fulltext):
    """Write the fulltext to a blob if it is original and not a delete.

    The reason we go to this trouble is to avoid writing the same file
    contents multiple times for a string of revisions that don't have
    deltatexts (as, for example, happens with dead revisions and
    imported revisions)."""

    if isinstance(cvs_rev, CVSRevisionDelete):
      # There is no need to record a delete revision, and its token
      # will never be needed:
      return None

    source = self._get_original_source(cvs_rev)

    if source.id == cvs_rev.id:
      # Revision is its own source; write it out:
      mark = self._mark_generator.gen_id()
      self.dump_file.write('blob\n')
      self.dump_file.write('mark :%d\n' % (mark,))
      self.dump_file.write('data %d\n' % (len(fulltext),))
      self.dump_file.write(fulltext)
      self.dump_file.write('\n')
      return mark
    else:
      # Return as revision_recorder_token the CVSRevision.id of the
      # original source revision:
      return source.revision_recorder_token

  def finish_file(self, cvs_file_items):
    # Determine the original source of each CVSSymbol, and store it as
    # the symbol's revision_recorder_token.
    for cvs_item in cvs_file_items.values():
      if isinstance(cvs_item, CVSSymbol):
        cvs_source = cvs_item.get_cvs_revision_source(cvs_file_items)
        cvs_item.revision_recorder_token = cvs_source.revision_recorder_token

    del self._cvs_file_items

  def finish(self):
    self.dump_file.close()
开发者ID:SEGaL-Group,项目名称:scm2pgsql,代码行数:87,代码来源:git_revision_recorder.py

示例7: add_delegate

# 需要导入模块: from cvs2svn_lib.key_generator import KeyGenerator [as 别名]
# 或者: from cvs2svn_lib.key_generator.KeyGenerator import gen_id [as 别名]

#.........这里部分代码省略.........
    self._new_nodes = {}

    self._invoke_delegates('start_commit', revnum, revprops)

  def end_commit(self):
    """Called at the end of each commit.

    This method copies the newly created nodes to the on-disk nodes
    db."""

    # Copy the new nodes to the _nodes_db
    for id, value in self._new_nodes.items():
      self._nodes_db[id] = value

    del self._new_nodes

    self._invoke_delegates('end_commit')

  def _get_lod_history(self, lod):
    """Return the LODHistory instance describing LOD.

    Create a new (empty) LODHistory if it doesn't yet exist."""

    try:
      return self._lod_histories[lod]
    except KeyError:
      lod_history = LODHistory()
      self._lod_histories[lod] = lod_history
      return lod_history

  def _create_empty_node(self):
    """Create and return a new, empty, writable node."""

    new_node = _WritableMirrorNode(self, self._key_generator.gen_id(), {})
    self._new_nodes[new_node.id] = new_node.entries
    return new_node

  def _copy_node(self, old_node):
    """Create and return a new, writable node that is a copy of OLD_NODE."""

    new_node = _WritableMirrorNode(
        self, self._key_generator.gen_id(), old_node.entries.copy()
        )

    self._new_nodes[new_node.id] = new_node.entries
    return new_node

  def _get_node(self, id):
    """Return the node for id ID.

    The node might be read from either self._nodes_db or
    self._new_nodes.  Return an instance of _MirrorNode."""

    try:
      return _WritableMirrorNode(self, id, self._new_nodes[id])
    except KeyError:
      return _ReadOnlyMirrorNode(self, id, self._nodes_db[id])

  def _open_readonly_lod_node(self, lod, revnum):
    """Open a readonly node for the root path of LOD at revision REVNUM.

    Return an instance of _MirrorNode if the path exists; otherwise,
    raise KeyError."""

    lod_history = self._get_lod_history(lod)
    node_id = lod_history.get_id(revnum)
开发者ID:c0ns0le,项目名称:cygwin,代码行数:70,代码来源:svn_repository_mirror.py

示例8: GitRevisionCollector

# 需要导入模块: from cvs2svn_lib.key_generator import KeyGenerator [as 别名]
# 或者: from cvs2svn_lib.key_generator.KeyGenerator import gen_id [as 别名]
class GitRevisionCollector(RevisionCollector):
  """Output file revisions to git-fast-import."""

  def __init__(self, revision_reader, blob_filename=None):
    self.revision_reader = revision_reader
    self.blob_filename = blob_filename

  def register_artifacts(self, which_pass):
    self.revision_reader.register_artifacts(which_pass)
    if self.blob_filename is None:
      artifact_manager.register_temp_file(
        config.GIT_BLOB_DATAFILE, which_pass,
        )

  def start(self):
    self.revision_reader.start()
    if self.blob_filename is None:
      self.dump_file = open(
          artifact_manager.get_temp_file(config.GIT_BLOB_DATAFILE), 'wb',
          )
    else:
      self.dump_file = open(self.blob_filename, 'wb')
    self._mark_generator = KeyGenerator()

  def _process_revision(self, cvs_rev):
    """Write the revision fulltext to a blob if it is not dead."""

    if isinstance(cvs_rev, CVSRevisionDelete):
      # There is no need to record a delete revision, and its token
      # will never be needed:
      return

    # FIXME: We have to decide what to do about keyword substitution
    # and eol_style here:
    fulltext = self.revision_reader.get_content(cvs_rev)

    mark = self._mark_generator.gen_id()
    self.dump_file.write('blob\n')
    self.dump_file.write('mark :%d\n' % (mark,))
    self.dump_file.write('data %d\n' % (len(fulltext),))
    self.dump_file.write(fulltext)
    self.dump_file.write('\n')
    cvs_rev.revision_reader_token = mark

  def _process_symbol(self, cvs_symbol, cvs_file_items):
    """Record the original source of CVS_SYMBOL.

    Determine the original revision source of CVS_SYMBOL, and store it
    as the symbol's revision_reader_token."""

    cvs_source = cvs_symbol.get_cvs_revision_source(cvs_file_items)
    cvs_symbol.revision_reader_token = cvs_source.revision_reader_token

  def process_file(self, cvs_file_items):
    for lod_items in cvs_file_items.iter_lods():
      for cvs_rev in lod_items.cvs_revisions:
        self._process_revision(cvs_rev)

    # Now that all CVSRevisions' revision_reader_tokens are set,
    # iterate through symbols and set their tokens to those of their
    # original source revisions:
    for lod_items in cvs_file_items.iter_lods():
      if lod_items.cvs_branch is not None:
        self._process_symbol(lod_items.cvs_branch, cvs_file_items)
      for cvs_tag in lod_items.cvs_tags:
        self._process_symbol(cvs_tag, cvs_file_items)

  def finish(self):
    self.revision_reader.finish()
    self.dump_file.close()
开发者ID:mddtrifecta,项目名称:cvs2svn,代码行数:72,代码来源:git_revision_collector.py

示例9: process_changeset

# 需要导入模块: from cvs2svn_lib.key_generator import KeyGenerator [as 别名]
# 或者: from cvs2svn_lib.key_generator.KeyGenerator import gen_id [as 别名]
class SVNCommitCreator:
  """This class creates and yields SVNCommits via process_changeset()."""

  def __init__(self):
    # The revision number to assign to the next new SVNCommit.
    self.revnum_generator = KeyGenerator()

    # A set containing the Projects that have already been
    # initialized:
    self._initialized_projects = set()

  def _post_commit(self, cvs_revs, motivating_revnum, timestamp):
    """Generate any SVNCommits needed to follow CVS_REVS.

    That is, handle non-trunk default branches.  A revision on a CVS
    non-trunk default branch is visible in a default CVS checkout of
    HEAD.  So we copy such commits over to Subversion's trunk so that
    checking out SVN trunk gives the same output as checking out of
    CVS's default branch."""

    cvs_revs = [
          cvs_rev
          for cvs_rev in cvs_revs
          if cvs_rev.ntdbr and not isinstance(cvs_rev, CVSRevisionNoop)
          ]

    if cvs_revs:
      cvs_revs.sort(
          lambda a, b: cmp(a.cvs_file.rcs_path, b.cvs_file.rcs_path)
          )
      # Generate an SVNCommit for all of our default branch cvs_revs.
      yield SVNPostCommit(
          motivating_revnum, cvs_revs, timestamp,
          self.revnum_generator.gen_id(),
          )

  def _process_revision_changeset(self, changeset, timestamp):
    """Process CHANGESET, using TIMESTAMP as the commit time.

    Create and yield one or more SVNCommits in the process.  CHANGESET
    must be an OrderedChangeset.  TIMESTAMP is used as the timestamp
    for any resulting SVNCommits."""

    if not changeset.cvs_item_ids:
      logger.warn('Changeset has no items: %r' % changeset)
      return

    logger.verbose('-' * 60)
    logger.verbose('CVS Revision grouping:')
    logger.verbose('  Time: %s' % time.ctime(timestamp))

    # Generate an SVNCommit unconditionally.  Even if the only change in
    # this group of CVSRevisions is a deletion of an already-deleted
    # file (that is, a CVS revision in state 'dead' whose predecessor
    # was also in state 'dead'), the conversion will still generate a
    # Subversion revision containing the log message for the second dead
    # revision, because we don't want to lose that information.

    cvs_revs = list(changeset.iter_cvs_items())
    if cvs_revs:
      cvs_revs.sort(lambda a, b: cmp(a.cvs_file.rcs_path, b.cvs_file.rcs_path))
      svn_commit = SVNPrimaryCommit(
          cvs_revs, timestamp, self.revnum_generator.gen_id()
          )

      yield svn_commit

      for cvs_rev in cvs_revs:
        Ctx()._symbolings_logger.log_revision(cvs_rev, svn_commit.revnum)

      # Generate an SVNPostCommit if we have default branch revs.  If
      # some of the revisions in this commit happened on a non-trunk
      # default branch, then those files have to be copied into trunk
      # manually after being changed on the branch (because the RCS
      # "default branch" appears as head, i.e., trunk, in practice).
      # Unfortunately, Subversion doesn't support copies with sources
      # in the current txn.  All copies must be based in committed
      # revisions.  Therefore, we generate the copies in a new
      # revision.
      for svn_post_commit in self._post_commit(
            cvs_revs, svn_commit.revnum, timestamp
            ):
        yield svn_post_commit

  def _process_tag_changeset(self, changeset, timestamp):
    """Process TagChangeset CHANGESET, producing a SVNTagCommit.

    Filter out CVSTagNoops.  If no CVSTags are left, don't generate a
    SVNTagCommit."""

    if Ctx().trunk_only:
      raise InternalError(
          'TagChangeset encountered during a --trunk-only conversion')

    cvs_tag_ids = [
        cvs_tag.id
        for cvs_tag in changeset.iter_cvs_items()
        if not isinstance(cvs_tag, CVSTagNoop)
        ]
    if cvs_tag_ids:
#.........这里部分代码省略.........
开发者ID:SayCV,项目名称:tools-cvs2svn,代码行数:103,代码来源:svn_commit_creator.py

示例10: GitRevisionRecorder

# 需要导入模块: from cvs2svn_lib.key_generator import KeyGenerator [as 别名]
# 或者: from cvs2svn_lib.key_generator.KeyGenerator import gen_id [as 别名]
class GitRevisionRecorder(FulltextRevisionRecorder):
  """Output file revisions to git-fast-import."""

  def __init__(self, blob_filename):
    self.blob_filename = blob_filename

  def start(self):
    self.dump_file = open(self.blob_filename, 'wb')
    self._mark_generator = KeyGenerator()

  def start_file(self, cvs_file_items):
    self._cvs_file_items = cvs_file_items

  def _get_original_source(self, cvs_rev):
    """Return the first CVSRevision with the content of CVS_REV.

    'First' here refers to deltatext order; i.e., the very first
    revision is HEAD on trunk, then backwards to the root of a branch,
    then out to the tip of a branch.

    If there is no other CVSRevision that have the same content,
    return CVS_REV itself."""

    while True:
      if cvs_rev.deltatext_exists:
        return cvs_rev
      if isinstance(cvs_rev.lod, Trunk):
        if cvs_rev.next_id is None:
          # The HEAD revision on trunk is always its own source, even
          # if its deltatext (i.e., its fulltext) is empty:
          return cvs_rev
        else:
          cvs_rev = self._cvs_file_items[cvs_rev.next_id]
      else:
        cvs_rev = self._cvs_file_items[cvs_rev.prev_id]

  def record_fulltext(self, cvs_rev, log, fulltext):
    """Write the fulltext to a blob if it is original.

    To find the 'original' revision, we follow the CVS
    delta-dependency chain backwards until we find a file that has a
    deltatext.  The reason we go to this trouble is to avoid writing
    the same file contents multiple times for a string of revisions
    that don't have deltatexts (as, for example, happens with dead
    revisions and imported revisions)."""

    source = self._get_original_source(cvs_rev)

    if source.id == cvs_rev.id:
      # Revision is its own source; write it out:
      mark = self._mark_generator.gen_id()
      self.dump_file.write('blob\n')
      self.dump_file.write('mark :%d\n' % (mark,))
      self.dump_file.write('data %d\n' % (len(fulltext),))
      self.dump_file.write(fulltext)
      self.dump_file.write('\n')
      return mark
    else:
      # Return as revision_recorder_token the CVSRevision.id of the
      # original source revision:
      return source.revision_recorder_token

  def finish_file(self, cvs_file_items):
    # Determine the original source of each CVSSymbol, and store it as
    # the symbol's revision_recorder_token.
    for cvs_item in cvs_file_items.values():
      if isinstance(cvs_item, CVSSymbol):
        cvs_source = cvs_file_items[cvs_item.source_id]
        while not isinstance(cvs_source, CVSRevision):
          cvs_source = cvs_file_items[cvs_source.source_id]
        cvs_item.revision_recorder_token = cvs_source.revision_recorder_token

    del self._cvs_file_items

  def finish(self):
    self.dump_file.close()
开发者ID:c0ns0le,项目名称:cygwin,代码行数:78,代码来源:git_revision_recorder.py

示例11: GitOutputOption

# 需要导入模块: from cvs2svn_lib.key_generator import KeyGenerator [as 别名]
# 或者: from cvs2svn_lib.key_generator.KeyGenerator import gen_id [as 别名]

#.........这里部分代码省略.........
    if Ctx().cross_project_commits:
      raise FatalError(
          'Git output is not supported with cross-project commits'
          )
    if Ctx().cross_branch_commits:
      raise FatalError(
          'Git output is not supported with cross-branch commits'
          )
    if Ctx().username is None:
      raise FatalError(
          'Git output requires a default commit username'
          )

  def check_symbols(self, symbol_map):
    # FIXME: What constraints does git impose on symbols?
    pass

  def setup(self, svn_rev_count):
    self._symbolings_reader = SymbolingsReader()
    self.f = open(self.dump_filename, 'wb')

    # The youngest revnum that has been committed so far:
    self._youngest = 0

    # A map {lod : [(revnum, mark)]} giving each of the revision
    # numbers in which there was a commit to lod, and the mark active
    # at the end of the revnum.
    self._marks = {}

    self._mirror.open()
    self.revision_writer.start(self.f, self._mirror)

  def _create_commit_mark(self, lod, revnum):
    mark = self._mark_generator.gen_id()
    self._set_lod_mark(lod, revnum, mark)
    return mark

  def _set_lod_mark(self, lod, revnum, mark):
    """Record MARK as the status of LOD for REVNUM.

    If there is already an entry for REVNUM, overwrite it.  If not,
    append a new entry to the self._marks list for LOD."""

    assert revnum >= self._youngest
    entry = (revnum, mark)
    try:
      modifications = self._marks[lod]
    except KeyError:
      # This LOD hasn't appeared before; create a new list and add the
      # entry:
      self._marks[lod] = [entry]
    else:
      # A record exists, so it necessarily has at least one element:
      if modifications[-1][0] == revnum:
        modifications[-1] = entry
      else:
        modifications.append(entry)
    self._youngest = revnum

  def _get_author(self, svn_commit):
    """Return the author to be used for SVN_COMMIT.

    Return the author in the form needed by git; that is, 'foo <bar>'."""

    author = svn_commit.get_author()
    (name, email,) = self.author_transforms.get(author, (author, author,))
开发者ID:SEGaL-Group,项目名称:scm2pgsql,代码行数:70,代码来源:git_output_option.py


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