diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -968,6 +968,11 @@ def bookmark(ui, repo, *names, **opts): and not force): raise error.Abort( _("a bookmark cannot have the name of an existing branch")) + if len(mark) > 3 and mark in repo and not force: + repo.ui.warn( + _("bookmark %s matches a changeset hash\n" + "(did you leave a -r out of an 'hg bookmark' command?)\n") % + mark) if delete and rename: raise error.Abort(_("--delete and --rename are incompatible")) diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t --- a/tests/test-bookmarks.t +++ b/tests/test-bookmarks.t @@ -311,6 +311,15 @@ bookmark with integer name abort: cannot use an integer as a name [255] +bookmark with a name that matches a node id + $ hg bookmark 925d80f479bb db815d6d32e6 + bookmark 925d80f479bb matches a changeset hash + (did you leave a -r out of an 'hg bookmark' command?) + bookmark db815d6d32e6 matches a changeset hash + (did you leave a -r out of an 'hg bookmark' command?) + $ hg bookmark -d 925d80f479bb + $ hg bookmark -d db815d6d32e6 + incompatible options $ hg bookmark -m Y -d Z