Mercurial > kallithea
comparison rhodecode/lib/__init__.py @ 1571:a9888895b60d beta
added quiet flag into get_current_revision
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Mon, 17 Oct 2011 01:48:00 +0200 |
parents | 70e646b2806a |
children | 5498f86ba217 67168195a676 |
comparison
equal
deleted
inserted
replaced
1569:ff41d5f00e28 | 1571:a9888895b60d |
---|---|
381 from rhodecode.lib.utils import EmptyChangeset | 381 from rhodecode.lib.utils import EmptyChangeset |
382 cs = EmptyChangeset(requested_revision=rev) | 382 cs = EmptyChangeset(requested_revision=rev) |
383 return cs | 383 return cs |
384 | 384 |
385 | 385 |
386 def get_current_revision(): | 386 def get_current_revision(quiet=False): |
387 """ | 387 """ |
388 Returns tuple of (number, id) from repository containing this package | 388 Returns tuple of (number, id) from repository containing this package |
389 or None if repository could not be found. | 389 or None if repository could not be found. |
390 | |
391 :param quiet: prints error for fetching revision if True | |
390 """ | 392 """ |
391 | 393 |
392 try: | 394 try: |
393 from vcs import get_repo | 395 from vcs import get_repo |
394 from vcs.utils.helpers import get_scm | 396 from vcs.utils.helpers import get_scm |
397 scm = get_scm(repopath)[0] | 399 scm = get_scm(repopath)[0] |
398 repo = get_repo(path=repopath, alias=scm) | 400 repo = get_repo(path=repopath, alias=scm) |
399 tip = repo.get_changeset() | 401 tip = repo.get_changeset() |
400 return (tip.revision, tip.short_id) | 402 return (tip.revision, tip.short_id) |
401 except (ImportError, RepositoryError, VCSError), err: | 403 except (ImportError, RepositoryError, VCSError), err: |
402 print ("Cannot retrieve rhodecode's revision. Original error " | 404 if not quiet: |
403 "was: %s" % err) | 405 print ("Cannot retrieve rhodecode's revision. Original error " |
406 "was: %s" % err) | |
404 return None | 407 return None |
408 |