[ANN] tagmerge - an extension for merging .hgtags

Qi Yang qi.yang137 at gmail.com
Thu Apr 1 00:32:57 CDT 2010


Hi, Greg, Benjamin:

I just pushed some change in tagmerge on bitbucket. Please take a look at it
when you have time.
I have some concerns about the change. I'm hoping to get some suggestions
from you:

1. From line 73, I initialized a lot of tag dict. It looks quite ugly. Is
there a better way of doing this?
2. When tagmerge fails, it will give the following warning:
>>   merging .hgtags
>>   There are conflicts in the tags.Please merge the tags manually.
>>   merging .hgtags failed!
>>   0 files updated, 0 files merged, 0 files removed, 1 files unresolved
>>   use 'hg resolve' to retry unresolved file merges or 'hg update -C' to
abandon
(only "There are conflicts in the tags.Please merge the tags manually." is
from tagmerg)
Are there too many warning or they are fine? Do we want more information in
the warning message?
3. When I did "hg log" after tagmerge, the log message is only "Add
<tagname> to changeset xxxx" instead of " tagmerge .hgtags files" as I
hoped. This is because _tag function doesn't commit the change. I think this
behaviour is ok. Users can specify the message when they actually check in
the .hgtags file. But, in this case, should I just pass empty string as
message since it is useless anyways?
4. A lot of function I use in tagmerge, i.e. _tag(), are private functions.
Is that ok?
5. This is how i modified localrepo.py:
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -206,12 +206,14 @@
         if '.hgtags' not in self.dirstate:
             self.add(['.hgtags'])

+        for name in names:
+            self.hook('tag', node=hex(node), tag=name, local=local)
+
+    def _committags(self, message, user, date, extra={}):
+
         m = match_.exact(self.root, '', ['.hgtags'])
         tagnode = self.commit(message, user, date, extra=extra, match=m)

-        for name in names:
-            self.hook('tag', node=hex(node), tag=name, local=local)
-
         return tagnode

     def tag(self, names, node, message, local, user, date):
@@ -242,6 +244,7 @@

         self.tags() # instantiate the cache
         self._tag(names, node, message, local, user, date)
+        self._committags(message, user, date)

     def tags(self):
         '''return a mapping of tag to node'''

I think maybe I should keep _tag() as it is (i.e. still do commit and return
tagnode) since someone may use it and expecting return value. Again, I'm not
quite sure if we are supposed to use private functions, if not, this should
be fine.

I'm still working on test files for tagmerge, but please let me know what
you think about tagmerge.

Thanks,
Wendy


On Thu, Feb 18, 2010 at 9:47 PM, Greg Ward <greg-hg at gerg.ca> wrote:

> On Thu, Feb 18, 2010 at 2:34 PM, Qi Yang <qi.yang137 at gmail.com> wrote:
> > Thanks, Greg and Benoit for your suggestions. They are vey helpful.
> >
> > I made some changes in tagmerge to use "findglobaltag" and "_readtag" for
> > reading tags. It was successful. I updated it under
> >
> > https://q6yang@bitbucket.org/q6yang/tagmerge/
> >
> > However, when i do write tag using "tag()" in localrepo.py It always gets
> > locked. Did I use this method wrong?
>
> 1) I presume 'tagmerge' is an external script that hg runs like any
> other merge tool: correct?
> 2) from the stack trace, it looks like tagmerge is trying to add a new
> tag. That requires committing. But you're in the middle of a merge!
> Presumably the 'hg' process doing the merge holds a lock which
> tagmerge then tries to get in order to commit.  No wonder it doesn't
> work.
>
> So why is tagmerge trying to commit?  Merge tools should just write to
> the working directory.
>
> Greg
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20100401/17d97228/attachment.htm>


More information about the Mercurial-devel mailing list