Skip to content
Snippets Groups Projects
Commit 36e94e805fa7 authored by Scott Chacon's avatar Scott Chacon
Browse files

added basic config file for remembering remote urls

parent 01f28d40cb6a
No related branches found
No related tags found
No related merge requests found
CLONE
===========
* only try to import non-mapped commits
* checkout the HEAD
* limit to HEAD branch? (gh-pages makes weird import)
- possibly also add bookmarks on the same development line
GENERAL
==========
......@@ -8,13 +3,5 @@
* strip or close branches that have been abandoned (?)
* tag conversion
FETCH
===========
* gfetch command
* some sort of remote management
* remote management
PUSH
==========
......@@ -30,3 +17,15 @@
* upload packfile, remove temp packfile
* convert tags to git
CLONE
===========
* tag conversion
FETCH
===========
* gfetch command
* only try to import non-mapped commits
* strip or close branches that have been abandoned (?)
......@@ -49,7 +49,7 @@
node = git.remote_head('origin')
hg.update(dest_repo, node)
def gpush(ui, repo):
def gpush(ui, repo, remote_name):
dest_repo.ui.status(_("pushing to git url\n"))
def gpull(ui, repo):
......
......@@ -15,8 +15,9 @@
self.ui = ui
self.load_git()
self.load_map()
self.load_config()
def load_git(self):
git_dir = os.path.join(self.repo.path, 'git')
self.git = Repo(git_dir)
......@@ -18,11 +19,13 @@
def load_git(self):
git_dir = os.path.join(self.repo.path, 'git')
self.git = Repo(git_dir)
## FILE LOAD AND SAVE METHODS
def load_map(self):
self._map = {}
if os.path.exists(self.repo.join('git-mapfile')):
for line in self.repo.opener('git-mapfile'):
gitsha, hgsha = line.strip().split(' ', 1)
self._map[gitsha] = hgsha
......@@ -23,12 +26,12 @@
def load_map(self):
self._map = {}
if os.path.exists(self.repo.join('git-mapfile')):
for line in self.repo.opener('git-mapfile'):
gitsha, hgsha = line.strip().split(' ', 1)
self._map[gitsha] = hgsha
def save_map(self):
file = self.repo.opener('git-mapfile', 'w+')
for gitsha, hgsha in self._map.iteritems():
file.write("%s %s\n" % (gitsha, hgsha))
file.close()
......@@ -30,8 +33,24 @@
def save_map(self):
file = self.repo.opener('git-mapfile', 'w+')
for gitsha, hgsha in self._map.iteritems():
file.write("%s %s\n" % (gitsha, hgsha))
file.close()
def load_config(self):
self._config = {}
if os.path.exists(self.repo.join('git-config')):
for line in self.repo.opener('git-config'):
key, value = line.strip().split(' ', 1)
self._config[key] = value
def save_config(self):
file = self.repo.opener('git-config', 'w+')
for key, value in self._config.iteritems():
file.write("%s %s\n" % (key, value))
file.close()
## END FILE LOAD AND SAVE METHODS
def fetch(self, remote_name):
self.ui.status(_("fetching from : " + remote_name + "\n"))
......@@ -42,6 +61,7 @@
# TODO: make these actually save and recall
def remote_add(self, remote_name, git_url):
self._git_url = git_url
self._config['remote.' + remote_name + '.url'] = git_url
self.save_config()
def remote_name_to_url(self, remote_name):
......@@ -46,6 +66,6 @@
def remote_name_to_url(self, remote_name):
return self._git_url
return self._config['remote.' + remote_name + '.url']
def remote_head(self, remote_name):
for head, sha in self.git.remote_refs(remote_name).iteritems():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment