コード例 #1
0
ファイル: diffparse.py プロジェクト: ugtar/git-cola
    def __init__(self, model, filename="", cached=True, reverse=False):

        self._header_re = re.compile("^@@ -(\d+),(\d+) \+(\d+),(\d+) @@.*")
        self._headers = []

        self._idx = -1
        self._diffs = []
        self._diff_spans = []
        self._diff_offsets = []

        self.head = model.head
        self.amending = model.amending()
        self.start = None
        self.end = None
        self.offset = None
        self.diffs = []
        self.selected = []

        (header, diff) = gitcmds.diff_helper(
            head=self.head,
            amending=self.amending,
            filename=filename,
            with_diff_header=True,
            cached=cached,
            reverse=cached or reverse,
        )
        self.model = model
        self.diff = diff
        self.header = header
        self.parse_diff(diff)

        # Always index into the non-reversed diff
        self.fwd_header, self.fwd_diff = gitcmds.diff_helper(
            head=self.head, amending=self.amending, filename=filename, with_diff_header=True, cached=cached
        )
コード例 #2
0
ファイル: diffparse.py プロジェクト: dcfrancisco/git-cola
    def __init__(self, model, filename='',
                 cached=True, branch=None, reverse=False):

        self._header_re = re.compile('^@@ -(\d+),(\d+) \+(\d+),(\d+) @@.*')
        self._headers = []

        self._idx = -1
        self._diffs = []
        self._diff_spans = []
        self._diff_offsets = []

        self.start = None
        self.end = None
        self.offset = None
        self.diffs = []
        self.selected = []

        (header, diff) = gitcmds.diff_helper(filename=filename,
                                             branch=branch,
                                             with_diff_header=True,
                                             cached=cached and not bool(branch),
                                             reverse=cached or bool(branch) or reverse)
        self.model = model
        self.diff = diff
        self.header = header
        self.parse_diff(diff)

        # Always index into the non-reversed diff
        self.fwd_header, self.fwd_diff = \
            gitcmds.diff_helper(filename=filename,
                                branch=branch,
                                with_diff_header=True,
                                cached=cached and not bool(branch),
                                reverse=bool(branch))
コード例 #3
0
 def get(self, head, amending, filename, cached, reverse):
     return gitcmds.diff_helper(head=head,
                                amending=amending,
                                filename=filename,
                                with_diff_header=True,
                                cached=cached,
                                reverse=reverse)
コード例 #4
0
ファイル: diffparse.py プロジェクト: Viktorbutt/git-cola
 def get(self, head, amending, filename, cached, reverse):
     return gitcmds.diff_helper(head=head,
                                amending=amending,
                                filename=filename,
                                with_diff_header=True,
                                cached=cached,
                                reverse=reverse)
コード例 #5
0
ファイル: cmds.py プロジェクト: ab0de/git-cola
 def __init__(self, filename, cached=False, deleted=False):
     Command.__init__(self)
     opts = {}
     if cached:
         opts["ref"] = self.model.head
     self.new_filename = filename
     self.new_mode = self.model.mode_worktree
     self.new_diff_text = gitcmds.diff_helper(filename=filename, cached=cached, deleted=deleted, **opts)
コード例 #6
0
ファイル: cmds.py プロジェクト: kbielefe/git-cola
 def __init__(self, treeish, filename):
     HeadChangeCommand.__init__(self, treeish)
     self.old_filename = self.model.filename
     self.new_filename = filename
     self.new_mode = self.model.mode_branch
     self.new_diff_text = gitcmds.diff_helper(filename=filename,
                                              cached=False,
                                              reverse=True,
                                              branch=treeish)
コード例 #7
0
ファイル: gitcmds_test.py プロジェクト: Kuangcp/git-cola
def test_diff_helper(app_context):
    helper.commit_files()
    with open('A', 'w') as f:
        f.write('A change\n')
    helper.run_git('add', 'A')

    expect = '+A change\n'
    actual = gitcmds.diff_helper(app_context, ref='HEAD', cached=True)
    assert expect in actual
コード例 #8
0
 def __init__(self, filename, cached=False, deleted=False):
     Command.__init__(self)
     opts = {}
     if cached:
         opts['ref'] = self.model.head
     self.new_filename = filename
     self.new_mode = self.model.mode_worktree
     self.new_diff_text = gitcmds.diff_helper(filename=filename,
                                              cached=cached,
                                              deleted=deleted,
                                              **opts)
コード例 #9
0
ファイル: cmds.py プロジェクト: rakoo/git-cola
 def __init__(self, filenames, cached=False):
     Command.__init__(self)
     # Guard against the list of files being empty
     if not filenames:
         return
     opts = {}
     if cached:
         opts["ref"] = self.model.head
     self.new_filename = filenames[0]
     self.old_filename = self.model.filename
     self.new_mode = self.model.mode_worktree
     self.new_diff_text = gitcmds.diff_helper(filename=self.new_filename, cached=cached, **opts)
コード例 #10
0
ファイル: cmds.py プロジェクト: moreati/git-cola
 def __init__(self, filenames, cached=False):
     Command.__init__(self)
     # Guard against the list of files being empty
     if not filenames:
         return
     opts = {}
     if cached:
         opts['ref'] = self.model.head
     self.new_filename = filenames[0]
     self.old_filename = self.model.filename
     self.new_mode = self.model.mode_worktree
     self.new_diff_text = gitcmds.diff_helper(filename=self.new_filename,
                                              cached=cached, **opts)
コード例 #11
0
ファイル: cmds.py プロジェクト: kbielefe/git-cola
    def __init__(self, filenames, cached=False):
        Command.__init__(self)
        opts = {}
        if cached:
            cached = not self.model.read_only()
            opts = dict(ref=self.model.head)

        self.new_filename = filenames[0]
        self.old_filename = self.model.filename
        if not self.model.read_only():
            if self.model.mode != self.model.mode_amend:
                self.new_mode = self.model.mode_worktree
        self.new_diff_text = gitcmds.diff_helper(filename=self.new_filename,
                                                 cached=cached, **opts)