[PATCH] Built-in cvsps for hg cvsimport

Frank Kingswood frank at kingswood-consulting.co.uk
Fri Apr 4 10:27:33 CDT 2008


Dean Roehrich wrote:
> On Thu, Apr 03, 2008 at 10:45:40PM +0100, Frank Kingswood wrote:
>> When a log message includes the text {{mergefrombranch X}} then cvsps
>> will set a second parent for a changeset. When a log message includes
>> the text {{mergetobranch X}} then cvsps will insert a dummy changeset
>> (with no members, so no changes) merging the branch into the named
>> branch (which must exist).
> 
> I can imagine everyone having to customize those merge*branch strings for
> their own CVS customs.  Our repository uses strange tags (I've never
> deciphered them) to mark these tobranch/frombranch areas.

Actually this can be customized easily: just put the regular expressions 
in the .hgrc, defaulting to these (or perhaps to not doing any matching 
at all). As long as the re contains a group that I can fish out then it 
will work.

>> diff -r 6c4e12682fb9 -r 236da9d3c013 hgext/convert/convcmd.py
>> --- a/hgext/convert/convcmd.py	Thu Apr 03 13:47:05 2008 +0200
>> +++ b/hgext/convert/convcmd.py	Thu Apr 03 22:42:37 2008 +0100
>> @@ -290,7 +290,7 @@
>>                  # convert log message to local encoding without using
>>                  # tolocal() because util._encoding conver() use it as
>>                  # 'utf-8'
>> -                self.ui.status("%d %s\n" % (num, recode(desc)))
>> +                self.ui.status(util.ellipsis("%d %s\n" % (num, recode(desc)),80))
>>                  self.ui.note(_("source: %s\n" % recode(c)))
>>                  self.copy(c)
> 
> That seems like it doesn't belong in this patch.

Right, I'll remove that.

>> diff -r 6c4e12682fb9 -r 236da9d3c013 hgext/convert/cvs.py
>> --- a/hgext/convert/cvs.py	Thu Apr 03 13:47:05 2008 +0200
>> +++ b/hgext/convert/cvs.py	Thu Apr 03 22:42:37 2008 +0100
> 
>> +                # external cvsps
>> +                for l in util.popen(cmd):
>> +                    if state == 0: # header
>> +                        if l.startswith("PatchSet"):
>> +                            id = l[9:-2]
>> +                            if maxrev and int(id) > maxrev:
>> +                                # ignore everything
>> +                                state = 3
>> +                        elif l.startswith("Date"):
>> +                            date = util.parsedate(l[6:-1], ["%Y/%m/%d %H:%M:%S"])
>> +                            date = util.datestr(date)
>> +                        elif l.startswith("Branch"):
>> +                            branch = l[8:-1]
>> +                            self.parent[id] = self.lastbranch.get(branch, 'bad')
> 
> Hmm, you're keeping that 'bad'?  While you're messing with this code... :)

I did not want to mess with the external cvsps code at all. It should be 
identical to what it was, but unfortunately because of an indent it does 
not look like it.

> If I tell hg convert in hg 1.0 to handle patchsets from tag1 to tag2, then I
> hit this and walktree() gets 'bad' as a parent from cachecommit() and then
> things crumble.

Yeah, I'm not surprised. I might experiment with partial conversions 
using the builtin code and see if it can be made to work.

> You will begin printing when you find the patchset that matches the first -r
> argument.  But cvsps2.1 will begin printing with the patchset that _follows_
> that one (I explicitly called this out in my patch to you).

OK, will fix that.

Frank



More information about the Mercurial-devel mailing list