comparison hgext/fastexport.py @ 50875:00081fa564ed

fastexport: migrate `opts` to native kwargs
author Matt Harbison <matt_harbison@yahoo.com>
date Sun, 20 Aug 2023 16:06:08 -0400
parents dd42156b6441
children a97f2b50219b
comparison
equal deleted inserted replaced
50874:f12d53a6e8b8 50875:00081fa564ed
13 from mercurial.node import hex, nullrev 13 from mercurial.node import hex, nullrev
14 from mercurial.utils import stringutil 14 from mercurial.utils import stringutil
15 from mercurial import ( 15 from mercurial import (
16 error, 16 error,
17 logcmdutil, 17 logcmdutil,
18 pycompat,
19 registrar, 18 registrar,
20 scmutil, 19 scmutil,
21 ) 20 )
22 from .convert import convcmd 21 from .convert import convcmd
23 22
174 173
175 This command lets you dump a repository as a human-readable text stream. 174 This command lets you dump a repository as a human-readable text stream.
176 It can be piped into corresponding import routines like "git fast-import". 175 It can be piped into corresponding import routines like "git fast-import".
177 Incremental dumps can be created by using marks files. 176 Incremental dumps can be created by using marks files.
178 """ 177 """
179 opts = pycompat.byteskwargs(opts) 178 revs += tuple(opts.get("rev", []))
180
181 revs += tuple(opts.get(b"rev", []))
182 if not revs: 179 if not revs:
183 revs = scmutil.revrange(repo, [b":"]) 180 revs = scmutil.revrange(repo, [b":"])
184 else: 181 else:
185 revs = logcmdutil.revrange(repo, revs) 182 revs = logcmdutil.revrange(repo, revs)
186 if not revs: 183 if not revs:
187 raise error.Abort(_(b"no revisions matched")) 184 raise error.Abort(_(b"no revisions matched"))
188 authorfile = opts.get(b"authormap") 185 authorfile = opts.get("authormap")
189 if authorfile: 186 if authorfile:
190 authormap = convcmd.readauthormap(ui, authorfile) 187 authormap = convcmd.readauthormap(ui, authorfile)
191 else: 188 else:
192 authormap = {} 189 authormap = {}
193 190
194 import_marks = opts.get(b"import_marks") 191 import_marks = opts.get("import_marks")
195 marks = {} 192 marks = {}
196 if import_marks: 193 if import_marks:
197 with open(import_marks, "rb") as import_marks_file: 194 with open(import_marks, "rb") as import_marks_file:
198 for line in import_marks_file: 195 for line in import_marks_file:
199 line = line.strip() 196 line = line.strip()
207 ) as progress: 204 ) as progress:
208 for rev in revs: 205 for rev in revs:
209 export_commit(ui, repo, rev, marks, authormap) 206 export_commit(ui, repo, rev, marks, authormap)
210 progress.increment() 207 progress.increment()
211 208
212 export_marks = opts.get(b"export_marks") 209 export_marks = opts.get("export_marks")
213 if export_marks: 210 if export_marks:
214 with open(export_marks, "wb") as export_marks_file: 211 with open(export_marks, "wb") as export_marks_file:
215 output_marks = [None] * len(marks) 212 output_marks = [None] * len(marks)
216 for k, v in marks.items(): 213 for k, v in marks.items():
217 output_marks[v - 1] = k 214 output_marks[v - 1] = k