Commit 7bf91ad2 authored by Matthias Putz's avatar Matthias Putz

working init for win+linux

parent 9da5bff1
This diff is collapsed.
...@@ -537,8 +537,8 @@ class Remote(object): ...@@ -537,8 +537,8 @@ class Remote(object):
self.url = self._Get('url') self.url = self._Get('url')
self.review = self._Get('review') self.review = self._Get('review')
self.projectname = self._Get('projectname') self.projectname = self._Get('projectname')
self.fetch = map(RefSpec.FromString, self.fetch = list(map(RefSpec.FromString,
self._Get('fetch', all_keys=True)) self._Get('fetch', all_keys=True)))
self._review_url = None self._review_url = None
def _InsteadOf(self): def _InsteadOf(self):
...@@ -657,7 +657,7 @@ class Remote(object): ...@@ -657,7 +657,7 @@ class Remote(object):
self._Set('url', self.url) self._Set('url', self.url)
self._Set('review', self.review) self._Set('review', self.review)
self._Set('projectname', self.projectname) self._Set('projectname', self.projectname)
self._Set('fetch', map(str, self.fetch)) self._Set('fetch', list(map(str, self.fetch)))
def _Set(self, key, value): def _Set(self, key, value):
key = 'remote.%s.%s' % (self.name, key) key = 'remote.%s.%s' % (self.name, key)
......
...@@ -130,11 +130,11 @@ class XmlManifest(object): ...@@ -130,11 +130,11 @@ class XmlManifest(object):
try: try:
if os.path.lexists(self.manifestFile): if os.path.lexists(self.manifestFile):
os.remove(self.manifestFile) os.remove(self.manifestFile)
if portable.isLinux(): #if portable.isLinux():
src = 'manifests/%s' % name src = 'manifests/%s' % name
else: #else:
src = self.manifestProject.relpath + '/%s' % name # src = self.manifestProject.relpath + '/%s' % name
portable.os_link(src, self.manifestFile) portable.os_link('./.repo/%s' % src, self.manifestFile)
except OSError as e: except OSError as e:
raise ManifestParseError('cannot link manifest %s: %s' % (name, str(e))) raise ManifestParseError('cannot link manifest %s: %s' % (name, str(e)))
......
...@@ -22,19 +22,20 @@ def pathToWindows(path): ...@@ -22,19 +22,20 @@ def pathToWindows(path):
def os_link(src, dst): def os_link(src, dst):
if isLinux(): if isLinux():
os.symlink(os.path.relpath(src, os.path.dirname(dst)), dst) # requires src in relation to dst
src = os.path.relpath(src, os.path.dirname(dst))
os.symlink(src, dst)
else: else:
dst = pathToLinux(dst) dst = pathToLinux(dst)
#subprocess.call(["ln", "-s", src, dst]) #subprocess.call(["ln", "-s", src, dst])
# ln in MinGW does not create hard links? - it copies # ln in MinGW does not create hard links? - it copies
# python internal link
if os.path.isdir(src): if os.path.isdir(src):
src = os.path.relpath(src, os.path.dirname(dst))
src = pathToWindows(src) src = pathToWindows(src)
# symlink does create soft links in windows for directories dst = pathToWindows(dst)
#os.symlink(src, dst, True) # symlink does create soft links in windows for directories => use mklink
# call windows cmd tool 'mklink' from git bash (mingw) # call windows cmd tool 'mklink' from git bash (mingw)
subprocess.Popen('cmd /c mklink /J %s %s' % (dst, src)) subprocess.Popen('cmd /c mklink /J %s %s' % (dst, src))
else: else:
# requires paths in relation to current dir (not in relation to target file)
src = pathToLinux(src) src = pathToLinux(src)
os.link(src, dst) os.link(src, dst)
\ No newline at end of file
...@@ -1949,6 +1949,11 @@ class Project(object): ...@@ -1949,6 +1949,11 @@ class Project(object):
if not os.path.exists(dotgit): if not os.path.exists(dotgit):
os.makedirs(dotgit) os.makedirs(dotgit)
# create dir - since on Linux a broken link will be created, which is not allowed on windows
rr_cache = os.path.join(self.gitdir, 'rr-cache')
if not os.path.exists(rr_cache):
os.makedirs(rr_cache)
for name in ['config', for name in ['config',
'description', 'description',
'hooks', 'hooks',
...@@ -1958,7 +1963,8 @@ class Project(object): ...@@ -1958,7 +1963,8 @@ class Project(object):
'packed-refs', 'packed-refs',
'refs', 'refs',
'rr-cache', 'rr-cache',
'svn']: #'svn'
]:
try: try:
src = os.path.join(self.gitdir, name) src = os.path.join(self.gitdir, name)
dst = os.path.join(dotgit, name) dst = os.path.join(dotgit, name)
...@@ -1980,9 +1986,6 @@ class Project(object): ...@@ -1980,9 +1986,6 @@ class Project(object):
if GitCommand(self, cmd).Wait() != 0: if GitCommand(self, cmd).Wait() != 0:
raise GitError("cannot initialize work tree") raise GitError("cannot initialize work tree")
rr_cache = os.path.join(self.gitdir, 'rr-cache')
if not os.path.exists(rr_cache):
os.makedirs(rr_cache)
self._CopyFiles() self._CopyFiles()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment