prev: simplify the bookmark preserving logic
authorPierre-Yves David <pierre-yves.david@octobus.net>
Fri, 14 Jul 2017 01:01:22 +0200
changeset 2735 28087c173534
parent 2734 39c3b2b5deb0
child 2736 3c87d5276394
prev: simplify the bookmark preserving logic We can use 'None' as a special value and have a simpler code.
hgext3rd/evolve/__init__.py
--- a/hgext3rd/evolve/__init__.py	Fri Jul 14 00:58:14 2017 +0200
+++ b/hgext3rd/evolve/__init__.py	Fri Jul 14 01:01:22 2017 +0200
@@ -2018,12 +2018,14 @@
             ui.warn(_('(do you want --no-topic)\n'))
         elif len(parents) == 1:
             target = parents[0]
-            bm = repo._activebookmark
-            shouldmove = opts.get('move_bookmark') and bm is not None
+            bookmark = None
+            if opts.get('move_bookmark'):
+                bookmark = repo._activebookmark
             if dryrunopt:
                 ui.write(('hg update %s;\n' % target.rev()))
-                if shouldmove:
-                    ui.write(('hg bookmark %s -r %s;\n' % (bm, target.rev())))
+                if bookmark is not None:
+                    ui.write(('hg bookmark %s -r %s;\n'
+                              % (bookmark, target.rev())))
             else:
                 ret = hg.update(repo, target.rev())
                 if not ret:
@@ -2031,8 +2033,8 @@
                     try:
                         lock = repo.lock()
                         tr = repo.transaction('previous')
-                        if shouldmove:
-                            repo._bookmarks[bm] = target.node()
+                        if bookmark is not None:
+                            repo._bookmarks[bookmark] = target.node()
                             repo._bookmarks.recordchange(tr)
                         else:
                             bookmarksmod.deactivate(repo)