# HG changeset patch # User Pierre-Yves David # Date 1529200006 -7200 # Node ID bbc3cfdfe42b542954f39adf0ae16d8da625d63f # Parent 2e32a1ef0c6003fd96a5eaa7d5e1a6e439552a6f rewind: default to rewinding the current stack diff -r 2e32a1ef0c60 -r bbc3cfdfe42b hgext3rd/evolve/rewind.py --- 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: diff -r 2e32a1ef0c60 -r bbc3cfdfe42b tests/test-rewind.t --- 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 '.'