Comments
Patch
@@ -1716,41 +1716,47 @@
lockmod.release(lock, wlock)
@command('^fold|squash',
- [('r', 'rev', [], _("explicitly specify the full set of revision to fold")),
+ [('r', 'rev', [], _("revision(s) to fold")),
] + commitopts + commitopts2,
# allow to choose the seed ?
- _('rev'))
+ _('hg fold [OPTION]... [-r] REV'))
def fold(ui, repo, *revs, **opts):
- """Fold multiple revisions into a single one
+ """fold multiple revisions into a single one
- The revisions from your current working directory to the given one are folded
- into a single successor revision.
+ Folds all revisions between the specified revision and the parent
+ of working directory into a single revision. The folded revisions
+ will be marked as obsolete and replaced by the resulting revision.
- you can alternatively use --rev to explicitly specify revisions to be folded,
- ignoring the current working directory parent.
+ If multiple revisions are specified, they will all be folded into
+ one, without implicitly folding from the parent of the current
+ working directory.
"""
revs = list(revs)
- if revs:
- if opts.get('rev', ()):
- raise util.Abort("cannot specify both --rev and a target revision")
- targets = scmutil.revrange(repo, revs)
- revs = repo.revs('(%ld::.) or (.::%ld)', targets, targets)
- elif 'rev' in opts:
- revs = scmutil.revrange(repo, opts['rev'])
- else:
- revs = ()
+ revs.extend(opts['rev'])
if not revs:
- ui.write_err('no revision to fold\n')
- return 1
+ raise util.Abort('no revisions specified')
+
+ revs = scmutil.revrange(repo, revs)
+ if len(revs) == 1:
+ # Try to extend given revision starting from the working directory
+ revs = repo.revs('(%ld::.) or (.::%ld)', revs, revs)
+ if len(revs) == 1:
+ # If that didn't extend, then there's nothing to fold.
+ raise util.Abort('cannot fold current revision with itself\n'
+ '(specify target revision other than '
+ 'current revision)')
+
roots = repo.revs('roots(%ld)', revs)
if len(roots) > 1:
- raise util.Abort("set has multiple roots")
+ raise util.Abort("cannot fold non-contiguous revisions\n"
+ "(multiple roots detected)")
root = repo[roots[0]]
if root.phase() <= phases.public:
- raise util.Abort("can't fold public revisions")
+ raise util.Abort("cannot fold public revisions")
heads = repo.revs('heads(%ld)', revs)
if len(heads) > 1:
- raise util.Abort("set has multiple heads")
+ raise util.Abort("cannot fold non-contiguous revisions\n"
+ "(multiple heads detected)")
head = repo[heads[0]]
wlock = lock = None
try:
@@ -585,10 +585,15 @@
$ rm *.orig
$ hg fold
- no revision to fold
- [1]
- $ hg fold 6 --rev 10
- abort: cannot specify both --rev and a target revision
+ abort: no revisions specified
+ [255]
+ $ hg fold 5 --rev 10
+ abort: cannot fold non-contiguous revisions
+ (multiple roots detected)
+ [255]
+ $ hg fold -r .
+ abort: cannot fold current revision with itself
+ (specify target revision other than current revision)
[255]
$ hg fold 6 # want to run hg fold 6
2 changesets folded