evolvecmd: move more core from __init__.py to evolvecmd.py
authorPulkit Goyal <7895pulkit@gmail.com>
Fri, 19 Jan 2018 16:44:00 +0530
changeset 3466 0a8e3130ad00
parent 3465 ffe566999920
child 3467 41ce24cf288d
evolvecmd: move more core from __init__.py to evolvecmd.py We are done with moving helper code, we will now be moving the evolve command in the new module.
hgext3rd/evolve/__init__.py
hgext3rd/evolve/evolvecmd.py
--- a/hgext3rd/evolve/__init__.py	Fri Jan 19 16:00:21 2018 +0530
+++ b/hgext3rd/evolve/__init__.py	Fri Jan 19 16:44:00 2018 +0530
@@ -947,13 +947,6 @@
     _deprecatealias('gup', 'next')
     _deprecatealias('gdown', 'previous')
 
-
-def _cleanup(ui, repo, startnode, showprogress):
-    if showprogress:
-        ui.progress(_('evolve'), None)
-    if repo['.'] != startnode:
-        ui.status(_('working directory is now at %s\n') % repo['.'])
-
 class MultipleSuccessorsError(RuntimeError):
     """Exception raised by _singlesuccessor when multiple successor sets exists
 
@@ -1140,7 +1133,7 @@
     categories of troubles with the --unstable, --divergent or --bumped flags.
     """
 
-    opts = _checkevolveopts(repo, opts)
+    opts = evolvecmd._checkevolveopts(repo, opts)
     # Options
     contopt = opts['continue']
     anyopt = opts['any']
@@ -1255,48 +1248,7 @@
         if ret[0]:
             replacements[curctx.node()] = [ret[1]]
     progresscb()
-    _cleanup(ui, repo, startnode, showprogress)
-
-def _checkevolveopts(repo, opts):
-    """ check the options passed to `hg evolve` and warn for deprecation warning
-    if any """
-
-    if opts['continue']:
-        if opts['any']:
-            raise error.Abort('cannot specify both "--any" and "--continue"')
-        if opts['all']:
-            raise error.Abort('cannot specify both "--all" and "--continue"')
-
-    if opts['rev']:
-        if opts['any']:
-            raise error.Abort('cannot specify both "--rev" and "--any"')
-        if opts['all']:
-            raise error.Abort('cannot specify both "--rev" and "--all"')
-
-    # Backward compatibility
-    if opts['unstable']:
-        msg = ("'evolve --unstable' is deprecated, "
-               "use 'evolve --orphan'")
-        repo.ui.deprecwarn(msg, '4.4')
-
-        opts['orphan'] = opts['divergent']
-
-    if opts['divergent']:
-        msg = ("'evolve --divergent' is deprecated, "
-               "use 'evolve --content-divergent'")
-        repo.ui.deprecwarn(msg, '4.4')
-
-        opts['content_divergent'] = opts['divergent']
-
-    if opts['bumped']:
-        msg = ("'evolve --bumped' is deprecated, "
-               "use 'evolve --phase-divergent'")
-        repo.ui.deprecwarn(msg, '4.4')
-
-        opts['phase_divergent'] = opts['bumped']
-
-    return opts
-
+    evolvecmd._cleanup(ui, repo, startnode, showprogress)
 
 def _gettopic(ctx):
     """handle topic fetching with or without the extension"""
--- a/hgext3rd/evolve/evolvecmd.py	Fri Jan 19 16:00:21 2018 +0530
+++ b/hgext3rd/evolve/evolvecmd.py	Fri Jan 19 16:44:00 2018 +0530
@@ -843,6 +843,52 @@
 
     fm.end()
 
+def _checkevolveopts(repo, opts):
+    """ check the options passed to `hg evolve` and warn for deprecation warning
+    if any """
+
+    if opts['continue']:
+        if opts['any']:
+            raise error.Abort('cannot specify both "--any" and "--continue"')
+        if opts['all']:
+            raise error.Abort('cannot specify both "--all" and "--continue"')
+
+    if opts['rev']:
+        if opts['any']:
+            raise error.Abort('cannot specify both "--rev" and "--any"')
+        if opts['all']:
+            raise error.Abort('cannot specify both "--rev" and "--all"')
+
+    # Backward compatibility
+    if opts['unstable']:
+        msg = ("'evolve --unstable' is deprecated, "
+               "use 'evolve --orphan'")
+        repo.ui.deprecwarn(msg, '4.4')
+
+        opts['orphan'] = opts['divergent']
+
+    if opts['divergent']:
+        msg = ("'evolve --divergent' is deprecated, "
+               "use 'evolve --content-divergent'")
+        repo.ui.deprecwarn(msg, '4.4')
+
+        opts['content_divergent'] = opts['divergent']
+
+    if opts['bumped']:
+        msg = ("'evolve --bumped' is deprecated, "
+               "use 'evolve --phase-divergent'")
+        repo.ui.deprecwarn(msg, '4.4')
+
+        opts['phase_divergent'] = opts['bumped']
+
+    return opts
+
+def _cleanup(ui, repo, startnode, showprogress):
+    if showprogress:
+        ui.progress(_('evolve'), None)
+    if repo['.'] != startnode:
+        ui.status(_('working directory is now at %s\n') % repo['.'])
+
 def divergentsets(repo, ctx):
     """Compute sets of commits divergent with a given one"""
     cache = {}