forked from glandium/git-cinnabar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-remote-hg
executable file
·47 lines (38 loc) · 1.07 KB
/
git-remote-hg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python2.7
from __future__ import division
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__)))
sys.path.append(os.path.join(os.path.dirname(__file__), 'pythonlib'))
from cinnabar.githg import (
UpgradeException,
GitHgStore,
)
from cinnabar.hg.repo import Remote
import logging
from cinnabar.remote_helper import (
GitRemoteHelper,
TagsRemoteHelper,
)
from cinnabar.util import run
def main(args):
if sys.platform == 'win32':
# By default, sys.stdout on Windows will transform \n into \r\n, which
# the calling git process won't recognize in our answers.
import msvcrt
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
assert len(args) == 2
remote = Remote(*args)
try:
store = GitHgStore()
except UpgradeException as e:
logging.error(e.message)
return 1
if remote.url == 'tags:':
helper = TagsRemoteHelper(store)
else:
helper = GitRemoteHelper(store, remote)
helper.run()
store.close()
if __name__ == '__main__':
run(main)