18 def __init__(self, ui, path): |
18 def __init__(self, ui, path): |
19 self.path = path |
19 self.path = path |
20 self.ui = ui |
20 self.ui = ui |
21 self.branchnames = ui.configbool('convert', 'hg.usebranchnames', True) |
21 self.branchnames = ui.configbool('convert', 'hg.usebranchnames', True) |
22 self.clonebranches = ui.configbool('convert', 'hg.clonebranches', False) |
22 self.clonebranches = ui.configbool('convert', 'hg.clonebranches', False) |
|
23 self.tagsbranch = ui.config('convert', 'hg.tagsbranch', 'default') |
23 self.lastbranch = None |
24 self.lastbranch = None |
24 try: |
25 try: |
25 self.repo = hg.repository(self.ui, path) |
26 self.repo = hg.repository(self.ui, path) |
26 except: |
27 except: |
27 raise NoRepo("could not open hg repo %s as sink" % path) |
28 raise NoRepo("could not open hg repo %s as sink" % path) |
137 f = self.repo.wfile(".hgtags", "w") |
138 f = self.repo.wfile(".hgtags", "w") |
138 f.write("".join(newlines)) |
139 f.write("".join(newlines)) |
139 f.close() |
140 f.close() |
140 if not oldlines: self.repo.add([".hgtags"]) |
141 if not oldlines: self.repo.add([".hgtags"]) |
141 date = "%s 0" % int(time.mktime(time.gmtime())) |
142 date = "%s 0" % int(time.mktime(time.gmtime())) |
|
143 extra = {} |
|
144 if self.tagsbranch != 'default': |
|
145 extra['branch'] = self.tagsbranch |
|
146 try: |
|
147 tagparent = self.repo.changectx(self.tagsbranch).node() |
|
148 except hg.RepoError, inst: |
|
149 tagparent = nullid |
142 self.repo.rawcommit([".hgtags"], "update tags", "convert-repo", |
150 self.repo.rawcommit([".hgtags"], "update tags", "convert-repo", |
143 date, self.repo.changelog.tip(), nullid) |
151 date, tagparent, nullid) |
144 return hex(self.repo.changelog.tip()) |
152 return hex(self.repo.changelog.tip()) |
145 |
153 |
146 class mercurial_source(converter_source): |
154 class mercurial_source(converter_source): |
147 def __init__(self, ui, path, rev=None): |
155 def __init__(self, ui, path, rev=None): |
148 converter_source.__init__(self, ui, path, rev) |
156 converter_source.__init__(self, ui, path, rev) |