Re: PATCHES: more refactoring and skeletal cvs2hg

Greg Ward <[email protected]>
Newsgroups gmane.comp.version-control.subversion.cvs2svn.devel
Message-ID <[email protected]>
On Mon, Aug 31, 2009 at 11:37 AM, Michael Haggerty<[email protected]> wrote:
> I don't understand the problem.  If hg_main() is defined within
> hg_run_options.py, and the latter imports the Mercurial API as a
> file-level import, then cvs2hg only needs to import hg_run_options.py.
> The other cvs2xxx scripts don't need to import (or even know about)
> hg_run_options.py so they won't have any import problems.

Duh.  Yes.  Of course.  You're absolutely right.  Moving *_main() out
of main.py to *_run_options.py would make life simpler.

> But you don't have to worry about this.  I'll look at it again after you
> have submitted more of your code.

Great!

>> Why not just put it in cvs2svn_lib/__init__.py?  That would enable a
>> fairly simple idiom:
>>
>>   import cvs2svn_lib
>>   cvs2svn_lib.check_python_version()
>>
>> which could be the same in each cvs2* script as well as run-tests.py.
>> That means __init__.py must be tiny and compatible with everything
>> from 1.5.2 to 3.1, which I *think* is possible.
>
> If were were willing to forgo the name of the script in the error
> messages, then we could put the whole test inline in __init__.py.  Since
> __init__.py is always executed before importing any other modules in the
> package, this would guard all cvs2svn_lib modules without the importing
> module having to do anything special.

1) you don't have to forgo the script name: just use sys.argv[0]

2) I don't like doing stuff automatically at import time; it's bound
to cause problems for someone somewhere.  Just too magical.  The cost
of an extra line of code is pretty small, and it benefits clarity and
predictability.

(Imagine if 'hg convert' or 'bzr-fast-import' started using
cvs2svn_lib as a library, rather than as an external script.  It would
be rather surprising if importing the library had the potential to
print an error message about "this is the wrong Python version for
{hg,bzr}".)

Greg

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

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.