Review of a new extension (hg remap) that I am working on
Martin Geisler
mg at lazybytes.net
Mon Jun 14 19:15:47 UTC 2010
Didly Bom <didlybom at gmail.com> writes:
Hey
> I found this to be a good idea, and I though that this may be an easy
> thing to implement as a mercurial extension. So I've been thinking
> about this for a while, trying to imagine what such an extension
> should do and how it could work. This week-end I had some spare time
> and decided to try to start a little extension that would implement
> this idea. I've tentativelly called it "remap" since the idea is that
> you can "remap" version tracked files into non version tracked files.
>
> [...]
I think the idea is interesting, so you should do some experiments and
see how it works out.
> I have already written some source code (which is _very_ preliminary)
> but which can already add the "remap" command to mercurial, which
> reads an .hgremap file and does all the copying as expected. What does
> not work yet is:
>
> - The automatic triggering upon update: Is there a way to have an
> extension attach itself to the update hook without needing to have
> the user manually setup the hook?).
Yes, an extension can register a hook -- here is an example:
http://selenic.com/hg/file/5bf465160632/hgext/eol.py#l130
> - I am using "print" to output information and error messages, but I
> assume that there is a way to use mercurial itself to print those
> (perhaps via the "ui" object). Maybe you can point me to the
> corresponding documentation and best practices.
There you go:
http://mercurial.selenic.com/wiki/MercurialApi#Communicating_with_the_User
> - I am not yet checking that the target files are not version
> controlled by mercurial (which should trigger an error). Probably
> there is a way to do so via the "repo" object?
Something like
if target in repo['.']:
# target is already version controlled
raise util.Abort(_("bad luck, %s is under version control") % target)
should do it.
> - The "force" option is not implemented yet.
> - Maybe I could add a "reverse map" command which could go the opposite way
> (copying targets to sources). This could even be executed as a pre-commit
> hook. This behaviour could be enabled or disabled via the extension
> configuration.
>
> So what do you think? I would really appreciate any feedback that you guys
> could provide me. I could also share the code that I have already written
> (BTW, what would be the best way to do so? Through a bitbucket project?)
Yes, putting a Mercurial repository online is indeed a very good way to
share things :)
--
Martin Geisler
See my Mercurial presentation: http://vimeo.com/11497288
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.mercurial-scm.org/pipermail/mercurial/attachments/20100614/ebe59f55/attachment.asc>
More information about the Mercurial
mailing list