Mercurial > hg
comparison hgext/imerge.py @ 5054:ec70fd08e16c
Update imerge for new filemerge interface
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Wed, 01 Aug 2007 23:59:19 -0700 |
parents | 58006f8b8275 |
children | 56d48aed1f69 86327d13d916 |
comparison
equal
deleted
inserted
replaced
5053:47a8ea1eb2c3 | 5054:ec70fd08e16c |
---|---|
65 return self.parents[1].node() != nullid | 65 return self.parents[1].node() != nullid |
66 | 66 |
67 def load(self): | 67 def load(self): |
68 # status format. \0-delimited file, fields are | 68 # status format. \0-delimited file, fields are |
69 # p1, p2, conflict count, conflict filenames, resolved filenames | 69 # p1, p2, conflict count, conflict filenames, resolved filenames |
70 # conflict filenames are pairs of localname, remotename | 70 # conflict filenames are tuples of localname, remoteorig, remotenew |
71 | 71 |
72 statusfile = self.opener('status') | 72 statusfile = self.opener('status') |
73 | 73 |
74 status = statusfile.read().split('\0') | 74 status = statusfile.read().split('\0') |
75 if len(status) < 3: | 75 if len(status) < 3: |
79 self.parents = [self.repo.changectx(n) for n in status[:2]] | 79 self.parents = [self.repo.changectx(n) for n in status[:2]] |
80 except LookupError: | 80 except LookupError: |
81 raise util.Abort('merge parent %s not in repository' % short(p)) | 81 raise util.Abort('merge parent %s not in repository' % short(p)) |
82 | 82 |
83 status = status[2:] | 83 status = status[2:] |
84 conflicts = int(status.pop(0)) * 2 | 84 conflicts = int(status.pop(0)) * 3 |
85 self.resolved = status[conflicts:] | 85 self.resolved = status[conflicts:] |
86 for i in xrange(0, conflicts, 2): | 86 for i in xrange(0, conflicts, 3): |
87 self.conflicts[status[i]] = status[i+1] | 87 self.conflicts[status[i]] = (status[i+1], status[i+2]) |
88 | 88 |
89 def save(self): | 89 def save(self): |
90 lock = self.repo.lock() | 90 lock = self.repo.lock() |
91 | 91 |
92 if not os.path.isdir(self.path): | 92 if not os.path.isdir(self.path): |
95 | 95 |
96 out = [hex(n.node()) for n in self.parents] | 96 out = [hex(n.node()) for n in self.parents] |
97 out.append(str(len(self.conflicts))) | 97 out.append(str(len(self.conflicts))) |
98 for f in sorted(self.conflicts): | 98 for f in sorted(self.conflicts): |
99 out.append(f) | 99 out.append(f) |
100 out.append(self.conflicts[f]) | 100 out.extend(self.conflicts[f]) |
101 out.extend(self.resolved) | 101 out.extend(self.resolved) |
102 | 102 |
103 fd.write('\0'.join(out)) | 103 fd.write('\0'.join(out)) |
104 | 104 |
105 def remaining(self): | 105 def remaining(self): |
106 return [f for f in self.conflicts if f not in self.resolved] | 106 return [f for f in self.conflicts if f not in self.resolved] |
107 | 107 |
108 def filemerge(self, fn): | 108 def filemerge(self, fn): |
109 wlock = self.repo.wlock() | 109 wlock = self.repo.wlock() |
110 | 110 |
111 fo = self.conflicts[fn] | 111 (fd, fo) = self.conflicts[fn] |
112 return merge.filemerge(self.repo, fn, fo, self.parents[0], | 112 return merge.filemerge(self.repo, fn, fd, fo, self.parents[0], |
113 self.parents[1]) | 113 self.parents[1]) |
114 | 114 |
115 def start(self, rev=None): | 115 def start(self, rev=None): |
116 _filemerge = merge.filemerge | 116 _filemerge = merge.filemerge |
117 def filemerge(repo, fw, fo, wctx, mctx): | 117 def filemerge(repo, fw, fd, fo, wctx, mctx): |
118 self.conflicts[fw] = fo | 118 self.conflicts[fw] = (fd, fo) |
119 | 119 |
120 merge.filemerge = filemerge | 120 merge.filemerge = filemerge |
121 commands.merge(self.ui, self.repo, rev=rev) | 121 commands.merge(self.ui, self.repo, rev=rev) |
122 merge.filemerge = _filemerge | 122 merge.filemerge = _filemerge |
123 | 123 |
143 self.ui.write(' %s\n' % fn) | 143 self.ui.write(' %s\n' % fn) |
144 remaining = [f for f in self.conflicts if f not in self.resolved] | 144 remaining = [f for f in self.conflicts if f not in self.resolved] |
145 if remaining: | 145 if remaining: |
146 self.ui.write('remaining:\n') | 146 self.ui.write('remaining:\n') |
147 for fn in remaining: | 147 for fn in remaining: |
148 fo = self.conflicts[fn] | 148 (fd, fo) = self.conflicts[fn] |
149 if fn == fo: | 149 if fn == fo: |
150 self.ui.write(' %s\n' % (fn,)) | 150 self.ui.write(' %s\n' % (fn,)) |
151 else: | 151 else: |
152 self.ui.write(' %s (%s)\n' % (fn, fo)) | 152 self.ui.write(' %s (%s)\n' % (fn, fd)) |
153 else: | 153 else: |
154 self.ui.write('all conflicts resolved\n') | 154 self.ui.write('all conflicts resolved\n') |
155 | 155 |
156 def next(self): | 156 def next(self): |
157 remaining = self.remaining() | 157 remaining = self.remaining() |