diff hgfastimport/hgimport.py @ 73:a99e5c6c8e1c

Fix compatibility with 4.6+ Update to work with hg 4.5+ Switch to modern @command decorator API Adds compatiblility with hg 4.2 Clean up formatting and add description Update to work with hg 3.4+ Update to work with hg 3.2+ This breaks compatibility with <3.2. Merged from patches from github:danielj7/hg-fastimport
author Daniel Johnson <daniel@daniel-johnson.org>
date Sun, 12 Aug 2018 07:54:35 -0400
parents 5dc3ab8142d5
children a4f13dc5e3f7
line wrap: on
line diff
--- a/hgfastimport/hgimport.py	Fri Dec 13 22:38:47 2013 -0500
+++ b/hgfastimport/hgimport.py	Sun Aug 12 07:54:35 2018 -0400
@@ -26,6 +26,8 @@
 import sys
 
 from hgext.convert import common, hg as converthg
+from mercurial import util
+from mercurial.i18n import _
 
 from fastimport import processor, parser
 
@@ -34,11 +36,12 @@
     """Interface between the fastimport processor below and Mercurial's
     normal conversion infrastructure.
     """
-    def __init__(self, ui, repo, sources):
+    def __init__(self, ui, repotype, repo, sources):
         self.ui = ui
         self.sources = sources
         self.processor = HgImportProcessor(ui, repo)
         self.parsed = False
+        self.repotype = repotype
 
     # converter_source methods
 
@@ -58,21 +61,26 @@
 
     def getfile(self, name, fileid):
         if fileid is None:              # deleted file
-            raise IOError
+            return None, None
         return (self.processor.getblob(fileid),
                 self.processor.getmode(name, fileid))
 
-    def getchanges(self, commitid):
-        """Returns a tuple of (files, copies).
+    def getchanges(self, commitid, full):
+        """Returns a tuple of (files, copies, cleanp2).
 
         files is a sorted list of (filename, id) tuples for all files
         changed between commitid and its first parent returned by
-        getcommit(). id is the source revision id of the file.
+        getcommit().
+        commitid id is the source revision id of the file.
+        cleanp2 is currently unused and an empty set is returned.
 
         copies is a dictionary of dest: source
         """
+        if full:
+            raise util.Abort(_("convert from fastimport does not support --full"))
         return (self.processor.modified[commitid],
-                self.processor.copies[commitid])
+                self.processor.copies[commitid],
+                set())
 
     def getcommit(self, commitid):
         """Return the commit object for commitid"""
@@ -307,7 +315,8 @@
         date = self.convert_date(userinfo)
 
         parents = filter(None, [first_parent, second_parent])
-        commit = common.commit(user, date, text, parents, branch, rev=cmd.id)
+        commit = common.commit(user, date, text, parents, branch,
+                               rev=cmd.id, sortkey=int(cmd.id[1:]))
 
         self.commitmap[cmd.id] = commit
         heads = self.branchmap.get(branch)