# HG changeset patch # User Matt Mackall # Date 2011-07-22 22:17:23 # Node ID ebdfdba0faafc5728b2dd4084fed50d06a6fad60 # Parent 44382887d0122c518d16a5e19487b5a0c31d2738 # Parent 2957b8b1e8091e6e146aaf8659bc67a510092dfa merge with stable diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -180,7 +180,7 @@ def rebase(ui, repo, **opts): for rev in state: branches.add(repo[rev].branch()) if len(branches) > 1: - raise util.Abort(_('cannot collapse multiple named ' + raise util.Abort(_('cannot collapse multiple named ' 'branches')) diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -4156,9 +4156,11 @@ def revert(ui, repo, *pats, **opts): To cancel a merge (and lose your changes), use :hg:`update --clean .`. With no revision specified, revert the specified files or directories - to the state they had in the first parent of the working directory. + to the contents they had in the parent of the working directory. This restores the contents of files to an unmodified - state and unschedules adds, removes, copies, and renames. + state and unschedules adds, removes, copies, and renames. If the + working directory has two parents, you must explicitly specify a + revision. Using the -r/--rev or -d/--date options, revert the given files or directories to their states as of a specific revision. Because @@ -4181,6 +4183,11 @@ def revert(ui, repo, *pats, **opts): opts["rev"] = cmdutil.finddate(ui, repo, opts["date"]) parent, p2 = repo.dirstate.parents() + if not opts.get('rev') and p2 != nullid: + # revert after merge is a trap for new users (issue2915) + raise util.Abort(_('uncommitted merge with no revision specified'), + hint=_('use "hg update" or see "hg help revert"')) + ctx = scmutil.revsingle(repo, opts.get('rev')) node = ctx.node() diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -651,7 +651,7 @@ def _dispatch(req): req.args = ['--repository', guess] + fullargs return _dispatch(req) if not path: - raise error.RepoError(_("no repository found in %r" + raise error.RepoError(_("no repository found in '%s'" " (.hg not found)") % os.getcwd()) raise if repo: diff --git a/mercurial/hook.py b/mercurial/hook.py --- a/mercurial/hook.py +++ b/mercurial/hook.py @@ -65,26 +65,27 @@ def _pythonhook(ui, repo, name, hname, f '("%s" is not callable)') % (hname, funcname)) try: - # redirect IO descriptors the the ui descriptors so hooks that write - # directly to these don't mess the command protocol when running through - # the command server - old = sys.stdout, sys.stderr, sys.stdin - sys.stdout, sys.stderr, sys.stdin = ui.fout, ui.ferr, ui.fin + try: + # redirect IO descriptors the the ui descriptors so hooks + # that write directly to these don't mess up the command + # protocol when running through the command server + old = sys.stdout, sys.stderr, sys.stdin + sys.stdout, sys.stderr, sys.stdin = ui.fout, ui.ferr, ui.fin - r = obj(ui=ui, repo=repo, hooktype=name, **args) - except KeyboardInterrupt: - raise - except Exception, exc: - if isinstance(exc, util.Abort): - ui.warn(_('error: %s hook failed: %s\n') % - (hname, exc.args[0])) - else: - ui.warn(_('error: %s hook raised an exception: ' - '%s\n') % (hname, exc)) - if throw: + r = obj(ui=ui, repo=repo, hooktype=name, **args) + except KeyboardInterrupt: raise - ui.traceback() - return True + except Exception, exc: + if isinstance(exc, util.Abort): + ui.warn(_('error: %s hook failed: %s\n') % + (hname, exc.args[0])) + else: + ui.warn(_('error: %s hook raised an exception: ' + '%s\n') % (hname, exc)) + if throw: + raise + ui.traceback() + return True finally: sys.stdout, sys.stderr, sys.stdin = old if r: diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -1332,6 +1332,8 @@ class url(object): >>> url('file:///home/joe/repo') + >>> url('file:///c:/temp/foo/') + >>> url('bundle:foo') >>> url('bundle://../foo') @@ -1421,7 +1423,7 @@ class url(object): path = None if not self.host: self.host = None - if path: + if path and not hasdriveletter(path): path = '/' + path if self.host and '@' in self.host: diff --git a/tests/test-confused-revert.t b/tests/test-confused-revert.t --- a/tests/test-confused-revert.t +++ b/tests/test-confused-revert.t @@ -59,8 +59,8 @@ Should show a removed and b added: Revert should fail: $ hg revert - abort: no files or directories specified - (uncommitted merge, use --all to discard all changes, or 'hg update -C .' to abort the merge) + abort: uncommitted merge with no revision specified + (use "hg update" or see "hg help revert") [255] Revert should be ok now: diff --git a/tests/test-i18n.t b/tests/test-i18n.t --- a/tests/test-i18n.t +++ b/tests/test-i18n.t @@ -8,17 +8,17 @@ Default encoding in tests is "ascii" and using the "replace" error handler: $ LANGUAGE=pt_BR hg tip - abortado: n?o foi encontrado um reposit?rio em '$TESTTMP' (.hg n?o encontrado)! + abortado: no repository found in '$TESTTMP' (.hg not found)! [255] Using a more accomodating encoding: $ HGENCODING=UTF-8 LANGUAGE=pt_BR hg tip - abortado: n\xc3\xa3o foi encontrado um reposit\xc3\xb3rio em '$TESTTMP' (.hg n\xc3\xa3o encontrado)! (esc) + abortado: no repository found in '$TESTTMP' (.hg not found)! [255] Different encoding: $ HGENCODING=Latin-1 LANGUAGE=pt_BR hg tip - abortado: n\xe3o foi encontrado um reposit\xf3rio em '$TESTTMP' (.hg n\xe3o encontrado)! (esc) + abortado: no repository found in '$TESTTMP' (.hg not found)! [255]