evolve: handle case when newnode can be None while continuing evolve
authorPulkit Goyal <7895pulkit@gmail.com>
Mon, 22 Jan 2018 18:52:27 +0530
changeset 3490 51c0a23b519e
parent 3489 ee72cdc2387b
child 3491 92df1aac8c7f
evolve: handle case when newnode can be None while continuing evolve There can be case when `hg evolve --continue` is run, when working directory is clean and there is nothing to be included in the new commit. Let's make sure we handle such cases correctly and obsolete the node which is evolved with parent of wdir as successor. This is same as what rebase does.
hgext3rd/evolve/evolvecmd.py
tests/test-evolve-continue.t
--- a/hgext3rd/evolve/evolvecmd.py	Sun Jan 28 19:28:08 2018 +0530
+++ b/hgext3rd/evolve/evolvecmd.py	Mon Jan 22 18:52:27 2018 +0530
@@ -1138,7 +1138,12 @@
                 node = repo.commit(text=message, user=user,
                                    date=date, extra=extra)
 
-            obsolete.createmarkers(repo, [(ctx, (repo[node],))])
+            # resolving conflicts can lead to empty wdir and node can be None in
+            # those cases
+            if node is not None:
+                obsolete.createmarkers(repo, [(ctx, (repo[node],))])
+            else:
+                obsolete.createmarkers(repo, [(ctx, (repo['.'],))])
             evolvestate.delete()
             return
 
--- a/tests/test-evolve-continue.t	Sun Jan 28 19:28:08 2018 +0530
+++ b/tests/test-evolve-continue.t	Mon Jan 22 18:52:27 2018 +0530
@@ -130,54 +130,10 @@
 XXX: maybe we should add a message here about evolve resulting in no commit
   $ hg evolve --continue
   evolving 7:ad0a59d83efe "added e"
-  ** Unknown exception encountered with possibly-broken third-party extension evolve
-  ** which supports versions 4.4 of Mercurial.
-  ** Please disable evolve and try your action again.
-  ** If that fixes the bug please report it to https://bz.mercurial-scm.org/
-  ** Python 2.7.12 (default, Dec  4 2017, 14:50:18) [GCC 5.4.0 20160609]
-  ** Mercurial Distributed SCM (version 4.5+64-87416288be98)
-  ** Extensions loaded: rebase, evolve
-  Traceback (most recent call last):
-    File "/tmp/hgtests.vDbR61/install/bin/hg", line 41, in <module>
-      dispatch.run()
-    File "/tmp/hgtests.vDbR61/install/lib/python/mercurial/dispatch.py", line 88, in run
-      status = (dispatch(req) or 0) & 255
-    File "/tmp/hgtests.vDbR61/install/lib/python/mercurial/dispatch.py", line 183, in dispatch
-      ret = _runcatch(req)
-    File "/tmp/hgtests.vDbR61/install/lib/python/mercurial/dispatch.py", line 324, in _runcatch
-      return _callcatch(ui, _runcatchfunc)
-    File "/tmp/hgtests.vDbR61/install/lib/python/mercurial/dispatch.py", line 332, in _callcatch
-      return scmutil.callcatch(ui, func)
-    File "/tmp/hgtests.vDbR61/install/lib/python/mercurial/scmutil.py", line 154, in callcatch
-      return func()
-    File "/tmp/hgtests.vDbR61/install/lib/python/mercurial/dispatch.py", line 314, in _runcatchfunc
-      return _dispatch(req)
-    File "/tmp/hgtests.vDbR61/install/lib/python/mercurial/dispatch.py", line 918, in _dispatch
-      cmdpats, cmdoptions)
-    File "/tmp/hgtests.vDbR61/install/lib/python/mercurial/dispatch.py", line 673, in runcommand
-      ret = _runcommand(ui, options, cmd, d)
-    File "/tmp/hgtests.vDbR61/install/lib/python/mercurial/dispatch.py", line 926, in _runcommand
-      return cmdfunc()
-    File "/tmp/hgtests.vDbR61/install/lib/python/mercurial/dispatch.py", line 915, in <lambda>
-      d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
-    File "/tmp/hgtests.vDbR61/install/lib/python/mercurial/util.py", line 1195, in check
-      return func(*args, **kwargs)
-    File "/home/foobar/repo/mutable-history/hgext3rd/evolve/evolvecmd.py", line 1141, in evolve
-      obsolete.createmarkers(repo, [(ctx, (repo[node],))])
-    File "/tmp/hgtests.vDbR61/install/lib/python/mercurial/obsolete.py", line 1115, in createmarkers
-      ui=repo.ui)
-    File "/tmp/hgtests.vDbR61/install/lib/python/mercurial/obsolete.py", line 621, in create
-      if len(succ) != 20:
-  TypeError: object of type 'NoneType' has no len()
-  [1]
 
   $ hg glog
   @  8:00a5c774cc37 added d
   |   () draft
-  | *  7:ad0a59d83efe added e
-  | |   () draft
-  | x  6:2a4e03d422e2 added d
-  |/    () draft
   o  5:cb6a2ab625bb added c
   |   () draft
   o  2:b1661037fa25 added b