prev: issue a proper error when reaching repository root
authorPierre-Yves David <pierre-yves.david@octobus.net>
Fri, 14 Jul 2017 01:32:34 +0200
changeset 2738 3f27fe80be26
parent 2737 66278c4d9c07
child 2739 7d86594cb829
prev: issue a proper error when reaching repository root (and adds the associated test)
hgext3rd/evolve/__init__.py
tests/test-prev-next.t
--- a/hgext3rd/evolve/__init__.py	Fri Jul 14 01:21:32 2017 +0200
+++ b/hgext3rd/evolve/__init__.py	Fri Jul 14 01:32:34 2017 +0200
@@ -2038,7 +2038,10 @@
         if topic and not opts.get("no_topic", False):
             parents = [ctx for ctx in parents if ctx.topic() == topic]
         displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate})
-        if not parents:
+        if wparents[0].node() == node.nullid:
+            ui.warn(_('already at repository root\n'))
+            return 1
+        elif not parents and topic:
             ui.warn(_('no parent in topic "%s"\n') % topic)
             ui.warn(_('(do you want --no-topic)\n'))
         elif len(parents) == 1:
--- a/tests/test-prev-next.t	Fri Jul 14 01:21:32 2017 +0200
+++ b/tests/test-prev-next.t	Fri Jul 14 01:32:34 2017 +0200
@@ -94,6 +94,15 @@
      mark                      2:4e26ef31f919
      no-move                   2:4e26ef31f919
 
+test prev on root
+
+  $ hg up null
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ hg prev
+  already at repository root
+  [1]
+  $ hg up 1
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 Behavior with local modification
 --------------------------------