Skip to content

Commit b110dbc

Browse files
committed
Add support for numeric hashes for Mercurial, e.g. 'neo update 10'
1 parent c2f587f commit b110dbc

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

mbed/mbed.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585

8686
# mbed url is subset of hg. mbed doesn't support ssh transport
8787
regex_mbed_url = r'^(https?)://([\w\-\.]*mbed\.(co\.uk|org|com))/(users|teams)/([\w\-]{1,32})/(repos|code)/([\w\-]+)/?$'
88-
regex_build_url = r'^(https?://([\w\-\.]*mbed\.(co\.uk|org|com))/(users|teams)/([\w\-]{1,32})/(repos|code)/([\w\-]+))/builds/?([\w\-]{1,32})?/?$'
88+
regex_build_url = r'^(https?://([\w\-\.]*mbed\.(co\.uk|org|com))/(users|teams)/([\w\-]{1,32})/(repos|code)/([\w\-]+))/builds/?([\w\-]{12,40})?/?$'
8989

9090
# default mbed OS url
9191
mbed_os_url = 'https://github.com/ARMmbed/mbed-os'
@@ -242,7 +242,6 @@ def init(path, url):
242242
error("Unable to write bldrc file in \"%s\"" % fl, 1)
243243

244244
def clone(url, path=None, hash=None, depth=None, protocol=None):
245-
# Deploys mbed SDK library build into program
246245
m = Bld.isurl(url)
247246
if not m:
248247
return False
@@ -252,7 +251,6 @@ def clone(url, path=None, hash=None, depth=None, protocol=None):
252251

253252
try:
254253
Bld.init(path, url+'/'+hash)
255-
256254
with cd(path):
257255
if not os.path.exists(arch_dir):
258256
action("Downloading mbed library build \"%s\" (might take a minute)" % hash)
@@ -302,9 +300,8 @@ def pull(repo):
302300
error("mbed library builds do not support pushing")
303301

304302
def update(repo, hash=None, clean=False):
305-
if not hash:
306-
m = Bld.isurl(repo.url)
307-
hash = Hg.remoteid(m.group(1))
303+
m = Bld.isurl(repo.url)
304+
hash = Hg.remoteid(m.group(1), hash)
308305

309306
if not hash:
310307
error("Unable to fetch late mbed library revision")
@@ -474,8 +471,8 @@ def gethash(repo):
474471
def getbranch():
475472
return pquery([hg_cmd, 'branch']).strip() or ""
476473

477-
def remoteid(url):
478-
return pquery([hg_cmd, 'id', '--id', url]).strip() or ""
474+
def remoteid(url, hash=None):
475+
return pquery([hg_cmd, 'id', '--id', url] + (['-r', hash] if hash else [])).strip() or ""
479476

480477
def ignores(repo):
481478
hook = 'ignore.local = .hg/hgignore'
@@ -902,7 +899,7 @@ def pathtype(cls, path=None):
902899
def hashtype(cls, hash, ret_hash=False):
903900
if hash is None or len(hash) == 0:
904901
return 'latest' + (' revision in the current branch' if ret_hash else '')
905-
if re.match(r'^([a-zA-Z0-9]{12,40})$', hash):
902+
elif re.match(r'^([a-zA-Z0-9]{12,40})$', hash) or re.match(r'^([0-9]+)$', hash):
906903
return 'rev' + (' #'+hash if ret_hash else '')
907904
else:
908905
return 'branch' + (' '+hash if ret_hash else '')
@@ -1158,7 +1155,7 @@ def post_action(self):
11581155

11591156
if len(missing):
11601157
warning(
1161-
"mbed OS and tools in this program require Python modules that are not installed.\n"
1158+
"The mbed build tools in this program require Python modules that are not installed.\n"
11621159
"This might prevent you from compiling your code or exporting to IDEs and other toolchains.\n"
11631160
"The missing Python modules are: %s\n"
11641161
"You can install all missing modules by opening a command prompt in \"%s\" and running \"pip install -r %s\"" % (', '.join(missing), mbed_os_path, fname))

0 commit comments

Comments
 (0)