rewind: default to rewinding the current stack
authorPierre-Yves David <pierre-yves.david@octobus.net>
Sun, 17 Jun 2018 03:46:46 +0200
changeset 3872 bbc3cfdfe42b
parent 3871 2e32a1ef0c60
child 3873 b81fd1487e04
rewind: default to rewinding the current stack
hgext3rd/evolve/rewind.py
tests/test-rewind.t
--- a/hgext3rd/evolve/rewind.py	Sun Jun 17 03:10:19 2018 +0200
+++ b/hgext3rd/evolve/rewind.py	Sun Jun 17 03:46:46 2018 +0200
@@ -43,6 +43,9 @@
     obsolete the changeset you rewind from). Rewinding "to" will restore the
     changeset you have selected (and obsolete their latest successors).
 
+    By default, we rewind from the working copy parents, restoring its
+    precursor.
+
     When we rewind to an obsolete version, we also rewind to all its obsolete
     ancestors. To only rewind to the explicitly selection changesets use the
     `--exact` flag. Using the `--exact` flag can restore some changesets as
@@ -120,10 +123,14 @@
     """
     unfi = repo.unfiltered()
     rewinded = set()
-    if opts.get('to'):
-        rewinded.update(scmutil.revrange(repo, opts.get('to')))
-    if opts.get('from'):
-        succs = scmutil.revrange(repo, opts.get('from'))
+    revsto = opts.get('to')
+    revsfrom = opts.get('from')
+    if not (revsto or revsfrom):
+        revsfrom.append('.')
+    if revsto:
+        rewinded.update(scmutil.revrange(repo, revsto))
+    if revsfrom:
+        succs = scmutil.revrange(repo, revsfrom)
         rewinded.update(unfi.revs('precursors(%ld)', succs))
 
     if not rewinded:
--- a/tests/test-rewind.t	Sun Jun 17 03:10:19 2018 +0200
+++ b/tests/test-rewind.t	Sun Jun 17 03:46:46 2018 +0200
@@ -748,8 +748,10 @@
      summary:     c_ROOT
   
 
-Testing --from (and cleanup)
-```````````````````````````
+Testing default argument (and cleanup)
+``````````````````````````````````````
+
+rewind with no argument should be equivalent to `--from .`
 
   $ echo 'default-date = 4 0' >> $HGRCPATH
   $ hg rewind --from '.'