##// END OF EJS Templates
bookmarks: fix check of hash-like name to not abort by ambiguous identifier...
Yuya Nishihara -
r32482:579df5aa default
parent child Browse files
Show More
@@ -968,11 +968,16 b' def bookmark(ui, repo, *names, **opts):'
968 and not force):
968 and not force):
969 raise error.Abort(
969 raise error.Abort(
970 _("a bookmark cannot have the name of an existing branch"))
970 _("a bookmark cannot have the name of an existing branch"))
971 if len(mark) > 3 and mark in repo and not force:
971 if len(mark) > 3 and not force:
972 repo.ui.warn(
972 try:
973 _("bookmark %s matches a changeset hash\n"
973 shadowhash = (mark in repo)
974 "(did you leave a -r out of an 'hg bookmark' command?)\n") %
974 except error.LookupError: # ambiguous identifier
975 mark)
975 shadowhash = False
976 if shadowhash:
977 repo.ui.warn(
978 _("bookmark %s matches a changeset hash\n"
979 "(did you leave a -r out of an 'hg bookmark' command?)\n")
980 % mark)
976
981
977 if delete and rename:
982 if delete and rename:
978 raise error.Abort(_("--delete and --rename are incompatible"))
983 raise error.Abort(_("--delete and --rename are incompatible"))
@@ -320,8 +320,36 b' bookmark with a name that matches a node'
320 $ hg bookmark -d 925d80f479bb
320 $ hg bookmark -d 925d80f479bb
321 $ hg bookmark -d db815d6d32e6
321 $ hg bookmark -d db815d6d32e6
322
322
323 $ cd ..
324
325 bookmark with a name that matches an ambiguous node id
326
327 $ hg init ambiguous
328 $ cd ambiguous
329 $ echo 0 > a
330 $ hg ci -qAm 0
331 $ for i in 1057 2857 4025; do
332 > hg up -q 0
333 > echo $i > a
334 > hg ci -qm $i
335 > done
336 $ hg up -q null
337 $ hg log -r0: -T '{rev}:{node}\n'
338 0:b4e73ffab476aa0ee32ed81ca51e07169844bc6a
339 1:c56256a09cd28e5764f32e8e2810d0f01e2e357a
340 2:c5623987d205cd6d9d8389bfc40fff9dbb670b48
341 3:c562ddd9c94164376c20b86b0b4991636a3bf84f
342
343 $ hg bookmark -r0 c562
344 $ hg bookmarks
345 c562 0:b4e73ffab476
346
347 $ cd ..
348
323 incompatible options
349 incompatible options
324
350
351 $ cd repo
352
325 $ hg bookmark -m Y -d Z
353 $ hg bookmark -m Y -d Z
326 abort: --delete and --rename are incompatible
354 abort: --delete and --rename are incompatible
327 [255]
355 [255]
General Comments 0
You need to be logged in to leave comments. Login now