evolve: don't show working directory obsolete message if we were on it stable
authorPulkit Goyal <7895pulkit@gmail.com>
Wed, 27 Dec 2017 05:01:30 +0530
branchstable
changeset 3363 380fa6e8baf2
parent 3362 92b414710d2e
child 3375 1cb549cd6236
evolve: don't show working directory obsolete message if we were on it This patch tweaks showing wc obsolete message functionality to not show the message if the operation led us to the same changeset we were on before and it didn't obsoleted it. This make failed updates, update on current changeset and a pull with no change omit showing the message. This has some cons like if you are on rev 1 which is obsolete and you do `hg up <revset>` where revset is some revset which resolves to the rev 1, we won't show the warning as shown earlier.
CHANGELOG
hgext3rd/evolve/__init__.py
tests/test-evolve-obshistory.t
tests/test-tutorial.t
--- a/CHANGELOG	Thu Dec 28 03:12:54 2017 +0530
+++ b/CHANGELOG	Wed Dec 27 05:01:30 2017 +0530
@@ -5,6 +5,7 @@
 -------------------
 
   * fix `hg prev` behavior on obsolete changesets
+  * no longer issue "obsolete working copy" message during no-op
 
 topic (0.6.1)
 
--- a/hgext3rd/evolve/__init__.py	Thu Dec 28 03:12:54 2017 +0530
+++ b/hgext3rd/evolve/__init__.py	Wed Dec 27 05:01:30 2017 +0530
@@ -684,12 +684,14 @@
 
 # This section take care of issue warning to the user when troubles appear
 
-def _warnobsoletewc(ui, repo):
+def _warnobsoletewc(ui, repo, prevnode=None, wasobs=None):
     rev = repo['.']
 
     if not rev.obsolete():
         return
 
+    if rev.node() == prevnode and wasobs:
+        return
     msg = _("working directory parent is obsolete! (%s)\n")
     shortnode = node.short(rev.node())
 
@@ -763,8 +765,12 @@
 @eh.wrapcommand("pull")
 def wrapmayobsoletewc(origfn, ui, repo, *args, **opts):
     """Warn that the working directory parent is an obsolete changeset"""
+    ctx = repo['.']
+    node = ctx.node()
+    isobs = ctx.obsolete()
+
     def warnobsolete():
-        _warnobsoletewc(ui, repo)
+        _warnobsoletewc(ui, repo, node, isobs)
     wlock = None
     try:
         wlock = repo.wlock()
--- a/tests/test-evolve-obshistory.t	Thu Dec 28 03:12:54 2017 +0530
+++ b/tests/test-evolve-obshistory.t	Wed Dec 27 05:01:30 2017 +0530
@@ -972,8 +972,6 @@
   working directory parent is obsolete! (471f378eab4c)
   (use 'hg evolve' to update to its successor: eb5a0daa2192)
   $ hg update 0dec01379d3b
-  working directory parent is obsolete! (471f378eab4c)
-  (use 'hg evolve' to update to its successor: eb5a0daa2192)
   abort: hidden revision '0dec01379d3b'!
   (use --hidden to access hidden revisions; successor: eb5a0daa2192)
   [255]
@@ -1524,12 +1522,8 @@
   (use 'hg evolve' to update to its successor: eb5a0daa2192)
   $ hg update 0dec01379d3b
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  working directory parent is obsolete! (0dec01379d3b)
-  (use 'hg evolve' to update to its successor: eb5a0daa2192)
   $ hg update --hidden 'desc(B0)'
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  working directory parent is obsolete! (0dec01379d3b)
-  (use 'hg evolve' to update to its successor: eb5a0daa2192)
 
 Test output with pushed and pulled obs markers
 ==============================================
--- a/tests/test-tutorial.t	Thu Dec 28 03:12:54 2017 +0530
+++ b/tests/test-tutorial.t	Wed Dec 27 05:01:30 2017 +0530
@@ -1514,8 +1514,6 @@
   pulling from $TESTTMP/local (glob)
   searching for changes
   no changes found
-  working directory parent is obsolete! (bf1b0d202029)
-  (use 'hg evolve' to update to its successor: ee942144f952)
 
 Now let's see where we are, and update to the successor.