convert/git: rename gitcmd() into gitopen() for readability stable
authorPatrick Mezard <pmezard@gmail.com>
Sun, 25 Apr 2010 22:32:27 +0200
branchstable
changeset 10985 7fab6ae3f688
parent 10980 30ae8174a597
child 10986 610f047326b9
convert/git: rename gitcmd() into gitopen() for readability
hgext/convert/git.py
--- a/hgext/convert/git.py	Sun Apr 25 17:11:36 2010 +0200
+++ b/hgext/convert/git.py	Sun Apr 25 22:32:27 2010 +0200
@@ -16,7 +16,7 @@
     # cannot remove environment variable. Just assume none have
     # both issues.
     if hasattr(os, 'unsetenv'):
-        def gitcmd(self, s):
+        def gitopen(self, s):
             prevgitdir = os.environ.get('GIT_DIR')
             os.environ['GIT_DIR'] = self.path
             try:
@@ -27,7 +27,7 @@
                 else:
                     os.environ['GIT_DIR'] = prevgitdir
     else:
-        def gitcmd(self, s):
+        def gitopen(self, s):
             return util.popen('GIT_DIR=%s %s' % (self.path, s), 'rb')
 
     def __init__(self, ui, path, rev=None):
@@ -44,16 +44,16 @@
 
     def getheads(self):
         if not self.rev:
-            fh = self.gitcmd('git rev-parse --branches --remotes')
+            fh = self.gitopen('git rev-parse --branches --remotes')
             return fh.read().splitlines()
         else:
-            fh = self.gitcmd("git rev-parse --verify %s" % self.rev)
+            fh = self.gitopen("git rev-parse --verify %s" % self.rev)
             return [fh.read()[:-1]]
 
     def catfile(self, rev, type):
         if rev == "0" * 40:
             raise IOError()
-        fh = self.gitcmd("git cat-file %s %s" % (type, rev))
+        fh = self.gitopen("git cat-file %s %s" % (type, rev))
         return fh.read()
 
     def getfile(self, name, rev):
@@ -64,7 +64,7 @@
 
     def getchanges(self, version):
         self.modecache = {}
-        fh = self.gitcmd("git diff-tree -z --root -m -r %s" % version)
+        fh = self.gitopen("git diff-tree -z --root -m -r %s" % version)
         changes = []
         seen = set()
         entry = None
@@ -123,7 +123,7 @@
 
     def gettags(self):
         tags = {}
-        fh = self.gitcmd('git ls-remote --tags "%s"' % self.path)
+        fh = self.gitopen('git ls-remote --tags "%s"' % self.path)
         prefix = 'refs/tags/'
         for line in fh:
             line = line.strip()
@@ -140,7 +140,7 @@
     def getchangedfiles(self, version, i):
         changes = []
         if i is None:
-            fh = self.gitcmd("git diff-tree --root -m -r %s" % version)
+            fh = self.gitopen("git diff-tree --root -m -r %s" % version)
             for l in fh:
                 if "\t" not in l:
                     continue
@@ -148,7 +148,7 @@
                 changes.append(f)
             fh.close()
         else:
-            fh = self.gitcmd('git diff-tree --name-only --root -r %s "%s^%s" --'
+            fh = self.gitopen('git diff-tree --name-only --root -r %s "%s^%s" --'
                              % (version, version, i + 1))
             changes = [f.rstrip('\n') for f in fh]
             fh.close()