Re: Tracking "branch heads"

Michael Haggerty <[email protected]> Thu, 17 Dec 2009 09:28:55 +0100
Newsgroups gmane.comp.version-control.subversion.cvs2svn.devel
Message-ID <[email protected]>
Greg Ward wrote:
> On Mon, Dec 14, 2009 at 3:19 PM, Greg Ward <[email protected]> wrote:
>> Cool.  OK, here is a preliminary draft.  This passes its test, but I
>> have not yet used it in production.  I'll see how the design actually
>> works within the next 24 hours.  For your amusement...
> 
> It works, but the first thing I had to do with the LOD->head revnum
> mapping is invert it.  That is, at any point in the conversion, I need
> to know if the current svn_commit is the head of a branch.  So I first
> had to write this code in my custom HgOutputOption subclass:
> 
>         if self.head_revs is None:
>             file =
> open(artifact_manager.get_temp_file(config.SVN_BRANCH_HEADS), 'rb')
>             branch_heads = cPickle.load(file)
>             file.close()
> 
>             self.head_revs = {}
>             for ((id, name), revnum) in branch_heads.items():
>                 self.head_revs[revnum] = (id, name)
> 
> Then I can use self.head_revs during the course of the conversion.
> 
> Obviously, this data has to be gathered as a branch/LOD -> revnum
> mapping.  But its only user to date (me) actually needs the inverse
> mapping.  My inclination is to leave the svn_branch_heads.pck file
> as-is, because that's the smallest patch to cvs2svn.  Anyone who knows
> enough to open and read that file probably also knows how to invert a
> dictionary.  But there is the chance that I'll be imposing those extra
> 3 lines on every future user of this mapping.
> 
> Can you think of other reasons why knowing branch heads would be
> useful, and whether those uses are more likely to want branch->revnum
> or revnum->branch?

Vanilla cvs2svn (like CVS) allows cross-branch commits; that is, a
single commit that affects more than one branch.  In that case the
mapping is not 1:1 so the map cannot, in general, be inverted.

So storing the map branch->revnum seems more appropriate.

Is there a reason to store the branch name in addition to the branch id?
 Usually symbols can be looked up via the in-memory SymbolDatabase,
which is available in Ctx()._symbol_db during most passes.

Michael

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

To unsubscribe from this discussion, e-mail: [[email protected]].