зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1274693 - Upgrade robustcheckout extension to require --revision be a revision; r=jlund
This is a straight import of version-control-tools:hgext/robustcheckout/__init__.py at d115bc9578dac4ae2694ea93bb9662de9e6b0b67. Code was reviewed in bug 1274095. Should be a rubber stamp review. MozReview-Commit-ID: CEXR9uCHBfI --HG-- extra : rebase_source : c71bf0bc965993183a197e93459826137392d9e7
This commit is contained in:
Родитель
bd43ebe418
Коммит
373e3998df
|
@ -127,6 +127,12 @@ def robustcheckout(ui, url, dest, upstream=None, revision=None, branch=None,
|
|||
if revision and branch:
|
||||
raise error.Abort('cannot specify both --revision and --branch')
|
||||
|
||||
# Require revision to look like a SHA-1.
|
||||
if revision:
|
||||
if len(revision) < 12 or len(revision) > 40 or not re.match('^[a-f0-9]+$', revision):
|
||||
raise error.Abort('--revision must be a SHA-1 fragment 12-40 '
|
||||
'characters long')
|
||||
|
||||
sharebase = sharebase or ui.config('share', 'pool')
|
||||
if not sharebase:
|
||||
raise error.Abort('share base directory not defined; refusing to operate',
|
||||
|
@ -241,13 +247,19 @@ def _docheckout(ui, url, dest, upstream, revision, branch, purge, sharebase):
|
|||
# wanted revision.
|
||||
|
||||
repo = hg.repository(ui, dest)
|
||||
|
||||
# We only pull if we are using symbolic names or the requested revision
|
||||
# doesn't exist.
|
||||
havewantedrev = False
|
||||
if revision:
|
||||
havewantedrev = revision in repo
|
||||
else:
|
||||
assert branch
|
||||
# Branch names are not constant over time, so always pull to
|
||||
# ensure we have the latest revision.
|
||||
if revision and revision in repo:
|
||||
ctx = repo[revision]
|
||||
|
||||
if not ctx.hex().startswith(revision):
|
||||
raise error.Abort('--revision argument is ambiguous',
|
||||
hint='must be the first 12+ characters of a '
|
||||
'SHA-1 fragment')
|
||||
|
||||
havewantedrev = True
|
||||
|
||||
if not havewantedrev:
|
||||
ui.write('(pulling to obtain %s)\n' % (revision or branch,))
|
||||
|
|
Загрузка…
Ссылка в новой задаче