Mercurial > hg
comparison hgext/absorb.py @ 38987:9204445ad54c
absorb: port partway to Python 3
Use pycompat.maplist() in the one place that matters and use the
default iterator of a dict instead of iterkeys().
Two new tests pass on Python 3.
Differential Revision: https://phab.mercurial-scm.org/D4174
author | Augie Fackler <augie@google.com> |
---|---|
date | Thu, 09 Aug 2018 12:06:31 -0400 |
parents | 19344143b3e1 |
children | ab452995eaff |
comparison
equal
deleted
inserted
replaced
38986:ac0a87160012 | 38987:9204445ad54c |
---|---|
243 if extra is None: | 243 if extra is None: |
244 extra = ctx.extra() | 244 extra = ctx.extra() |
245 date = ctx.date() | 245 date = ctx.date() |
246 desc = ctx.description() | 246 desc = ctx.description() |
247 user = ctx.user() | 247 user = ctx.user() |
248 files = set(ctx.files()).union(memworkingcopy.iterkeys()) | 248 files = set(ctx.files()).union(memworkingcopy) |
249 store = overlaystore(ctx, memworkingcopy) | 249 store = overlaystore(ctx, memworkingcopy) |
250 return context.memctx( | 250 return context.memctx( |
251 repo=ctx.repo(), parents=parents, text=desc, | 251 repo=ctx.repo(), parents=parents, text=desc, |
252 files=files, filectxfn=store, user=user, date=date, | 252 files=files, filectxfn=store, user=user, date=date, |
253 branch=None, extra=extra) | 253 branch=None, extra=extra) |
284 self.ui = ui or nullui() | 284 self.ui = ui or nullui() |
285 self.opts = opts or {} | 285 self.opts = opts or {} |
286 | 286 |
287 # following fields are built from fctxs. they exist for perf reason | 287 # following fields are built from fctxs. they exist for perf reason |
288 self.contents = [f.data() for f in fctxs] | 288 self.contents = [f.data() for f in fctxs] |
289 self.contentlines = map(mdiff.splitnewlines, self.contents) | 289 self.contentlines = pycompat.maplist(mdiff.splitnewlines, self.contents) |
290 self.linelog = self._buildlinelog() | 290 self.linelog = self._buildlinelog() |
291 if self.ui.debugflag: | 291 if self.ui.debugflag: |
292 assert self._checkoutlinelog() == self.contents | 292 assert self._checkoutlinelog() == self.contents |
293 | 293 |
294 # following fields will be filled later | 294 # following fields will be filled later |
803 parents = ctx.parents() | 803 parents = ctx.parents() |
804 if len(parents) != 1: | 804 if len(parents) != 1: |
805 return False | 805 return False |
806 pctx = parents[0] | 806 pctx = parents[0] |
807 # ctx changes more files (not a subset of memworkingcopy) | 807 # ctx changes more files (not a subset of memworkingcopy) |
808 if not set(ctx.files()).issubset(set(memworkingcopy.iterkeys())): | 808 if not set(ctx.files()).issubset(set(memworkingcopy)): |
809 return False | 809 return False |
810 for path, content in memworkingcopy.iteritems(): | 810 for path, content in memworkingcopy.iteritems(): |
811 if path not in pctx or path not in ctx: | 811 if path not in pctx or path not in ctx: |
812 return False | 812 return False |
813 fctx = ctx[path] | 813 fctx = ctx[path] |