aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/storage/vcs/hg.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-12-13 07:20:31 -0500
committerW. Trevor King <wking@drexel.edu>2009-12-13 07:20:31 -0500
commit6f23fccbde4ede1121d5baf35c81932b7c8aa7bb (patch)
tree6457f240162bb45f7b08c3d4bc9d65d6ab53e340 /libbe/storage/vcs/hg.py
parentc2a50865f1ea73f43f2d347b2e7595a484f43e78 (diff)
downloadbugseverywhere-6f23fccbde4ede1121d5baf35c81932b7c8aa7bb.tar.gz
Converted libbe.storage.vcs.hg to new Storage format.
Diffstat (limited to 'libbe/storage/vcs/hg.py')
-rw-r--r--libbe/storage/vcs/hg.py73
1 files changed, 39 insertions, 34 deletions
diff --git a/libbe/storage/vcs/hg.py b/libbe/storage/vcs/hg.py
index ed27717..67c5bf3 100644
--- a/libbe/storage/vcs/hg.py
+++ b/libbe/storage/vcs/hg.py
@@ -26,7 +26,7 @@ import re
import sys
import libbe
-import vcs
+import base
if libbe.TESTING == True:
import unittest
@@ -36,62 +36,67 @@ if libbe.TESTING == True:
def new():
return Hg()
-class Hg(vcs.VCS):
- name="hg"
- client="hg"
+class Hg(base.VCS):
+ name='hg'
+ client='hg'
versioned=True
+
def _vcs_version(self):
- status,output,error = self._u_invoke_client("--version")
+ status,output,error = self._u_invoke_client('--version')
return output
+
+ def _vcs_get_user_id(self):
+ status,output,error = self._u_invoke_client(
+ 'showconfig', 'ui.username')
+ return output.rstrip('\n')
+
def _vcs_detect(self, path):
"""Detect whether a directory is revision-controlled using Mercurial"""
- if self._u_search_parent_directories(path, ".hg") != None:
+ if self._u_search_parent_directories(path, '.hg') != None:
return True
return False
+
def _vcs_root(self, path):
- status,output,error = self._u_invoke_client("root", cwd=path)
+ status,output,error = self._u_invoke_client(
+ 'root', expect=(0,255), cwd=path)
+ if status == 255:
+ # "abort: There is no Mercurial repository here
+ # (.hg not found)!"
+ return None
return output.rstrip('\n')
+
def _vcs_init(self, path):
- self._u_invoke_client("init", cwd=path)
- def _vcs_get_user_id(self):
- status,output,error = self._u_invoke_client("showconfig","ui.username")
- return output.rstrip('\n')
- def _vcs_set_user_id(self, value):
- """
- Supported by the Config Extension, but that is not part of
- standard Mercurial.
- http://www.selenic.com/mercurial/wiki/index.cgi/ConfigExtension
- """
- raise vcs.SettingIDnotSupported
+ self._u_invoke_client('init', cwd=path)
+
def _vcs_add(self, path):
- self._u_invoke_client("add", path)
+ self._u_invoke_client('add', path)
+
def _vcs_remove(self, path):
- self._u_invoke_client("rm", "--force", path)
+ self._u_invoke_client('rm', '--force', path)
+
def _vcs_update(self, path):
pass
- def _vcs_get_file_contents(self, path, revision=None, binary=False):
+
+ def _vcs_get_file_contents(self, path, revision=None):
if revision == None:
- return vcs.VCS._vcs_get_file_contents(self, path, revision, binary=binary)
+ return base.VCS._vcs_get_file_contents(self, path, revision)
else:
status,output,error = \
- self._u_invoke_client("cat","-r",revision,path)
+ self._u_invoke_client('cat', '-r', revision, path)
return output
- def _vcs_duplicate_repo(self, directory, revision=None):
- if revision == None:
- return vcs.VCS._vcs_duplicate_repo(self, directory, revision)
- else:
- self._u_invoke_client("archive", "--rev", revision, directory)
+
def _vcs_commit(self, commitfile, allow_empty=False):
args = ['commit', '--logfile', commitfile]
status,output,error = self._u_invoke_client(*args)
if allow_empty == False:
- strings = ["nothing changed"]
+ strings = ['nothing changed']
if self._u_any_in_string(strings, output) == True:
- raise vcs.EmptyCommit()
+ raise base.EmptyCommit()
return self._vcs_revision_id(-1)
- def _vcs_revision_id(self, index, style="id"):
- args = ["identify", "--rev", str(int(index)), "--%s" % style]
- kwargs = {"expect": (0,255)}
+
+ def _vcs_revision_id(self, index, style='id'):
+ args = ['identify', '--rev', str(int(index)), '--%s' % style]
+ kwargs = {'expect': (0,255)}
status,output,error = self._u_invoke_client(*args, **kwargs)
if status == 0:
id = output.strip()
@@ -102,7 +107,7 @@ class Hg(vcs.VCS):
if libbe.TESTING == True:
- vcs.make_vcs_testcase_subclasses(Hg, sys.modules[__name__])
+ base.make_vcs_testcase_subclasses(Hg, sys.modules[__name__])
unitsuite =unittest.TestLoader().loadTestsFromModule(sys.modules[__name__])
suite = unittest.TestSuite([unitsuite, doctest.DocTestSuite()])