mercurial/bookmarks.py
changeset 43601 a80d5ddecc2d
parent 43600 fe2e0d100187
child 44370 edaae3616ba3
equal deleted inserted replaced
43600:fe2e0d100187 43601:a80d5ddecc2d
   956 
   956 
   957     # unhide revs if any
   957     # unhide revs if any
   958     if rev:
   958     if rev:
   959         repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
   959         repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
   960 
   960 
   961     ctx = scmutil.revsingle(repo, rev)
   961     ctx = scmutil.revsingle(repo, rev, None)
       
   962     # bookmarking wdir means creating a bookmark on p1 and activating it
       
   963     activatenew = not inactive and ctx.rev() is None
       
   964     if ctx.node() is None:
       
   965         ctx = ctx.p1()
   962     tgt = ctx.node()
   966     tgt = ctx.node()
       
   967     assert tgt
   963 
   968 
   964     for mark in names:
   969     for mark in names:
   965         mark = checkformat(repo, mark)
   970         mark = checkformat(repo, mark)
   966         if newact is None:
   971         if newact is None:
   967             newact = mark
   972             newact = mark
   982         if ctx.obsolete():
   987         if ctx.obsolete():
   983             msg = obsutil._getfilteredreason(repo, ctx.hex()[:12], ctx)
   988             msg = obsutil._getfilteredreason(repo, ctx.hex()[:12], ctx)
   984             repo.ui.warn(b"(%s)\n" % msg)
   989             repo.ui.warn(b"(%s)\n" % msg)
   985 
   990 
   986     marks.applychanges(repo, tr, changes)
   991     marks.applychanges(repo, tr, changes)
   987     if not inactive and cur == marks[newact] and not rev:
   992     if activatenew and cur == marks[newact]:
   988         activate(repo, newact)
   993         activate(repo, newact)
   989     elif cur != tgt and newact == repo._activebookmark:
   994     elif cur != tgt and newact == repo._activebookmark:
   990         deactivate(repo)
   995         deactivate(repo)
   991 
   996 
   992 
   997