Patchwork [3,of,5,topic-experiment] topics: drop the clean argument from _changetopics()

login
register
mail settings
Submitter Pulkit Goyal
Date June 21, 2017, 2:09 a.m.
Message ID <06359d495ef9cc44163a.1498010964@workspace>
Download mbox | patch
Permalink /patch/21569/
State Accepted
Headers show

Comments

Pulkit Goyal - June 21, 2017, 2:09 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1497995905 -19800
#      Wed Jun 21 03:28:25 2017 +0530
# Node ID 06359d495ef9cc44163a35e16ca763148053e69c
# Parent  22705ee4a0f7a049dfd18063b5410ef72c55393c
topics: drop the clean argument from _changetopics()

After this commit, None will represent that we want to clean the topic.

Patch

diff --git a/hgext3rd/topic/__init__.py b/hgext3rd/topic/__init__.py
--- a/hgext3rd/topic/__init__.py
+++ b/hgext3rd/topic/__init__.py
@@ -278,7 +278,10 @@ 
             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, clear)
+        if clear:
+            _changetopics(ui, repo, rev, None)
+        else:
+            _changetopics(ui, repo, rev, topic)
     if clear:
         if repo.vfs.exists('topic'):
             repo.vfs.unlink('topic')
@@ -301,7 +304,7 @@ 
         raise error.Abort(_('no active topic to list'))
     return stack.showstack(ui, repo, topic, opts)
 
-def _changetopics(ui, repo, revset, topic, clear):
+def _changetopics(ui, repo, revset, newtopic):
     rewrote = 0
     needevolve = False
     l = repo.lock()
@@ -320,14 +323,13 @@ 
             fixedextra = dict(c.extra())
             ui.debug('old node id is %s\n' % node.hex(c.node()))
             ui.debug('origextra: %r\n' % fixedextra)
-            newtopic = None if clear else topic
             oldtopic = fixedextra.get(constants.extrakey, None)
             if oldtopic == newtopic:
                 continue
-            if clear:
+            if newtopic is None:
                 del fixedextra[constants.extrakey]
             else:
-                fixedextra[constants.extrakey] = topic
+                fixedextra[constants.extrakey] = newtopic
             if 'amend_source' in fixedextra:
                 # TODO: right now the commitctx wrapper in
                 # topicrepo overwrites the topic in extra if
@@ -372,7 +374,7 @@ 
         lock.release(txn, l)
     ui.status('changed topic on %d changes\n' % rewrote)
     if needevolve:
-        evolvetarget = 'topic(%s)' % topic if topic else 'not topic()'
+        evolvetarget = 'topic(%s)' % newtopic if newtopic else 'not topic()'
         ui.status('please run hg evolve --rev "%s" now\n' % evolvetarget)
 
 def _listtopics(ui, repo, opts):