diff --git a/method/git.py b/method/git.py index bd5ece8..56794d8 100644 --- a/method/git.py +++ b/method/git.py @@ -173,7 +173,7 @@ class GitDiff(Method): # w.set_error("No difference found") class GitBlame(VcBlame): - '''show blame output for the current version in SVN''' + '''show blame output for the current version in Git''' # rev, user, date, [time], [timezone], [date-str], content num_fields = 3 line_re = re.compile(r'^\^*([0-9a-f]+) \(([a-zA-Z0-9_ ]+|Not Committed Yet) +([-0-9]+) [:0-9]+ +[-\+]\d{4} +\d+\) (.*)\n$') @@ -197,18 +197,18 @@ class GitBlame(VcBlame): cmd = ("git", 'blame', w.buffer.path) return Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) -#class GitBlame2(GitBlame): -# '''show file contents in SVN at revision''' -# args = [arg("revision", t=type(""), p="Revision: ", h="revision number")] -# def _open_pipe(self, w, **vargs): -# cmd = ("git", 'blame', '-v', '-r', vargs['revision'], w.buffer.path) -# return Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) -# -#class GitRevView(VcRevView): -# '''show file contents in SVN at date''' -# args = [arg("revision", t=type(""), p="Revision: ", h="revision number")] -# namebase = 'SVN' -# _is_method = True -# def _get_cmd(self, w, **vargs): -# path = self._get_path(w, **vargs) -# return ("git", 'cat', '-r', vargs['revision'], path) +class GitBlame2(GitBlame): + '''show blame output for the specific revision in Git''' + args = [arg("revision", t=type(""), p="Revision: ", h="revision number")] + def _open_pipe(self, w, **vargs): + cmd = ("git", 'blame', vargs['revision'], w.buffer.path) + return Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) + +class GitRevView(VcRevView): + '''show file contents in Git at revision''' + args = [arg("revision", t=type(""), p="Revision: ", h="revision number")] + namebase = 'Git' + _is_method = True + def _get_cmd(self, w, **vargs): + path = self._get_path(w, **vargs) + return ("git", 'show', vargs['revision'] + ':' + path)