Mercurial > hg > mercurial-crew-with-dirclash
comparison hgext/convert/hg.py @ 5172:6b4c332f241b
convert: hg: optionally create branches as clones
If convert.hg.clonebranches is set, branches will be created as clones of
their parent revisions. All clones will be subdirectories of the
destination path.
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Wed, 15 Aug 2007 13:21:23 -0700 |
parents | d4fa6bafc43a |
children | 33015dac5df5 |
comparison
equal
deleted
inserted
replaced
5171:f53d97d651f4 | 5172:6b4c332f241b |
---|---|
16 | 16 |
17 class mercurial_sink(converter_sink): | 17 class mercurial_sink(converter_sink): |
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) | |
22 self.clonebranches = ui.configbool('convert', 'hg.clonebranches', False) | |
23 self.lastbranch = None | |
21 try: | 24 try: |
22 self.repo = hg.repository(self.ui, path) | 25 self.repo = hg.repository(self.ui, path) |
23 except: | 26 except: |
24 raise NoRepo("could not open hg repo %s as sink" % path) | 27 raise NoRepo("could not open hg repo %s as sink" % path) |
25 self.lock = None | 28 self.lock = None |
26 self.wlock = None | 29 self.wlock = None |
27 self.branchnames = ui.configbool('convert', 'hg.usebranchnames', True) | |
28 | 30 |
29 def before(self): | 31 def before(self): |
30 self.wlock = self.repo.wlock() | 32 self.wlock = self.repo.wlock() |
31 self.lock = self.repo.lock() | 33 self.lock = self.repo.lock() |
32 | 34 |
56 try: | 58 try: |
57 os.unlink(self.repo.wjoin(f)) | 59 os.unlink(self.repo.wjoin(f)) |
58 #self.repo.remove([f]) | 60 #self.repo.remove([f]) |
59 except: | 61 except: |
60 pass | 62 pass |
63 | |
64 def setbranch(self, branch, pbranch, parents): | |
65 if (not self.clonebranches) or (branch == self.lastbranch): | |
66 return | |
67 | |
68 self.lastbranch = branch | |
69 self.after() | |
70 if not branch: | |
71 branch = 'default' | |
72 if not pbranch: | |
73 pbranch = 'default' | |
74 | |
75 branchpath = os.path.join(self.path, branch) | |
76 try: | |
77 self.repo = hg.repository(self.ui, branchpath) | |
78 except: | |
79 if not parents: | |
80 self.repo = hg.repository(self.ui, branchpath, create=True) | |
81 else: | |
82 self.ui.note(_('cloning branch %s to %s\n') % (pbranch, branch)) | |
83 hg.clone(self.ui, os.path.join(self.path, pbranch), | |
84 branchpath, rev=parents, update=False, | |
85 stream=True) | |
86 self.repo = hg.repository(self.ui, branchpath) | |
61 | 87 |
62 def putcommit(self, files, parents, commit): | 88 def putcommit(self, files, parents, commit): |
63 if not files: | 89 if not files: |
64 return hex(self.repo.changelog.tip()) | 90 return hex(self.repo.changelog.tip()) |
65 | 91 |