equal
deleted
inserted
replaced
11 possibly in another repository. The transplant is done using 'diff' patches. |
11 possibly in another repository. The transplant is done using 'diff' patches. |
12 |
12 |
13 Transplanted patches are recorded in .hg/transplant/transplants, as a |
13 Transplanted patches are recorded in .hg/transplant/transplants, as a |
14 map from a changeset hash to its hash in the source repository. |
14 map from a changeset hash to its hash in the source repository. |
15 ''' |
15 ''' |
16 from __future__ import absolute_import |
|
17 |
16 |
18 import os |
17 import os |
19 |
18 |
20 from mercurial.i18n import _ |
19 from mercurial.i18n import _ |
21 from mercurial.pycompat import open |
20 from mercurial.pycompat import open |
74 b'log', |
73 b'log', |
75 default=None, |
74 default=None, |
76 ) |
75 ) |
77 |
76 |
78 |
77 |
79 class transplantentry(object): |
78 class transplantentry: |
80 def __init__(self, lnode, rnode): |
79 def __init__(self, lnode, rnode): |
81 self.lnode = lnode |
80 self.lnode = lnode |
82 self.rnode = rnode |
81 self.rnode = rnode |
83 |
82 |
84 |
83 |
85 class transplants(object): |
84 class transplants: |
86 def __init__(self, path=None, transplantfile=None, opener=None): |
85 def __init__(self, path=None, transplantfile=None, opener=None): |
87 self.path = path |
86 self.path = path |
88 self.transplantfile = transplantfile |
87 self.transplantfile = transplantfile |
89 self.opener = opener |
88 self.opener = opener |
90 |
89 |
105 def write(self): |
104 def write(self): |
106 if self.dirty and self.transplantfile: |
105 if self.dirty and self.transplantfile: |
107 if not os.path.isdir(self.path): |
106 if not os.path.isdir(self.path): |
108 os.mkdir(self.path) |
107 os.mkdir(self.path) |
109 fp = self.opener(self.transplantfile, b'w') |
108 fp = self.opener(self.transplantfile, b'w') |
110 for list in pycompat.itervalues(self.transplants): |
109 for list in self.transplants.values(): |
111 for t in list: |
110 for t in list: |
112 l, r = map(hex, (t.lnode, t.rnode)) |
111 l, r = map(hex, (t.lnode, t.rnode)) |
113 fp.write(l + b':' + r + b'\n') |
112 fp.write(l + b':' + r + b'\n') |
114 fp.close() |
113 fp.close() |
115 self.dirty = False |
114 self.dirty = False |
127 if list: |
126 if list: |
128 del list[list.index(transplant)] |
127 del list[list.index(transplant)] |
129 self.dirty = True |
128 self.dirty = True |
130 |
129 |
131 |
130 |
132 class transplanter(object): |
131 class transplanter: |
133 def __init__(self, ui, repo, opts): |
132 def __init__(self, ui, repo, opts): |
134 self.ui = ui |
133 self.ui = ui |
135 self.repo = repo |
134 self.repo = repo |
136 self.path = repo.vfs.join(b'transplant') |
135 self.path = repo.vfs.join(b'transplant') |
137 self.opener = vfsmod.vfs(self.path) |
136 self.opener = vfsmod.vfs(self.path) |