Mercurial > evolve
changeset 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 | 13c406d9912c |
children | 0b7328d7503a |
files | CHANGELOG hgext3rd/topic/__init__.py tests/test-amend-merge.t |
diffstat | 3 files changed, 39 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGELOG Sun May 09 00:09:53 2021 +0800 +++ b/CHANGELOG Sun May 09 00:10:55 2021 +0800 @@ -6,6 +6,10 @@ * next: remove duplicated targets when updating from an unstable changeset +topic (0.22.2) + + * topic: don't lose any file changes when changing topic of a merge commit + 10.3.1 -- 2021-04-25 --------------------
--- a/hgext3rd/topic/__init__.py Sun May 09 00:09:53 2021 +0800 +++ b/hgext3rd/topic/__init__.py Sun May 09 00:10:55 2021 +0800 @@ -1059,6 +1059,14 @@ for r in revs: c = repo[r] + if len(c.parents()) > 1: + # ctx.files() isn't reliable for merges, so fall back to the + # slower repo.status() method + st = c.p1().status(c) + files = set(st.modified) | set(st.added) | set(st.removed) + else: + files = set(c.files()) + def filectxfn(repo, ctx, path): try: return c[path] @@ -1097,7 +1105,7 @@ mc = context.memctx(repo, (p1, p2), c.description(), - c.files(), + files, filectxfn, user=c.user(), date=c.date(),
--- a/tests/test-amend-merge.t Sun May 09 00:09:53 2021 +0800 +++ b/tests/test-amend-merge.t Sun May 09 00:10:55 2021 +0800 @@ -70,3 +70,29 @@ +++ b/apple Thu Jan 01 00:00:00 1970 +0000 @@ -0,0 +1,1 @@ +apple + +topics + + $ hg topics -r . foo + switching to topic foo + changed topic on 1 changesets to "foo" + $ hg diff -r 'p1(.)' -r '.' + diff -r 88a060ab6523 -r 52150b9639f7 banana + --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + +++ b/banana Thu Jan 01 00:00:00 1970 +0000 + @@ -0,0 +1,1 @@ + +banana + $ hg diff -r 'p2(.)' -r '.' + diff -r d8c7baf0ca58 -r 52150b9639f7 apple + --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + +++ b/apple Thu Jan 01 00:00:00 1970 +0000 + @@ -0,0 +1,1 @@ + +apple + + $ hg files + apple + banana + root + $ hg cat apple banana + apple + banana