Mercurial > hg > hg-fastimport
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 72:6b716ecb1cf3 | 73:a99e5c6c8e1c |
|---|---|
| 24 import shutil | 24 import shutil |
| 25 import stat | 25 import stat |
| 26 import sys | 26 import sys |
| 27 | 27 |
| 28 from hgext.convert import common, hg as converthg | 28 from hgext.convert import common, hg as converthg |
| 29 from mercurial import util | |
| 30 from mercurial.i18n import _ | |
| 29 | 31 |
| 30 from fastimport import processor, parser | 32 from fastimport import processor, parser |
| 31 | 33 |
| 32 | 34 |
| 33 class fastimport_source(common.converter_source): | 35 class fastimport_source(common.converter_source): |
| 34 """Interface between the fastimport processor below and Mercurial's | 36 """Interface between the fastimport processor below and Mercurial's |
| 35 normal conversion infrastructure. | 37 normal conversion infrastructure. |
| 36 """ | 38 """ |
| 37 def __init__(self, ui, repo, sources): | 39 def __init__(self, ui, repotype, repo, sources): |
| 38 self.ui = ui | 40 self.ui = ui |
| 39 self.sources = sources | 41 self.sources = sources |
| 40 self.processor = HgImportProcessor(ui, repo) | 42 self.processor = HgImportProcessor(ui, repo) |
| 41 self.parsed = False | 43 self.parsed = False |
| 44 self.repotype = repotype | |
| 42 | 45 |
| 43 # converter_source methods | 46 # converter_source methods |
| 44 | 47 |
| 45 def before(self): | 48 def before(self): |
| 46 self.processor.setup() | 49 self.processor.setup() |
| 56 allheads.extend(branchheads) | 59 allheads.extend(branchheads) |
| 57 return allheads | 60 return allheads |
| 58 | 61 |
| 59 def getfile(self, name, fileid): | 62 def getfile(self, name, fileid): |
| 60 if fileid is None: # deleted file | 63 if fileid is None: # deleted file |
| 61 raise IOError | 64 return None, None |
| 62 return (self.processor.getblob(fileid), | 65 return (self.processor.getblob(fileid), |
| 63 self.processor.getmode(name, fileid)) | 66 self.processor.getmode(name, fileid)) |
| 64 | 67 |
| 65 def getchanges(self, commitid): | 68 def getchanges(self, commitid, full): |
| 66 """Returns a tuple of (files, copies). | 69 """Returns a tuple of (files, copies, cleanp2). |
| 67 | 70 |
| 68 files is a sorted list of (filename, id) tuples for all files | 71 files is a sorted list of (filename, id) tuples for all files |
| 69 changed between commitid and its first parent returned by | 72 changed between commitid and its first parent returned by |
| 70 getcommit(). id is the source revision id of the file. | 73 getcommit(). |
| 74 commitid id is the source revision id of the file. | |
| 75 cleanp2 is currently unused and an empty set is returned. | |
| 71 | 76 |
| 72 copies is a dictionary of dest: source | 77 copies is a dictionary of dest: source |
| 73 """ | 78 """ |
| 79 if full: | |
| 80 raise util.Abort(_("convert from fastimport does not support --full")) | |
| 74 return (self.processor.modified[commitid], | 81 return (self.processor.modified[commitid], |
| 75 self.processor.copies[commitid]) | 82 self.processor.copies[commitid], |
| 83 set()) | |
| 76 | 84 |
| 77 def getcommit(self, commitid): | 85 def getcommit(self, commitid): |
| 78 """Return the commit object for commitid""" | 86 """Return the commit object for commitid""" |
| 79 if commitid is None: | 87 if commitid is None: |
| 80 return None | 88 return None |
| 305 | 313 |
| 306 text = cmd.message | 314 text = cmd.message |
| 307 date = self.convert_date(userinfo) | 315 date = self.convert_date(userinfo) |
| 308 | 316 |
| 309 parents = filter(None, [first_parent, second_parent]) | 317 parents = filter(None, [first_parent, second_parent]) |
| 310 commit = common.commit(user, date, text, parents, branch, rev=cmd.id) | 318 commit = common.commit(user, date, text, parents, branch, |
| 319 rev=cmd.id, sortkey=int(cmd.id[1:])) | |
| 311 | 320 |
| 312 self.commitmap[cmd.id] = commit | 321 self.commitmap[cmd.id] = commit |
| 313 heads = self.branchmap.get(branch) | 322 heads = self.branchmap.get(branch) |
| 314 if heads is None: | 323 if heads is None: |
| 315 heads = [cmd.id] | 324 heads = [cmd.id] |
