Mercurial > evolve
changeset 6539:45689da4ed41
topic: teach hg import/export to handle topic namespace as well
Importing topic currently doesn't work, but will hopefully be fixed soon.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Fri, 14 Jul 2023 15:54:51 -0300 |
parents | d20e5eaba766 |
children | 09fb1cfb5adc |
files | hgext3rd/topic/__init__.py tests/test-namespaces.t tests/test-split.t tests/test-topic-stack.t |
diffstat | 4 files changed, 109 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py Mon Jul 10 16:13:45 2023 -0300 +++ b/hgext3rd/topic/__init__.py Fri Jul 14 15:54:51 2023 -0300 @@ -1681,22 +1681,37 @@ ## preserve topic during import/export +def _exporttns(seq, ctx): + tns = ctx.topic_namespace() + if tns != b'none': + return b'EXP-Topic-Namespace %s' % tns + return None + def _exporttopic(seq, ctx): topic = ctx.topic() if topic: return b'EXP-Topic %s' % topic return None +def _importtns(repo, patchdata, extra, opts): + if b'topic-namespace' in patchdata: + extra[b'topic-namespace'] = patchdata[b'topic-namespace'] + def _importtopic(repo, patchdata, extra, opts): if b'topic' in patchdata: extra[b'topic'] = patchdata[b'topic'] def setupimportexport(ui): """run at ui setup time to install import/export logic""" + cmdutil.extraexport.append(b'topic-namespace') + cmdutil.extraexportmap[b'topic-namespace'] = _exporttns cmdutil.extraexport.append(b'topic') cmdutil.extraexportmap[b'topic'] = _exporttopic + cmdutil.extrapreimport.append(b'topic-namespace') + cmdutil.extrapreimportmap[b'topic-namespace'] = _importtns cmdutil.extrapreimport.append(b'topic') cmdutil.extrapreimportmap[b'topic'] = _importtopic + patch.patchheadermap.append((b'EXP-Topic-Namespace', b'topic-namespace')) patch.patchheadermap.append((b'EXP-Topic', b'topic')) ## preserve topic during split
--- a/tests/test-namespaces.t Mon Jul 10 16:13:45 2023 -0300 +++ b/tests/test-namespaces.t Fri Jul 14 15:54:51 2023 -0300 @@ -72,6 +72,55 @@ abort: unknown revision 'alice' [10] +Export/import of topic namespaces + + $ hg export + # HG changeset patch + # User test + # Date 0 0 + # Thu Jan 01 00:00:00 1970 +0000 + # Branch stable + # Node ID 69c7dbf6acd180eeec055dd67933badd3601d45f + # Parent 0000000000000000000000000000000000000000 + # EXP-Topic-Namespace alice + # EXP-Topic feature + a + + diff -r 000000000000 -r 69c7dbf6acd1 a + --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + +++ b/a Thu Jan 01 00:00:00 1970 +0000 + @@ -0,0 +1,1 @@ + +a + + $ hg import - << EOF + > # HG changeset patch + > # User test + > # Date 0 0 + > # Thu Jan 01 00:00:00 1970 +0000 + > # Branch another-branch + > # Node ID 1111111111111111111111111111111111111111 + > # Parent 2222222222222222222222222222222222222222 + > # EXP-Topic-Namespace mynamespace + > # EXP-Topic mytopic + > added z + > + > diff --git a/z b/z + > new file mode 100644 + > --- /dev/null + > +++ b/z + > @@ -0,0 +1,1 @@ + > +z + > EOF + applying patch from stdin + +TODO: topic should also be imported from the patch + + $ hg log -r tip -T '{rev}: {branch} {topic_namespace} {topic}\n' + 1: stable mynamespace feature + + $ hg log -r tip -T '{rev}: {fqbn}\n' + 1: stable//mynamespace/feature + Revsets $ nslog() { @@ -80,10 +129,13 @@ $ nslog 'topicnamespace()' 0: alice + 1: mynamespace $ nslog 'topicnamespace(:)' 0: alice + 1: mynamespace $ nslog 'topicnamespace(all())' 0: alice + 1: mynamespace $ nslog 'topicnamespace(topicnamespace("alice"))' 0: alice $ nslog 'topicnamespace(wdir())'
--- a/tests/test-split.t Mon Jul 10 16:13:45 2023 -0300 +++ b/tests/test-split.t Fri Jul 14 15:54:51 2023 -0300 @@ -543,6 +543,7 @@ # Branch another-branch # Node ID 94981e5d988ea23cf2b17f6c07c39edc0f174b01 # Parent d6d47657e765570283ec03fc68836d9eb297c4b3 + # EXP-Topic-Namespace mynamespace # EXP-Topic mytopic To be split @@ -739,6 +740,7 @@ # Branch another-branch # Node ID 61661257a93759374255a4c05fcd9b8a78bbe399 # Parent a05395d0b42120af8bfb222d19f01008b1342c15 + # EXP-Topic-Namespace mynamespace # EXP-Topic mytopic split10 @@ -755,6 +757,7 @@ # Branch another-branch # Node ID e6ca7ba1372dc452769c51a56d853c8ede26d9fa # Parent a05395d0b42120af8bfb222d19f01008b1342c15 + # EXP-Topic-Namespace mynamespace # EXP-Topic mytopic split10 @@ -791,6 +794,7 @@ # Branch another-branch # Node ID bb8f1c282ddf89515bd07bd63a84962ab51ac277 # Parent a05395d0b42120af8bfb222d19f01008b1342c15 + # EXP-Topic-Namespace mynamespace # EXP-Topic mytopic split12
--- a/tests/test-topic-stack.t Mon Jul 10 16:13:45 2023 -0300 +++ b/tests/test-topic-stack.t Fri Jul 14 15:54:51 2023 -0300 @@ -676,6 +676,8 @@ $ echo aaa > aaa $ hg commit -Am 'c_A' adding aaa + $ hg debug-topic-namespace my-tns + marked working directory as topic namespace: my-tns $ hg topic red marked working directory as topic: red $ echo bbb > bbb @@ -905,12 +907,13 @@ get things linear again $ hg rebase -r s1 -d default - rebasing 16:1d84ec948370 tip blue "c_D" + rebasing 16:c9b07601c2f4 tip blue "c_D" + switching to topic-namespace my-tns switching to topic blue $ hg rebase -r s2 -d s1 - rebasing 13:3ab2eedae500 blue "c_G" + rebasing 13:90c34d9f99aa blue "c_G" $ hg rebase -r s3 -d s2 - rebasing 8:3bfe800e0486 blue "c_I" + rebasing 8:77174443ad61 blue "c_I" $ hg stack ### topic: blue ### target: default (branch) @@ -967,48 +970,49 @@ continue splitting? [Ycdq?] c $ hg debugobsolete - 34679cfcccdd07565970b959c79428af9a5744e4 6a11ae6b0cde4d4952ed68e8077b9e3596d99548 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '16', 'operation': 'amend', 'user': 'test'} - 20f7945d89a5e372b7548f766ebc800677856443 3c7bec987cd37ba12b83c01683e8609dd549c07b 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '16', 'operation': 'amend', 'user': 'test'} - 952e24687ebc5f11743268f6f1c3f24fa83c7ddd 74979543bf1d6c0f75229991400f352a6fb3fddb 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '16', 'operation': 'amend', 'user': 'test'} - c9961f97c7b40b54b3c1922986675d6f38793014 d7bfa3d6ce36dfb917547246752f0c2a564fe33b 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '16', 'operation': 'amend', 'user': 'test'} - c7d60a180d05255e8c6ea50bce09d014015b7cdc 3ab2eedae500f52b6aa220bb8ce6e20732a8a6d1 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '16', 'operation': 'amend', 'user': 'test'} - 6a11ae6b0cde4d4952ed68e8077b9e3596d99548 61700bf67137c724a72aa5f034e9187d2c5e7e47 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '16', 'operation': 'amend', 'user': 'test'} - 3c7bec987cd37ba12b83c01683e8609dd549c07b 4bcfa5dd0945476ba938e8115e81ba367af3b573 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '16', 'operation': 'amend', 'user': 'test'} - 74979543bf1d6c0f75229991400f352a6fb3fddb 1d84ec948370a2ac1a51f3ab27835e31d50c3407 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '16', 'operation': 'amend', 'user': 'test'} - 1d84ec948370a2ac1a51f3ab27835e31d50c3407 f3328cd199dc389b850ca952f65a15a8e6dbc79b 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '4', 'operation': 'rebase', 'user': 'test'} - 3ab2eedae500f52b6aa220bb8ce6e20732a8a6d1 907f7d3c2333082d62942ac3a47e466ce03d82b9 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '4', 'operation': 'rebase', 'user': 'test'} - 3bfe800e04863d23f909f8d98848656b7b5a971a 662ff4ad29901b325a64c39f7850e3efaaeeccc5 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '4', 'operation': 'rebase', 'user': 'test'} - 907f7d3c2333082d62942ac3a47e466ce03d82b9 b24bab30ac12f6124a52e74aaf46b7468e42526c 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'} - b24bab30ac12f6124a52e74aaf46b7468e42526c dde94df880e97f4a1ee8c5408254b429b3d90204 e7ea874afbd5c17aeee366d39a828dbcb01682ce 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '12', 'operation': 'split', 'user': 'test'} + 8da160be12a0d8d40b5aad42aea02123e255f802 6646bdc8cb87942886d4b8548bc243aaacf94b61 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '16', 'operation': 'amend', 'user': 'test'} + 2dc043b3e268bc3d7f30fc2319a72f4430af1d31 6044ea1ba1f7e573bc33312518cd005c45e2ad7d 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '16', 'operation': 'amend', 'user': 'test'} + d2c0265139080fe437d3550f5a6c975bc5c3f545 03ec02fb9548883827e62560d0b1e786851f4536 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '16', 'operation': 'amend', 'user': 'test'} + 97cd99629af4d20fc3ccb0989d36294a85dd026d 17318610d72be0981692fb3f02ef1bf30191367e 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '16', 'operation': 'amend', 'user': 'test'} + 78da2467366f01b547bd1fc39bcfcc5917be7caa 90c34d9f99aafcc26de07beb0b3c85856de0fa46 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '16', 'operation': 'amend', 'user': 'test'} + 6646bdc8cb87942886d4b8548bc243aaacf94b61 3603891aa2fe38371f226d956f39252576155fba 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '16', 'operation': 'amend', 'user': 'test'} + 6044ea1ba1f7e573bc33312518cd005c45e2ad7d 0a3ac1989f8bde7725203cba7a812e547af916fc 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '16', 'operation': 'amend', 'user': 'test'} + 03ec02fb9548883827e62560d0b1e786851f4536 c9b07601c2f4a8c6c0bd8fe292d6d2e85b872d56 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '16', 'operation': 'amend', 'user': 'test'} + c9b07601c2f4a8c6c0bd8fe292d6d2e85b872d56 eed7b08171dd3b5a9359789531abc0bed2161580 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '4', 'operation': 'rebase', 'user': 'test'} + 90c34d9f99aafcc26de07beb0b3c85856de0fa46 7fae9524de068a420f7fa9f262669c461ada141f 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '4', 'operation': 'rebase', 'user': 'test'} + 77174443ad6187ba2a216529d7c9785b5f309b70 cc55835562515ff390751032f9e735606c549e96 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '4', 'operation': 'rebase', 'user': 'test'} + 7fae9524de068a420f7fa9f262669c461ada141f e2ca321d00b4adb62525539578290e49e662da79 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'} + e2ca321d00b4adb62525539578290e49e662da79 744c2a22b7da8397bcbd2d472911d51404e54a38 ff95a51a90b9c6710e71bc8ea62c382a5d45e500 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '12', 'operation': 'split', 'user': 'test'} $ hg --config extensions.evolve= obslog --all - o dde94df880e9 (21) c_G - | split(parent, content) from b24bab30ac12 using split by test (Thu Jan 01 00:00:00 1970 +0000) + o 744c2a22b7da (21) c_G + | split(parent, content) from e2ca321d00b4 using split by test (Thu Jan 01 00:00:00 1970 +0000) | - | @ e7ea874afbd5 (22) c_G - |/ split(parent, content) from b24bab30ac12 using split by test (Thu Jan 01 00:00:00 1970 +0000) + | @ ff95a51a90b9 (22) c_G + |/ split(parent, content) from e2ca321d00b4 using split by test (Thu Jan 01 00:00:00 1970 +0000) | - x b24bab30ac12 (20) c_G - | amended(content) from 907f7d3c2333 using amend by test (Thu Jan 01 00:00:00 1970 +0000) + x e2ca321d00b4 (20) c_G + | amended(content) from 7fae9524de06 using amend by test (Thu Jan 01 00:00:00 1970 +0000) | - x 907f7d3c2333 (18) c_G - | rebased(parent) from 3ab2eedae500 using rebase by test (Thu Jan 01 00:00:00 1970 +0000) + x 7fae9524de06 (18) c_G + | rebased(parent) from 90c34d9f99aa using rebase by test (Thu Jan 01 00:00:00 1970 +0000) | - x 3ab2eedae500 (13) c_G - | reauthored(user) from c7d60a180d05 using amend by test (Thu Jan 01 00:00:00 1970 +0000) + x 90c34d9f99aa (13) c_G + | reauthored(user) from 78da2467366f using amend by test (Thu Jan 01 00:00:00 1970 +0000) | - x c7d60a180d05 (6) c_G + x 78da2467366f (6) c_G $ hg export . # HG changeset patch # User test3 # Date 0 0 # Thu Jan 01 00:00:00 1970 +0000 - # Node ID e7ea874afbd5c17aeee366d39a828dbcb01682ce - # Parent dde94df880e97f4a1ee8c5408254b429b3d90204 + # Node ID ff95a51a90b9c6710e71bc8ea62c382a5d45e500 + # Parent 744c2a22b7da8397bcbd2d472911d51404e54a38 + # EXP-Topic-Namespace my-tns # EXP-Topic blue c_G - diff -r dde94df880e9 -r e7ea874afbd5 ggg + diff -r 744c2a22b7da -r ff95a51a90b9 ggg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ggg Thu Jan 01 00:00:00 1970 +0000 @@ -0,0 +1,1 @@ @@ -1018,12 +1022,13 @@ # User test3 # Date 0 0 # Thu Jan 01 00:00:00 1970 +0000 - # Node ID dde94df880e97f4a1ee8c5408254b429b3d90204 - # Parent f3328cd199dc389b850ca952f65a15a8e6dbc79b + # Node ID 744c2a22b7da8397bcbd2d472911d51404e54a38 + # Parent eed7b08171dd3b5a9359789531abc0bed2161580 + # EXP-Topic-Namespace my-tns # EXP-Topic blue c_G - diff -r f3328cd199dc -r dde94df880e9 Z + diff -r eed7b08171dd -r 744c2a22b7da Z --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Z Thu Jan 01 00:00:00 1970 +0000 @@ -0,0 +1,1 @@