changeset 1860:b7b9e5028c2a

topics: consistently use empty string instead of None This agrees with repo.currenttopic which uses ''. A subsequent patch is going to provide a context topic method that returns the empty string.
author Matt Mackall <mpm@selenic.com>
date Fri, 19 Jun 2015 16:13:16 -0500
parents fdfa611b8ab0
children 972d4e0c3d44
files src/topic/__init__.py
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/topic/__init__.py	Fri Jun 19 14:18:34 2015 -0500
+++ b/src/topic/__init__.py	Fri Jun 19 16:13:16 2015 -0500
@@ -47,7 +47,7 @@
         def commit(self, *args, **kwargs):
             backup = self.ui.backupconfig('ui', 'allowemptycommit')
             try:
-                if repo.currenttopic != repo['.'].extra().get('topic'):
+                if repo.currenttopic != repo['.'].extra().get('topic', ''):
                     # bypass the core "nothing changed" logic
                     self.ui.setconfig('ui', 'allowemptycommit', True)
                 return orig.commit(self, *args, **kwargs)
@@ -83,12 +83,12 @@
     ('', 'clear', False, 'clear active topic if any'),
     ('', 'change', '', 'revset of existing revisions to change topic'),
 ])
-def topics(ui, repo, topic=None, clear=False, change=None):
+def topics(ui, repo, topic='', clear=False, change=None):
     """View current topic, set current topic, or see all topics."""
     if change:
         if not obsolete.isenabled(repo, obsolete.createmarkersopt):
             raise util.Abort(_('must have obsolete enabled to use --change'))
-        if topic is None and not clear:
+        if not topic and not clear:
             raise util.Abort('changing topic requires a topic name or --clear')
         if any(not c.mutable() for c in repo.set('%r and public()', change)):
             raise util.Abort("can't change topic of a public change")
@@ -105,7 +105,7 @@
                        return None
                fixedextra = dict(c.extra())
                newtopic = None if clear else topic
-               if fixedextra.get(constants.extrakey, None) == topic:
+               if fixedextra.get(constants.extrakey, '') == topic:
                    continue
                if clear and constants.extrakey in fixedextra:
                    del fixedextra[constants.extrakey]
@@ -137,7 +137,7 @@
         if repo.vfs.exists('topic'):
             repo.vfs.unlink('topic')
         return
-    if topic is not None:
+    if topic:
         with repo.vfs.open('topic', 'w') as f:
             f.write(topic)
         return