Patchwork [2,of,4,topic-experiment] topics: return early so that other if conditions don't get execute

login
register
mail settings
Submitter Pulkit Goyal
Date June 26, 2017, 8:28 a.m.
Message ID <48635ee366c2cac52ba9.1498465731@workspace>
Download mbox | patch
Permalink /patch/21727/
State Accepted
Headers show

Comments

Pulkit Goyal - June 26, 2017, 8:28 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1498353802 -19800
#      Sun Jun 25 06:53:22 2017 +0530
# Node ID 48635ee366c2cac52ba9ccd721c4e9688a4abe90
# Parent  bd206f38dda1391cb6e0114d483c8f2fa00a9feb
topics: return early so that other if conditions don't get execute

We were not returning after the _changetopics() call and hence the if's below it
were also executed which resulted in changing of current topic.

Patch

diff --git a/hgext3rd/topic/__init__.py b/hgext3rd/topic/__init__.py
--- a/hgext3rd/topic/__init__.py
+++ b/hgext3rd/topic/__init__.py
@@ -286,7 +286,8 @@ 
             raise error.Abort('changing topic requires a topic name or --clear')
         if any(not c.mutable() for c in repo.set('%r and public()', rev)):
             raise error.Abort("can't change topic of a public change")
-        _changetopics(ui, repo, rev, topic)
+        return _changetopics(ui, repo, rev, topic)
+
     if clear:
         return _changecurrenttopic(repo, None)
 
diff --git a/tests/test-topic.t b/tests/test-topic.t
--- a/tests/test-topic.t
+++ b/tests/test-topic.t
@@ -601,6 +601,7 @@ 
 
   $ hg rebase -d tip -s .
   rebasing 12:18b70b8de1f0 "fran?"
+  switching to topic wat
 
   $ hg log -Gr 'draft()'
   @  changeset:   14:503497a14c3e