Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

make veh not depend on mercurial, make veh.conf version finding work …

…via processes on hg and git
  • Loading branch information...
commit 05ed566bd7e0ebfa2bf661bfa228321ebb750ef6 1 parent 3602490
@nicferrier authored
Showing with 41 additions and 29 deletions.
  1. +1 −1  setup.py
  2. +30 −26 veh/__init__.py
  3. +10 −2 veh/hooks.py
View
2  setup.py
@@ -23,7 +23,7 @@
download_url="http://github.com/nicferrier/veh/downloads",
platforms = ["any"],
packages=['veh'],
- install_requires=['pip', 'virtualenv', 'Mercurial'],
+ install_requires=['pip', 'virtualenv'],
entry_points = {
'console_scripts': [
'veh = veh:main'
View
56 veh/__init__.py
@@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with veh. If not, see <http://www.gnu.org/licenses/>.
-__version__ = "0.92.0"
+__version__ = "0.93.0"
from cmd import Cmd
import sys
@@ -216,39 +216,43 @@ def cleanup_inactive_venvs(repo):
def get_config(repo, rev=None):
"""Get the config from the veh root.
-Using a specified rev only works on Mercurial repos right now."""
- if not rev:
- repo_root = find_root_with_file(".veh.conf", repo)
- cfgfile = os.path.join(repo_root, '.veh.conf')
- if not pathexists(cfgfile):
- raise ConfigMissing(cfgfile)
+ We try and work out what version control system is being used from
+ the location of the veh config file.
+
+ We currently only support Mercurial and GIT.
+
+ The veh.conf MUST exist in the file system though we might read a
+ completly different version of course."""
+
+ repo_root = find_root_with_file(".veh.conf", repo)
+ cfgfile = os.path.join(repo_root, '.veh.conf')
+ if not pathexists(cfgfile):
+ raise ConfigMissing(cfgfile)
+ if not rev:
with open(cfgfile) as fd:
cfg = ConfigParser()
cfg.readfp(fd, '.veh.conf')
-
return cfg
else:
- # This obviously needs fixing to be DVCS agnostic
-
- from mercurial import hg, ui, error
- # NOTE: rev = None in the mercurial api will give you the working dir.
- u = ui.ui()
- try:
- repo = hg.repository(u, repo)
- except error.RepoError as e:
- # repo not found
- raise
- try:
- cfgdata = repo[rev]['.veh.conf'].data()
- except error.RepoLookupError as e:
- # revision not found
- raise
- except error.LookupError as e:
- # config not found
- cfgfile = os.path.join(repo.root, '.veh.conf')
+ # FIXME: Moar DVCS! Moar!
+ repo_command = None
+ if pathexists(os.path.join(repo_root, ".git")):
+ repo_command = "git show %(rev)s:%(path)s" % {
+ "rev": rev,
+ "path": path
+ }
+ elif pathexists(os.path.join(repo_root, ".hg")):
+ repo_command = "hg cat -r %(rev)s %(path)s" % {
+ "rev": rev,
+ "path": path
+ }
+
+ if repo_command:
+ # FIXE we need to mark that this is a verion problem?
raise ConfigMissing(cfgfile)
+ cfgdata = subprocess.check_output(repo_command.split(" "))
cfg = ConfigParser()
cfg.readfp(StringIO(cfgdata), '.veh.conf')
return cfg
View
12 veh/hooks.py
@@ -1,4 +1,9 @@
-import mercurial.node
+
+mercurial_available = True
+try:
+ import mercurial.node
+except ImportError:
+ mercurial_available = False
CFN = '.veh.conf'
@@ -12,6 +17,9 @@ def warn_changes(ui, repo, hooktype, **kwargs):
preupdate.veh=python:veh.hooks.warn_changes
"""
+ if not mercurial_available:
+ raise Exception("No mercurial installed here")
+
try:
if hooktype == 'changegroup':
warning = "WARNING: .veh.conf has been modified in changesets.\n"
@@ -48,5 +56,5 @@ def warn_changes(ui, repo, hooktype, **kwargs):
ui.warn('WARNING: update removing .veh.conf\n')
elif CFN in parent and CFN not in wd:
ui.warn('WARNING: update adding .veh.conf\n')
- except Exception, e:
+ except Exception as e:
ui.error('whoops! %s' % e)
Please sign in to comment.
Something went wrong with that request. Please try again.