summary refs log tree commit diff stats
path: root/ranger/ext/vcs/hg.py
diff options
context:
space:
mode:
Diffstat (limited to 'ranger/ext/vcs/hg.py')
-rw-r--r--ranger/ext/vcs/hg.py128
1 files changed, 2 insertions, 126 deletions
diff --git a/ranger/ext/vcs/hg.py b/ranger/ext/vcs/hg.py
index 48e991bf..58651795 100644
--- a/ranger/ext/vcs/hg.py
+++ b/ranger/ext/vcs/hg.py
@@ -2,31 +2,24 @@
 
 import os
 import re
-import shutil
 from datetime import datetime
-try:
-    from configparser import RawConfigParser
-except ImportError:
-    from ConfigParser import RawConfigParser
 
 from .vcs import Vcs, VcsError
 
-
 class Hg(Vcs):
     HEAD = 'tip'
-    # Auxiliar stuff
+
+    # Generic
     #---------------------------
 
     def _hg(self, path, args, silent=True, catchout=False, bytes=False):
         return self._vcs(path, 'hg', args, silent=silent, catchout=catchout, bytes=bytes)
 
-
     def _has_head(self):
         """Checks whether repo has head"""
         rnum = self._hg(self.path, ['-q', 'identify', '--num', '-r', self.HEAD], catchout=True)
         return rnum != '-1'
 
-
     def _sanitize_rev(self, rev):
         if rev == None: return None
         rev = rev.strip()
@@ -40,7 +33,6 @@ class Hg(Vcs):
 
         return rev
 
-
     def _log(self, refspec=None, maxres=None, filelist=None):
 
         fmt = "changeset: {rev}:{node}\ntag: {tags}\nuser: {author}\ndate: {date}\nsummary: {desc}\n"
@@ -66,7 +58,6 @@ class Hg(Vcs):
             log.append(dt)
         return log
 
-
     def _hg_file_status(self, st):
         if len(st) != 1: raise VcsError("Wrong hg file status string: %s" % st)
         if   st in "ARM":    return 'staged'
@@ -77,74 +68,19 @@ class Hg(Vcs):
         elif st in "C":      return 'sync'
         else:                return 'unknown'
 
-
-
-    # Repo creation
-    #---------------------------
-
-    def init(self):
-        """Initializes a repo in current path"""
-        self._hg(self.path, ['init'])
-        self.update()
-
-
-    def clone(self, src):
-        """Clones a repo from src"""
-        name = os.path.basename(self.path)
-        path = os.path.dirname(self.path)
-        try:
-            os.rmdir(self.path)
-        except OSError:
-            raise VcsError("Can't clone to %s. It is not an empty directory" % self.path)
-
-        self._hg(path, ['clone', src, name])
-        self.update()
-
-
-
     # Action Interface
     #---------------------------
 
-    def commit(self, message):
-        """Commits with a given message"""
-        self._hg(self.path, ['commit', '-m', message])
-
-
     def add(self, filelist=None):
         """Adds files to the index, preparing for commit"""
         if filelist != None: self._hg(self.path, ['addremove'] + filelist)
         else:                self._hg(self.path, ['addremove'])
 
-
     def reset(self, filelist=None):
         """Removes files from the index"""
         if filelist == None: filelist = self.get_status_subpaths().keys()
         self._hg(self.path, ['forget'] + filelist)
 
-
-    def pull(self):
-        """Pulls a hg repo"""
-        self._hg(self.path, ['pull', '-u'])
-
-
-    def push(self):
-        """Pushes a hg repo"""
-        self._hg(self.path, ['push'])
-
-
-    def checkout(self, rev):
-        """Checks out a branch or revision"""
-        self._hg(self.path, ['update', rev])
-
-
-    def extract_file(self, rev, name, dest):
-        """Extracts a file from a given revision and stores it in dest dir"""
-        if rev == self.INDEX:
-            shutil.copyfile(os.path.join(self.path, name), dest)
-        else:
-            self._hg(self.path, ['cat', '--rev', rev, '--output', dest, name])
-
-
     # Data Interface
     #---------------------------
 
@@ -161,14 +97,6 @@ class Hg(Vcs):
             ret[os.path.normpath(p.strip())] = sta
         return ret
 
-
-    def get_ignore_allfiles(self):
-        """Returns a set of all the ignored files in the repo"""
-        raw = self._hg(self.path, ['status', '-i'], catchout=True, bytes=True)
-        L = re.findall('^I\s*(.*?)\s*$', raw.decode('utf-8'), re.MULTILINE)
-        return set(L)
-
-
     def get_status_remote(self):
         """Checks the status of the repo regarding sync state with remote branch"""
         if self.get_remote() == None:
@@ -190,50 +118,11 @@ class Hg(Vcs):
         elif not ahead and     behind: return "behind"
         elif not ahead and not behind: return "sync"
 
-
     def get_branch(self):
         """Returns the current named branch, if this makes sense for the backend. None otherwise"""
         branch = self._hg(self.path, ['branch'], catchout=True)
         return branch or None
 
-
-    def get_log(self, filelist=None, maxres=None):
-        """Get the entire log for the current HEAD"""
-        if not self._has_head(): return []
-        return self._log(refspec=None, maxres=maxres, filelist=filelist)
-
-
-    def get_raw_log(self, filelist=None):
-        """Gets the raw log as a string"""
-        if not self._has_head(): return []
-        args = ['log']
-        if filelist: args = args + filelist
-        return self._hg(self.path, args, catchout=True)
-
-
-    def get_raw_diff(self, refspec=None, filelist=None):
-        """Gets the raw diff as a string"""
-        args = ['diff', '--git']
-        if refspec:  args = args + [refspec]
-        if filelist: args = args + filelist
-        return self._hg(self.path, args, catchout=True)
-
-
-    def get_remote(self, rev=None):
-        """Returns the url for the remote repo attached to head"""
-        remote = self._hg(self.path, ['showconfig', 'paths.default'], catchout=True)
-        return remote or None
-
-
-    def get_revision_id(self, rev=None):
-        """Get a canonical key for the revision rev"""
-        if rev == None: rev = self.HEAD
-        elif rev == self.INDEX: return None
-        rev = self._sanitize_rev(rev)
-
-        return self._sanitize_rev(self._hg(self.path, ['-q', 'identify', '--id', '-r', rev], catchout=True))
-
-
     def get_info(self, rev=None):
         """Gets info about the given revision rev"""
         if rev == None: rev = self.HEAD
@@ -247,16 +136,3 @@ class Hg(Vcs):
             raise VcsError("More than one instance of revision %s ?!?" % rev)
         else:
             return L[0]
-
-
-    def get_files(self, rev=None):
-        """Gets a list of files in revision rev"""
-        if rev == None: rev = self.HEAD
-        rev = self._sanitize_rev(rev)
-
-        if rev:
-            if rev == self.INDEX: raw = self._hg(self.path, ['locate', "*"], catchout=True)
-            else:                 raw = self._hg(self.path, ['locate', '--rev', rev, "*"], catchout=True)
-            return raw.split('\n')
-        else:
-            return []
c2d6857e1ed916221faae707e3c53ff8ed042'>^
ba6621b5 ^




9a7e1a0f ^
ba6621b5 ^






9a7e1a0f ^
ba6621b5 ^


608a7fa8 ^
ba6621b5 ^


25ad969f ^
c762564b ^
5a2cb154 ^
608a7fa8 ^



c762564b ^
9a7e1a0f ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101