Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change git log order,add status type "Rename". #53

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions checkin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from common import *
from clearcase import cc
from status import Modify, Add, Delete, Rename, SymLink
from status import Modify, Add, Delete, Rename, RenameModify, SymLink
import filecmp
from os import listdir
from os.path import isdir
Expand All @@ -29,7 +29,7 @@ def main(force=False, no_deliver=False, initial=False, all=False, cclabel=''):
if force:
IGNORE_CONFLICTS=True
cc_exec(['update', '.'], errors=False)
log = ['log', '-z', '--reverse', '--pretty=format:'+ LOG_FORMAT ]
log = ['log', '-z', '--reverse', '--topo-order', '--pretty=format:'+ LOG_FORMAT ]
if not all:
log.append('--first-parent')
if not initial:
Expand All @@ -50,6 +50,8 @@ def main(force=False, no_deliver=False, initial=False, all=False, cclabel=''):
reset.main('HEAD')

def getStatuses(id, initial):
modifylist = None

cmd = ['diff','--name-status', '-M', '-z', '--ignore-submodules', '%s^..%s' % (id, id)]
if initial:
cmd = cmd[:-1]
Expand All @@ -58,11 +60,12 @@ def getStatuses(id, initial):
status = git_exec(cmd)
status = status.strip()
status = status.strip("\x00")
types = {'M':Modify, 'R':Rename, 'D':Delete, 'A':Add, 'C':Add, 'S':SymLink}
types = {'M':Modify, 'R':Rename, 'RM': RenameModify, 'D':Delete, 'A':Add, 'C':Add, 'S':SymLink}
list = []
split = status.split('\x00')
while len(split) > 1:
char = split.pop(0)[0] # first char
statusstr = split.pop(0)
char = statusstr[0] # first char
args = [split.pop(0)]
# check if file is really a symlink
cmd = ['ls-tree', '-z', id, '--', args[0]]
Expand All @@ -71,6 +74,8 @@ def getStatuses(id, initial):
args.append(id)
if char == 'R':
args.append(split.pop(0))
if (statusstr[1:] != "100"):
char = "RM"
elif char == 'C':
args = [split.pop(0)]
if args[0] == cache.FILE:
Expand All @@ -80,6 +85,7 @@ def getStatuses(id, initial):
list.append(type)
return list


def checkout(stats, comment, initial):
"""Poor mans two-phase commit"""
transaction = ITransaction(comment) if initial else Transaction(comment)
Expand Down
12 changes: 12 additions & 0 deletions status.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ def commit(self, t):
cc_exec(['rm', self.file])

class Rename(Status):
def __init__(self, files):
self.old = files[0]
self.new = files[1]
self.setFile(self.new)
def stage(self, t):
t.stageDir(dirname(self.old))
self.stageDirs(t)
def commit(self, t):
self.commitDirs(t)
cc_exec(['mv', '-nc', self.old, self.new])

class RenameModify(Rename):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we share more of the base class where possible? Like __init__ and the first part of commit?

def __init__(self, files):
self.old = files[0]
self.new = files[1]
Expand Down