Mercurial > evolve
comparison hgext3rd/topic/__init__.py @ 5919:1a8e86053adb stable
topic: don't lose any file changes when changing topic of a merge commit
This file-related logic is taken directly from cmdutil.amend().
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Sun, 09 May 2021 00:10:55 +0800 |
parents | 355bd0f7354b |
children | 8d36bfe9968a |
comparison
equal
deleted
inserted
replaced
5918:13c406d9912c | 5919:1a8e86053adb |
---|---|
1056 p1 = None | 1056 p1 = None |
1057 p2 = None | 1057 p2 = None |
1058 successors = {} | 1058 successors = {} |
1059 for r in revs: | 1059 for r in revs: |
1060 c = repo[r] | 1060 c = repo[r] |
1061 | |
1062 if len(c.parents()) > 1: | |
1063 # ctx.files() isn't reliable for merges, so fall back to the | |
1064 # slower repo.status() method | |
1065 st = c.p1().status(c) | |
1066 files = set(st.modified) | set(st.added) | set(st.removed) | |
1067 else: | |
1068 files = set(c.files()) | |
1061 | 1069 |
1062 def filectxfn(repo, ctx, path): | 1070 def filectxfn(repo, ctx, path): |
1063 try: | 1071 try: |
1064 return c[path] | 1072 return c[path] |
1065 except error.ManifestLookupError: | 1073 except error.ManifestLookupError: |
1095 if p2 in successors: | 1103 if p2 in successors: |
1096 p2 = successors[p2][0] | 1104 p2 = successors[p2][0] |
1097 mc = context.memctx(repo, | 1105 mc = context.memctx(repo, |
1098 (p1, p2), | 1106 (p1, p2), |
1099 c.description(), | 1107 c.description(), |
1100 c.files(), | 1108 files, |
1101 filectxfn, | 1109 filectxfn, |
1102 user=c.user(), | 1110 user=c.user(), |
1103 date=c.date(), | 1111 date=c.date(), |
1104 extra=fixedextra) | 1112 extra=fixedextra) |
1105 | 1113 |