On 11/05/2016 12:58 AM, Martin von Zweigbergk via Mercurial-devel wrote:
# HG changeset patch
# User Martin von Zweigbergk <martinv...@google.com>
# Date 1478303512 25200
# Fri Nov 04 16:51:52 2016 -0700
# Node ID bb80851fe9a6e14263f0076074108556377141f9
# Parent cb2bac3253fbd52894ffcb4719a148fe6a3da38b
fold: disallow multiple revisions without --exact
It's very easy to think that "hg fold 4::6" will fold exactly those
revisions. In reality, it will fold those *and* any revisions between
them and the working copy. It seems very likely that users who pass
more than one revision wants to fold exactly those revisions, so let's
abort and hint that they may be looking for --exact.
That seems a good first step to take in all cases. Unfortunately, the
patch fails to apply for an unclear reason. Can you send me a new version?
In addition, I suggest the following changes:
- we should allow multiple revision if '.' is one of them. They will be
no surprise in this case.
- update to the commit message,
abort: multiple revisions specified
(do you want --exact?, see "hg help fold" for details)
(I'll tell more about possible changes to the default in the rest of the
thread)
diff -r cb2bac3253fb -r bb80851fe9a6 hgext/evolve.py
--- a/hgext/evolve.py Wed Nov 02 18:56:44 2016 +0100
+++ b/hgext/evolve.py Fri Nov 04 16:51:52 2016 -0700
@@ -3115,6 +3115,11 @@
revs = scmutil.revrange(repo, revs)
if not opts['exact']:
+ if len(revs) > 1:
+ raise error.Abort(_("cannot fold from working directory to "
+ "more than one revision"),
+ hint=_("did you mean to use --exact?"))
+
# Try to extend given revision starting from the working directory
extrevs = repo.revs('(%ld::.) or (.::%ld)', revs, revs)
discardedrevs = [r for r in revs if r not in extrevs]
diff -r cb2bac3253fb -r bb80851fe9a6 tests/test-evolve.t
--- a/tests/test-evolve.t Wed Nov 02 18:56:44 2016 +0100
+++ b/tests/test-evolve.t Fri Nov 04 16:51:52 2016 -0700
@@ -688,7 +688,11 @@
$ hg fold -r 4 -r 6 --exact
abort: cannot fold non-linear revisions (multiple roots given)
[255]
- $ hg fold 10 1
+ $ hg fold 4::5
+ abort: cannot fold from working directory to more than one revision
+ (did you mean to use --exact?)
+ [255]
+ $ hg fold 1
abort: cannot fold non-linear revisions
(given revisions are unrelated to parent of working directory)
[255]
diff -r cb2bac3253fb -r bb80851fe9a6 tests/test-userguide.t
--- a/tests/test-userguide.t Wed Nov 02 18:56:44 2016 +0100
+++ b/tests/test-userguide.t Fri Nov 04 16:51:52 2016 -0700
@@ -109,7 +109,7 @@
7:05e61aab8294 step 1
8:be6d5bc8e4cc step 2
9:35f432d9f7c1 step 3
- $ hg fold -d '0 0' -m 'fix bug 64' -r 7::
+ $ hg fold -d '0 0' -m 'fix bug 64' -r 7
3 changesets folded
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg --hidden shortlog -G -r 6::
--
Pierre-Yves David
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel