Permalink
Browse files

Merge pull request #14 from devnull42/my-improvements

Improvements to gitcc checkin
  • Loading branch information...
charleso committed Mar 10, 2012
2 parents 9f38cf0 + facc0d3 commit 14c5133e0d2edb92b6455934f10a32dd1322c197
Showing with 41 additions and 6 deletions.
  1. +5 −0 README
  2. +12 −4 checkin.py
  3. +2 −2 gitcc
  4. +16 −0 status.py
  5. +6 −0 tag.py
View
5 README
@@ -57,6 +57,11 @@ gitcc rebase --dry-run
Prints out the list of commits and modified files that are pending in clearcase.
+To synchronise just a portion of your git history (instead of from the
+very first commit to HEAD), mark the start point with the command:
+
+gitcc tag <commit>
+
Configuration
=============
View
@@ -2,7 +2,7 @@
from common import *
from clearcase import cc
-from status import Modify, Add, Delete, Rename
+from status import Modify, Add, Delete, Rename, SymLink
import filecmp
from os import listdir
from os.path import isdir
@@ -15,15 +15,18 @@
'force': 'ignore conflicts and check-in anyway',
'no_deliver': 'do not deliver in UCM mode',
'initial': 'checkin everything from the beginning',
+ 'all': 'checkin all parents, not just the first',
}
-def main(force=False, no_deliver=False, initial=False):
+def main(force=False, no_deliver=False, initial=False, all=False):
validateCC()
global IGNORE_CONFLICTS
if force:
IGNORE_CONFLICTS=True
cc_exec(['update', '.'], errors=False)
- log = ['log', '-z', '--first-parent', '--reverse', '--pretty=format:'+ LOG_FORMAT ]
+ log = ['log', '-z', '--reverse', '--pretty=format:'+ LOG_FORMAT ]
+ if not all:
+ log.append('--first-parent')
if not initial:
log.append(CI_TAG + '..')
log = git_exec(log)
@@ -50,12 +53,17 @@ 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}
+ types = {'M':Modify, 'R':Rename, 'D':Delete, 'A':Add, 'C':Add, 'S':SymLink}
list = []
split = status.split('\x00')
while len(split) > 1:
char = split.pop(0)[0] # first char
args = [split.pop(0)]
+ # check if file is really a symlink
+ cmd = ['ls-tree', '-z', id, '--', args[0]]
+ if git_exec(cmd).split(' ')[0] == '120000':
+ char = 'S'
+ args.append(id)
if char == 'R':
args.append(split.pop(0))
elif char == 'C':
View
4 gitcc
@@ -1,10 +1,10 @@
#!/usr/bin/env python
import sys, inspect
from optparse import OptionParser
-import rebase, checkin, init, sync, reset, update
+import rebase, checkin, init, sync, reset, tag, update
commands = [
- init, rebase, checkin, sync, reset, update
+ init, rebase, checkin, sync, reset, tag, update
]
def main():
View
@@ -61,3 +61,19 @@ def commit(self, t):
t.checkedout.remove(self.old)
t.add(self.new)
self.cat()
+
+class SymLink(Status):
+ def __init__(self, files):
+ self.setFile(files[0])
+ id = files[1]
+ self.target = git_exec(['cat-file', 'blob', getBlob(id, self.file)], decode=False)
+ if exists(join(CC_DIR, self.file)):
+ self.rmfirst=True
+ else:
+ self.rmfirst=False
+ def stage(self, t):
+ self.stageDirs(t)
+ def commit(self, t):
+ if self.rmfirst:
+ cc_exec(['rm', self.file])
+ cc_exec(['ln', '-s', self.target, self.file])
View
6 tag.py
@@ -0,0 +1,6 @@
+"""Tag a particular commit as gitcc start point"""
+
+from common import *
+
+def main(commit):
+ tag(CI_TAG, commit)

0 comments on commit 14c5133

Please sign in to comment.