Re: Getting a LineOfDevelopment object from branch name

Michael Haggerty <[email protected]>
Newsgroups gmane.comp.version-control.subversion.cvs2svn.devel
Message-ID <[email protected]>
Greg Ward wrote:
> in HgOutputOption and related code, I occasionally need to dig up the
> Trunk instance used to represent CVS trunk in this conversion, or the
> Branch object used to represent some CVS branch.  I'm handling it by
> keeping a dict from branch name (or "trunk") to LineOfDevelopment
> object, which I populate in process_initial_commit() and
> process_branch_commit().  This seems fine, but I was wondering if
> there is an easier way -- did I miss some global mapping of
> LineOfDevelopment objects?

Since, when converting to Subversion, cvs2svn can handle multi-project
conversions, there is a separate Trunk instance for each project.  Its
ID is stored in Project.trunk_id during CollectRevsPass, and the Trunk
object itself can be retrieved using Project.get_trunk().

All LinesOfDevelopment, including the Trunk objects and ExcludedSymbols,
are available from Ctx()._symbol_db during most passes (including
OutputPass).  This is a mapping from ID -> LOD object.  But everything
is in memory, so it is cheap to iterate over all symbols:

symbol_map = {}
for symbol in Ctx()._symbol_db:
  if isinstance(symbol, (Branch, Tag)):
    symbol_map[symbol.name] = symbol
  elif isinstance(symbol, Trunk):
    symbol_map[SPECIAL_TRUNK_KEY] = symbol

Please note that Symbol.name contains the symbol name *after* any symbol
transforms, which is not necessarily the same as the original CVS symbol
name.  (Transformed symbol names and CVS symbol names are not even
necessarily 1:1.)  The pre-transformed name is not recorded anywhere.

Hope that helps,
Michael

------------------------------------------------------
http://cvs2svn.tigris.org/ds/viewMessage.do?dsForumId=1667&dsMessageId=2385004

To unsubscribe from this discussion, e-mail: [[email protected]].
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.