diff options
author | Felipe Contreras <felipe.contreras@gmail.com> | 2013-05-24 21:29:30 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-05-28 07:59:30 -0700 |
commit | 68b161167841c43c138604429f9981cb453aff8a (patch) | |
tree | f7807fafadf64575353438543643c86178c06c93 /contrib/remote-helpers/git-remote-hg | |
parent | 93ae203495ded111bb0206fb50e54d0812df1cd5 (diff) | |
download | git-68b161167841c43c138604429f9981cb453aff8a.tar.gz |
remote-hg: upgrade version 1 marks
As suggested by Jed Brown; there's no need to re-import all the commits.
Cc: Jed Brown <jed@59a2.org>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/remote-helpers/git-remote-hg')
-rwxr-xr-x | contrib/remote-helpers/git-remote-hg | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg index ae7699c5b4..2e4f7ca425 100755 --- a/contrib/remote-helpers/git-remote-hg +++ b/contrib/remote-helpers/git-remote-hg @@ -103,14 +103,20 @@ def get_config_bool(config, default=False): class Marks: - def __init__(self, path): + def __init__(self, path, repo): self.path = path + self.repo = repo self.clear() self.load() if self.version < VERSION: - self.clear() - self.version = VERSION + if self.version == 1: + self.upgrade_one() + + # upgraded? + if self.version < VERSION: + self.clear() + self.version = VERSION def clear(self): self.tips = {} @@ -133,6 +139,14 @@ class Marks: for rev, mark in self.marks.iteritems(): self.rev_marks[mark] = rev + def upgrade_one(self): + def get_id(rev): + return hghex(self.repo.changelog.node(int(rev))) + self.tips = dict((name, get_id(rev)) for name, rev in self.tips.iteritems()) + self.marks = dict((get_id(rev), mark) for rev, mark in self.marks.iteritems()) + self.rev_marks = dict((mark, get_id(rev)) for mark, rev in self.rev_marks.iteritems()) + self.version = 2 + def dict(self): return { 'tips': self.tips, 'marks': self.marks, 'last-mark' : self.last_mark, 'version' : self.version } @@ -973,7 +987,7 @@ def main(args): fix_path(alias, peer or repo, url) marks_path = os.path.join(dirname, 'marks-hg') - marks = Marks(marks_path) + marks = Marks(marks_path, repo) if sys.platform == 'win32': import msvcrt |