changeset 3873:b81fd1487e04

rewing: prevent rewind in case of uncommitted changes rewind can update, which means merge and troubles. We might relax this limitation in the future.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 17 Jun 2018 03:56:54 +0200
parents bbc3cfdfe42b
children 830a2597ba26
files hgext3rd/evolve/rewind.py tests/test-rewind.t
diffstat 2 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/rewind.py	Sun Jun 17 03:46:46 2018 +0200
+++ b/hgext3rd/evolve/rewind.py	Sun Jun 17 03:56:54 2018 +0200
@@ -4,6 +4,7 @@
 import hashlib
 
 from mercurial import (
+    cmdutil,
     error,
     hg,
     obsolete,
@@ -77,6 +78,8 @@
     rewindmap = {}
     sscache = {}
     with repo.wlock(), repo.lock():
+        # stay on the safe side: prevent local case in case we need to upgrade
+        cmdutil.bailifchanged(repo)
 
         rewinded = _select_rewinded(repo, opts)
 
--- a/tests/test-rewind.t	Sun Jun 17 03:46:46 2018 +0200
+++ b/tests/test-rewind.t	Sun Jun 17 03:56:54 2018 +0200
@@ -917,3 +917,21 @@
      date:        Thu Jan 01 00:00:00 1970 +0000
      summary:     c_ROOT
   
+  $ cd ..
+
+Check error cases
+=================
+
+  $ hg clone rewind-testing-base rewind-testing-error
+  updating to branch default
+  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cd rewind-testing-error
+
+Uncommited changes
+------------------
+
+  $ echo C > C
+  $ hg add C
+  $ hg rewind
+  abort: uncommitted changes
+  [255]