[rfc patch convert] generalize repository logic

Edouard Gomez ed.gomez at free.fr
Tue Jun 19 12:33:35 CDT 2007


On Mon, 18 Jun 2007 14:56:02 -0500, Hollis Blanchard wrote:

> (This patch applies after my earlier convert patches.)
> 
> I'm trying to create a Git backend for 'convert' (which currently only
> outputs to Mercurial repositories). Before doing that though, the
> generic convert logic needs a little refactoring.
> 
> In particular, this patch moves the destination creation logic into each
> repository, which changes the interface a little because we need to
> specify when to create a new repo and when not to.
> 
> Further, we need to be able to guess what type of repository to create
> in the case that the destination repository does not yet exist. Doing
> that by repository name seems natural, and as long as we're doing that,
> we might as well do it for all repository types, so let's consolidate
> the source/sink interfaces and lists.
> 
> Any comments?

Concerning the patches:
 1 - The converter tables could ask the converter class to give its own
     name instead of having one hardcoded. Why not extend the interfaces
     to have some gettype() function that returns cvs|hg|git
 2 - Instead of having the repo creation logic plugged into the
     constructor why not make it an explicit method of the sink interface
     eg: initdestination(self, dirname). With one, it's easy to create
     dirname = sourcename + '.' + converter_sink.gettype()
 3 - If 2 is fullfilled, then no need to merge sink and source interfaces.
     Both interfaces define two different sets of supported operations, i
     don't see why they must be merged. If you really want a 
     BothSourceAndSink interface, then create a class:
      Converter(converter_sink, converter_source)
     But converter_git could just inherit from both (if my python foo
     is not mistaken).

-- 
Edouard Gomez



More information about the Mercurial-devel mailing list