Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHG48c52385e062: tag: use context manager for locks
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/commands.py (7 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Martin von Zweigbergk | Jun 14 2018, 6:08 PM |
Status | Author | Revision | |
---|---|---|---|
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz |
See :hg:`help dates` for a list of formats valid for -d/--date. | See :hg:`help dates` for a list of formats valid for -d/--date. | ||||
Since tag names have priority over branch names during revision | Since tag names have priority over branch names during revision | ||||
lookup, using an existing branch name as a tag name is discouraged. | lookup, using an existing branch name as a tag name is discouraged. | ||||
Returns 0 on success. | Returns 0 on success. | ||||
""" | """ | ||||
opts = pycompat.byteskwargs(opts) | opts = pycompat.byteskwargs(opts) | ||||
wlock = lock = None | with repo.wlock(), repo.lock(): | ||||
try: | |||||
wlock = repo.wlock() | |||||
lock = repo.lock() | |||||
rev_ = "." | rev_ = "." | ||||
names = [t.strip() for t in (name1,) + names] | names = [t.strip() for t in (name1,) + names] | ||||
if len(names) != len(set(names)): | if len(names) != len(set(names)): | ||||
raise error.Abort(_('tag names must be unique')) | raise error.Abort(_('tag names must be unique')) | ||||
for n in names: | for n in names: | ||||
scmutil.checknewlabel(repo, n, 'tag') | scmutil.checknewlabel(repo, n, 'tag') | ||||
if not n: | if not n: | ||||
raise error.Abort(_('tag names cannot consist entirely of ' | raise error.Abort(_('tag names cannot consist entirely of ' | ||||
# don't allow tagging the null rev | # don't allow tagging the null rev | ||||
if (not opts.get('remove') and | if (not opts.get('remove') and | ||||
scmutil.revsingle(repo, rev_).rev() == nullrev): | scmutil.revsingle(repo, rev_).rev() == nullrev): | ||||
raise error.Abort(_("cannot tag null revision")) | raise error.Abort(_("cannot tag null revision")) | ||||
tagsmod.tag(repo, names, node, message, opts.get('local'), | tagsmod.tag(repo, names, node, message, opts.get('local'), | ||||
opts.get('user'), date, editor=editor) | opts.get('user'), date, editor=editor) | ||||
finally: | |||||
release(lock, wlock) | |||||
@command('tags', formatteropts, '', intents={INTENT_READONLY}) | @command('tags', formatteropts, '', intents={INTENT_READONLY}) | ||||
def tags(ui, repo, **opts): | def tags(ui, repo, **opts): | ||||
"""list repository tags | """list repository tags | ||||
This lists both regular and local tags. When the -v/--verbose | This lists both regular and local tags. When the -v/--verbose | ||||
switch is used, a third column "local" is printed for local tags. | switch is used, a third column "local" is printed for local tags. | ||||
When the -q/--quiet switch is used, only the tag name is printed. | When the -q/--quiet switch is used, only the tag name is printed. |