convert-repo fixups
authormpm@selenic.com
Wed, 22 Jun 2005 11:21:04 -0800
changeset 431 dfc44f3f587c
parent 430 5b22029b5aa2
child 432 3b9e3d3d2810
convert-repo fixups -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 convert-repo fixups - - deal with octopus merge uniqueify parent list add a series of identical commits with "(octopus merge fixup)" - - add "committer" field from git to the commit message manifest hash: e33d802afe35edecfc5cc9b567def6db2b0cb885 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCubogywK+sNU5EO8RAkWgAJ9OVHeumKd/nRIfvS/nQ9eSbORqNgCgpBIE Dza0L59OSJHHmm3Dbp7ygds= =OEvJ -----END PGP SIGNATURE-----
contrib/convert-repo
--- a/contrib/convert-repo	Tue Jun 21 21:07:08 2005 -0800
+++ b/contrib/convert-repo	Wed Jun 22 11:21:04 2005 -0800
@@ -69,6 +69,12 @@
                 date = " ".join(p[-2:])
                 author = " ".join(p[:-2])
                 if author[0] == "<": author = author[1:-1]
+            if n == "committer": 
+                p = v.split()
+                date = " ".join(p[-2:])
+                committer = " ".join(p[:-2])
+                if committer[0] == "<": committer = committer[1:-1]
+                message += "\ncommitter: %s %s\n" % (committer, date)
             if n == "parent": parents.append(v)
         return (parents, author, date, message)
 
@@ -95,14 +101,27 @@
             pass
 
     def putcommit(self, files, parents, author, dest, text):
-        p1, p2 = "0"*40, "0"*40
-        if len(parents) > 0: p1 = parents[0]
-        if len(parents) > 1: p2 = parents[1]
-        if len(parents) > 2: raise "the dreaded octopus merge!"
-        self.repo.rawcommit(files, text, author, dest, 
-                            hg.bin(p1), hg.bin(p2))
+        if not parents: parents = ["0" * 40]
+        if len(parents) < 2: parents.append("0" * 40)
+
+        seen = {}
+        pl = []
+        for p in parents:
+            if p not in seen:
+                pl.append(p)
+                seen[p] = 1
+        parents = pl
 
-        return hg.hex(self.repo.changelog.tip())
+        p2 = parents.pop(0)
+        c = self.repo.changelog.count()
+        while parents:
+            p1 = p2
+            p2 = parents.pop(0)
+            self.repo.rawcommit(files, text, author, dest, 
+                                hg.bin(p1), hg.bin(p2))
+            text = "(octopus merge fixup)\n"
+
+        return hg.hex(self.repo.changelog.node(c))
 
 class convert:
     def __init__(self, source, dest, mapfile):