contrib/convert-repo
changeset 1656 14d73fff4c45
parent 1655 7bfd4724932a
child 1715 40346aa66b0f
equal deleted inserted replaced
1655:7bfd4724932a 1656:14d73fff4c45
    19 #
    19 #
    20 # This updates the mapfile on each commit copied, so it can be
    20 # This updates the mapfile on each commit copied, so it can be
    21 # interrupted and can be run repeatedly to copy new commits.
    21 # interrupted and can be run repeatedly to copy new commits.
    22 
    22 
    23 import sys, os, zlib, sha, time
    23 import sys, os, zlib, sha, time
    24 from mercurial import hg, ui, util
    24 from mercurial import hg, ui, util, commands
    25 
    25 
    26 class convert_git:
    26 class convert_git:
    27     def __init__(self, path):
    27     def __init__(self, path):
    28         self.path = path
    28         self.path = path
    29 
    29 
   111             os.unlink(self.repo.wjoin(f))
   111             os.unlink(self.repo.wjoin(f))
   112             #self.repo.remove([f])
   112             #self.repo.remove([f])
   113         except:
   113         except:
   114             pass
   114             pass
   115 
   115 
   116     def putcommit(self, files, parents, author, dest, text):
   116     def putcommit(self, files, parents, author, date, text):
   117         seen = {}
   117         seen = {}
   118         pl = []
   118         pl = []
   119         for p in parents:
   119         for p in parents:
   120             if p not in seen:
   120             if p not in seen:
   121                 pl.append(p)
   121                 pl.append(p)
   127         p2 = parents.pop(0)
   127         p2 = parents.pop(0)
   128 
   128 
   129         while parents:
   129         while parents:
   130             p1 = p2
   130             p1 = p2
   131             p2 = parents.pop(0)
   131             p2 = parents.pop(0)
   132             self.repo.rawcommit(files, text, author, dest,
   132             self.repo.dirstate.setparents(hg.bin(p1), hg.bin(p2))
   133                                 hg.bin(p1), hg.bin(p2))
   133             if len(files) > 0:
       
   134                 olddir = os.getcwd()
       
   135                 os.chdir(self.path)
       
   136                 commands.addremove(self.repo.ui, self.repo, *files)
       
   137                 os.chdir(olddir)
       
   138             self.repo.commit(files, text, author, date)
   134             text = "(octopus merge fixup)\n"
   139             text = "(octopus merge fixup)\n"
   135             p2 = hg.hex(self.repo.changelog.tip())
   140             p2 = hg.hex(self.repo.changelog.tip())
   136 
   141 
   137         return p2
   142         return p2
   138 
   143