# HG changeset patch # User Anton Shestakov # Date 1591872629 -28800 # Node ID 7f80558c9b8d08bac4a399231d8ab5964bb48cdf # Parent 31a72d43d20fa0c6c79c65e8d96ab0c73ad2b717 topic: treat argument to --topic as a literal topic name explicitly We already do treat it as a string (i.e. not a special revset language symbol) that needs to be escaped, because we use %s in repo.revs(), which escapes and single-quotes the appropriate argument. But now we abort in case user supplies topic name that doesn't exist. Before this patch, when user ran something like `hg push --topic .`, this code would use 'topic(".") - obsolete()' revset, which would get an empty set from repo.revs() unless there was a topic named "." (unlikely, because this name is reserved). This code would then add an empty set to the 'rev' argument of the original hg push command. And `hg push` without -r will try and push everything, and not just changesets on a specific topic. diff -r 31a72d43d20f -r 7f80558c9b8d CHANGELOG --- a/CHANGELOG Mon Jul 27 12:53:53 2020 +0800 +++ b/CHANGELOG Thu Jun 11 18:50:29 2020 +0800 @@ -14,6 +14,9 @@ * compatibility with Mercurial 5.5 + * topic: hg push --topic does-not-exist now doesn't try to push unrelated + changesets and aborts instead + 10.0.0 -- 2020-05-09 -------------------- diff -r 31a72d43d20f -r 7f80558c9b8d hgext3rd/topic/__init__.py --- a/hgext3rd/topic/__init__.py Mon Jul 27 12:53:53 2020 +0800 +++ b/hgext3rd/topic/__init__.py Thu Jun 11 18:50:29 2020 +0800 @@ -1269,7 +1269,8 @@ def pushoutgoingwrap(orig, ui, repo, *args, **opts): if opts.get('topic'): - topicrevs = repo.revs(b'topic(%s) - obsolete()', opts['topic']) + topic = b'literal:' + opts['topic'] + topicrevs = repo.revs(b'topic(%s) - obsolete()', topic) opts.setdefault('rev', []).extend(topicrevs) return orig(ui, repo, *args, **opts) diff -r 31a72d43d20f -r 7f80558c9b8d tests/test-topic-push.t --- a/tests/test-topic-push.t Mon Jul 27 12:53:53 2020 +0800 +++ b/tests/test-topic-push.t Thu Jun 11 18:50:29 2020 +0800 @@ -192,6 +192,14 @@ |/ o 0 default public CA + + $ hg outgoing draft --topic nonexistent + abort: topic 'nonexistent' does not exist! + [255] + $ hg push draft --topic nonexistent + abort: topic 'nonexistent' does not exist! + [255] + $ hg outgoing draft --topic babar comparing with $TESTTMP/draft searching for changes