Skip to content

Commit

Permalink
bookmark: check input looks like hash for "missing -r" warning
Browse files Browse the repository at this point in the history
Summary: Check that the bookmark name looks like a commit hash before we warn about the bookmark name looking like a commit hash. This avoids spurious warnings when creating a local bookmark with the same name as a remote bookmark (i.e. tracking bookmark).

Reviewed By: zzl0

Differential Revision: D67464491

fbshipit-source-id: 87c00fcfd5b4e41a37dc6d9316ba168cce0cf3cc
  • Loading branch information
muirdm authored and facebook-github-bot committed Dec 20, 2024
1 parent bb4c06f commit c1628cc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion eden/scm/sapling/bookmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from __future__ import absolute_import

import errno
import string
import struct
import typing

Expand Down Expand Up @@ -250,7 +251,7 @@ def checkconflict(self, mark, force=False, target=None):
raise error.Abort(
_("bookmark '%s' already exists (use -f to force)") % mark
)
if len(mark) > 3 and not force:
if len(mark) > 3 and not force and all(c in string.hexdigits for c in mark):
try:
shadowhash = mark in self._repo
except error.LookupError: # ambiguous identifier
Expand Down
8 changes: 5 additions & 3 deletions eden/scm/tests/test-bookmarks.t
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,9 @@ bookmark with existing name
abort: bookmark 'Z' already exists (use -f to force)
[255]

bookmark with name of branch
bookmark with name of branch (allowed - branches are deprecated)

$ hg bookmark default
bookmark default matches a changeset hash
(did you leave a -r out of an 'hg bookmark' command?)
$ hg bookmark -f default
$ hg book -d default

Expand All @@ -373,6 +371,10 @@ bookmark with a name that matches a node id
test-hook-bookmark: db815d6d32e6: -> db815d6d32e69058eadefc8cffbad37675707975
$ hg bookmark -d 925d80f479bb
$ hg bookmark -d db815d6d32e6
Don't warn if name clearly isn't a hex node.
$ hg push --to remote-bookmark-name --create -q
$ hg bookmark remote-bookmark-name
$ hg book -d remote-bookmark-name

$ cd ..

Expand Down

0 comments on commit c1628cc

Please sign in to comment.