comparison cmdutil.py @ 257:ffccf0080e54

Move wrappers for hg commands to their own module.
author Augie Fackler <durin42@gmail.com>
date Fri, 10 Apr 2009 22:38:29 -0500
parents 7932d098cb5f
children f8f9a2993705
comparison
equal deleted inserted replaced
256:7932d098cb5f 257:ffccf0080e54
1 #!/usr/bin/python 1 #!/usr/bin/python
2 import re 2 import re
3 import os 3 import os
4 import urllib
4 5
5 from mercurial import util as hgutil 6 from mercurial import util as hgutil
6 7
7 from svn import core 8 from svn import core
8 9
276 or e.apr_err == core.SVN_ERR_FS_CONFLICT): 277 or e.apr_err == core.SVN_ERR_FS_CONFLICT):
277 raise hgutil.Abort('Base text was out of date, maybe rebase?') 278 raise hgutil.Abort('Base text was out of date, maybe rebase?')
278 else: 279 else:
279 raise 280 raise
280 281
281 def filecheck(path):
282 for x in ('locks', 'hooks', 'format', 'db', ):
283 if not os.path.exists(os.path.join(path, x)):
284 return False
285 return True 282 return True
286 283
284 def islocalrepo(url):
285 if not url.startswith('file:///'):
286 return False
287 path = urllib.unquote(url[len('file://'):])
288 while '/' in path:
289 if reduce(lambda x,y: x and y,
290 map(lambda p: os.path.exists(os.path.join(path, p)),
291 ('hooks', 'format', 'db', ))):
292 return True
293 path = path.rsplit('/', 1)[0]
294 return False
287 295
288 def issvnurl(url): 296 def issvnurl(url):
289 return url.startswith('svn+') or ( 297 return url.startswith('svn') or islocalrepo(url)
290 url.startswith('file://') and
291 reduce(lambda x,y: x and y,
292 map(lambda p: os.path.exists(os.path.join(url[7:], p)),
293 ('locks', 'hooks', 'format', 'db', ))))