Skip to content

Instantly share code, notes, and snippets.

@AndreyPavlenko
Created September 25, 2011 09:55
Show Gist options
  • Save AndreyPavlenko/1240430 to your computer and use it in GitHub Desktop.
Save AndreyPavlenko/1240430 to your computer and use it in GitHub Desktop.
git-cc.patch
diff --git a/common.py b/common.py
index 9f3d8fb..bc8d56f 100644
--- a/common.py
+++ b/common.py
@@ -9,6 +9,13 @@ if v30:
else:
from ConfigParser import SafeConfigParser
+IS_CYGWIN = sys.platform == 'cygwin'
+
+if IS_CYGWIN:
+ FS = '\\'
+else:
+ FS = os.sep
+
CFG_CC = 'clearcase'
CC_DIR = None
ENCODING = None
@@ -130,14 +137,20 @@ def removeFile(file):
def validateCC():
if not CC_DIR:
fail("No 'clearcase' variable found for branch '%s'" % CURRENT_BRANCH)
-
-GIT_DIR = gitDir()
+
+def path(path, args='-m'):
+ if IS_CYGWIN:
+ return os.popen('cygpath %s "%s"' %(args, path)).readlines()[0].strip()
+ else:
+ return path
+
+GIT_DIR = path(gitDir())
if not exists(join(GIT_DIR, '.git')):
fail("fatal: Not a git repository (or any of the parent directories): .git")
CURRENT_BRANCH = getCurrentBranch() or 'master'
cfg = GitConfigParser(CURRENT_BRANCH)
cfg.read()
-CC_DIR = cfg.get(CFG_CC)
+CC_DIR = path(cfg.get(CFG_CC))
DEBUG = cfg.getCore('debug', True)
CC_TAG = CURRENT_BRANCH + '_cc'
CI_TAG = CURRENT_BRANCH + '_ci'
diff --git a/rebase.py b/rebase.py
index 10bb871..368d2ae 100644
--- a/rebase.py
+++ b/rebase.py
@@ -87,7 +87,7 @@ def getHistory(since):
return cc_exec(lsh)
def filterBranches(version, all=False):
- version = version.split(os.sep)
+ version = version.split(FS)
version.pop()
version = version[-1]
branches = cfg.getBranches();
@@ -210,7 +210,7 @@ class Changeset(object):
def _add(self, file, version):
if not cache.update(CCFile(file, version)):
return
- toFile = join(GIT_DIR, file)
+ toFile = path(join(GIT_DIR, file))
mkdirs(toFile)
removeFile(toFile)
cc_exec(['get','-to', toFile, cc_file(file, version)])
@@ -222,10 +222,10 @@ class Changeset(object):
class Uncataloged(Changeset):
def add(self, files):
- dir = cc_file(self.file, self.version)
+ dir = path(cc_file(self.file, self.version))
diff = cc_exec(['diff', '-diff_format', '-pred', dir], errors=False)
def getFile(line):
- return join(self.file, line[2:max(line.find(' '), line.find(os.sep + ' '))])
+ return join(self.file, line[2:max(line.find(' '), line.find(FS + ' '))])
for line in diff.split('\n'):
sym = line.find(' -> ')
if sym >= 0:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment