724 self.paths.append(path) |
724 self.paths.append(path) |
725 self.ctxaffected.update(fstate.ctxaffected) |
725 self.ctxaffected.update(fstate.ctxaffected) |
726 |
726 |
727 def apply(self): |
727 def apply(self): |
728 """apply fixups to individual filefixupstates""" |
728 """apply fixups to individual filefixupstates""" |
729 for path, state in self.fixupmap.iteritems(): |
729 for path, state in pycompat.iteritems(self.fixupmap): |
730 if self.ui.debugflag: |
730 if self.ui.debugflag: |
731 self.ui.write(_(b'applying fixups to %s\n') % path) |
731 self.ui.write(_(b'applying fixups to %s\n') % path) |
732 state.apply() |
732 state.apply() |
733 |
733 |
734 @property |
734 @property |
735 def chunkstats(self): |
735 def chunkstats(self): |
736 """-> {path: chunkstats}. collect chunkstats from filefixupstates""" |
736 """-> {path: chunkstats}. collect chunkstats from filefixupstates""" |
737 return dict( |
737 return dict( |
738 (path, state.chunkstats) |
738 (path, state.chunkstats) |
739 for path, state in self.fixupmap.iteritems() |
739 for path, state in pycompat.iteritems(self.fixupmap) |
740 ) |
740 ) |
741 |
741 |
742 def commit(self): |
742 def commit(self): |
743 """commit changes. update self.finalnode, self.replacemap""" |
743 """commit changes. update self.finalnode, self.replacemap""" |
744 with self.repo.transaction(b'absorb') as tr: |
744 with self.repo.transaction(b'absorb') as tr: |
753 """print things like '1 of 2 chunk(s) applied'""" |
753 """print things like '1 of 2 chunk(s) applied'""" |
754 ui = self.ui |
754 ui = self.ui |
755 chunkstats = self.chunkstats |
755 chunkstats = self.chunkstats |
756 if ui.verbose: |
756 if ui.verbose: |
757 # chunkstats for each file |
757 # chunkstats for each file |
758 for path, stat in chunkstats.iteritems(): |
758 for path, stat in pycompat.iteritems(chunkstats): |
759 if stat[0]: |
759 if stat[0]: |
760 ui.write( |
760 ui.write( |
761 _(b'%s: %d of %d chunk(s) applied\n') |
761 _(b'%s: %d of %d chunk(s) applied\n') |
762 % (path, stat[0], stat[1]) |
762 % (path, stat[0], stat[1]) |
763 ) |
763 ) |
829 |
829 |
830 def _movebookmarks(self, tr): |
830 def _movebookmarks(self, tr): |
831 repo = self.repo |
831 repo = self.repo |
832 needupdate = [ |
832 needupdate = [ |
833 (name, self.replacemap[hsh]) |
833 (name, self.replacemap[hsh]) |
834 for name, hsh in repo._bookmarks.iteritems() |
834 for name, hsh in pycompat.iteritems(repo._bookmarks) |
835 if hsh in self.replacemap |
835 if hsh in self.replacemap |
836 ] |
836 ] |
837 changes = [] |
837 changes = [] |
838 for name, hsh in needupdate: |
838 for name, hsh in needupdate: |
839 if hsh: |
839 if hsh: |
888 return False |
888 return False |
889 pctx = parents[0] |
889 pctx = parents[0] |
890 # ctx changes more files (not a subset of memworkingcopy) |
890 # ctx changes more files (not a subset of memworkingcopy) |
891 if not set(ctx.files()).issubset(set(memworkingcopy)): |
891 if not set(ctx.files()).issubset(set(memworkingcopy)): |
892 return False |
892 return False |
893 for path, content in memworkingcopy.iteritems(): |
893 for path, content in pycompat.iteritems(memworkingcopy): |
894 if path not in pctx or path not in ctx: |
894 if path not in pctx or path not in ctx: |
895 return False |
895 return False |
896 fctx = ctx[path] |
896 fctx = ctx[path] |
897 pfctx = pctx[path] |
897 pfctx = pctx[path] |
898 if pfctx.flags() != fctx.flags(): |
898 if pfctx.flags() != fctx.flags(): |
920 return obsolete.isenabled(self.repo, obsolete.createmarkersopt) |
920 return obsolete.isenabled(self.repo, obsolete.createmarkersopt) |
921 |
921 |
922 def _cleanupoldcommits(self): |
922 def _cleanupoldcommits(self): |
923 replacements = { |
923 replacements = { |
924 k: ([v] if v is not None else []) |
924 k: ([v] if v is not None else []) |
925 for k, v in self.replacemap.iteritems() |
925 for k, v in pycompat.iteritems(self.replacemap) |
926 } |
926 } |
927 if replacements: |
927 if replacements: |
928 scmutil.cleanupnodes( |
928 scmutil.cleanupnodes( |
929 self.repo, replacements, operation=b'absorb', fixphase=True |
929 self.repo, replacements, operation=b'absorb', fixphase=True |
930 ) |
930 ) |
966 patchmap = defaultdict(lambda: []) # {path: [(a1, a2, [bline])]} |
966 patchmap = defaultdict(lambda: []) # {path: [(a1, a2, [bline])]} |
967 for path, info in map(_parsechunk, chunks): |
967 for path, info in map(_parsechunk, chunks): |
968 if not path or not info: |
968 if not path or not info: |
969 continue |
969 continue |
970 patchmap[path].append(info) |
970 patchmap[path].append(info) |
971 for path, patches in patchmap.iteritems(): |
971 for path, patches in pycompat.iteritems(patchmap): |
972 if path not in ctx or not patches: |
972 if path not in ctx or not patches: |
973 continue |
973 continue |
974 patches.sort(reverse=True) |
974 patches.sort(reverse=True) |
975 lines = mdiff.splitnewlines(ctx[path].data()) |
975 lines = mdiff.splitnewlines(ctx[path].data()) |
976 for a1, a2, blines in patches: |
976 for a1, a2, blines in patches: |