Mercurial > hg
changeset 5109:86327d13d916
imerge: handle renames
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Fri, 03 Aug 2007 18:05:20 -0700 |
parents | ec70fd08e16c |
children | 420e1166a876 |
files | hgext/imerge.py tests/test-imerge tests/test-imerge.out |
diffstat | 3 files changed, 43 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/imerge.py Wed Aug 01 23:59:19 2007 -0700 +++ b/hgext/imerge.py Fri Aug 03 18:05:20 2007 -0700 @@ -23,8 +23,9 @@ tf.add(st, os.path.join('.hg', 'imerge', 'status')) for f in self.im.resolved: - abssrc = self.im.repo.wjoin(f) - tf.add(abssrc, f) + (fd, fo) = self.im.conflicts[f] + abssrc = self.im.repo.wjoin(fd) + tf.add(abssrc, fd) tf.close() @@ -39,12 +40,10 @@ raise InvalidStateFileException('no status file') tf.extract(statusfile, self.im.repo.root) - self.im.load() - p1 = self.im.parents[0].node() - p2 = self.im.parents[1].node() - if self.im.repo.dirstate.parents()[0] != p1: - hg.clean(self.im.repo, self.im.parents[0].node()) - self.im.start(p2) + p1, p2 = self.im.load() + if self.im.repo.dirstate.parents()[0] != p1.node(): + hg.clean(self.im.repo, p1.node()) + self.im.start(p2.node()) tf.extractall(self.im.repo.root) self.im.load() @@ -56,13 +55,12 @@ self.path = repo.join('imerge') self.opener = util.opener(self.path) - self.parents = [self.repo.changectx(n) - for n in self.repo.dirstate.parents()] + self.wctx = self.repo.workingctx() self.conflicts = {} self.resolved = [] def merging(self): - return self.parents[1].node() != nullid + return len(self.wctx.parents()) > 1 def load(self): # status format. \0-delimited file, fields are @@ -76,7 +74,7 @@ raise util.Abort('invalid imerge status file') try: - self.parents = [self.repo.changectx(n) for n in status[:2]] + parents = [self.repo.changectx(n) for n in status[:2]] except LookupError: raise util.Abort('merge parent %s not in repository' % short(p)) @@ -86,6 +84,8 @@ for i in xrange(0, conflicts, 3): self.conflicts[status[i]] = (status[i+1], status[i+2]) + return parents + def save(self): lock = self.repo.lock() @@ -93,7 +93,7 @@ os.mkdir(self.path) fd = self.opener('status', 'wb') - out = [hex(n.node()) for n in self.parents] + out = [hex(n.node()) for n in self.wctx.parents()] out.append(str(len(self.conflicts))) for f in sorted(self.conflicts): out.append(f) @@ -109,8 +109,8 @@ wlock = self.repo.wlock() (fd, fo) = self.conflicts[fn] - return merge.filemerge(self.repo, fn, fd, fo, self.parents[0], - self.parents[1]) + p2 = self.wctx.parents()[1] + return merge.filemerge(self.repo, fn, fd, fo, self.wctx, p2) def start(self, rev=None): _filemerge = merge.filemerge @@ -121,21 +121,21 @@ commands.merge(self.ui, self.repo, rev=rev) merge.filemerge = _filemerge - self.parents = [self.repo.changectx(n) - for n in self.repo.dirstate.parents()] + self.wctx = self.repo.workingctx() self.save() def resume(self): self.load() dp = self.repo.dirstate.parents() - if self.parents[0].node() != dp[0] or self.parents[1].node() != dp[1]: + p1, p2 = self.wctx.parents() + if p1.node() != dp[0] or p2.node() != dp[1]: raise util.Abort('imerge state does not match working directory') def status(self): + p1, p2 = self.wctx.parents() self.ui.write('merging %s and %s\n' % \ - (short(self.parents[0].node()), - short(self.parents[1].node()))) + (short(p1.node()), short(p2.node()))) if self.resolved: self.ui.write('resolved:\n')
--- a/tests/test-imerge Wed Aug 01 23:59:19 2007 -0700 +++ b/tests/test-imerge Fri Aug 03 18:05:20 2007 -0700 @@ -12,7 +12,8 @@ echo bar > bar hg ci -Am0 -d '0 0' -echo foo >> foo +hg mv foo foo2 +echo foo >> foo2 hg ci -m1 -d '1 0' hg up -C 0 @@ -23,14 +24,17 @@ echo % start imerge hg imerge -cat foo +cat foo2 cat bar echo % status hg imerge st +echo % next +hg imerge next + echo % merge next -hg imerge +hg --traceback imerge echo % unresolve hg imerge unres foo @@ -39,13 +43,13 @@ hg imerge merge foo echo % save -echo foo > foo +echo foo > foo2 hg imerge save ../savedmerge echo % load hg up -C 0 hg imerge --traceback load ../savedmerge -cat foo +cat foo2 hg ci -m'merged' -d '3 0' hg tip -v
--- a/tests/test-imerge.out Wed Aug 01 23:59:19 2007 -0700 +++ b/tests/test-imerge.out Fri Aug 03 18:05:20 2007 -0700 @@ -1,45 +1,47 @@ adding bar adding foo -1 files updated, 0 files merged, 0 files removed, 0 files unresolved +1 files updated, 0 files merged, 1 files removed, 0 files unresolved % start imerge 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) -merging e6da46716401 and 1c0a86e7db0d +merging e6da46716401 and 30d266f502e7 remaining: - foo + foo (foo2) foo bar bar bar % status -merging e6da46716401 and 1c0a86e7db0d +merging e6da46716401 and 30d266f502e7 remaining: - foo + foo (foo2) +% next +foo % merge next -merging foo +merging foo and foo2 all conflicts resolved % unresolve % merge foo -merging foo +merging foo and foo2 all conflicts resolved % save % load -2 files updated, 0 files merged, 0 files removed, 0 files unresolved +2 files updated, 0 files merged, 1 files removed, 0 files unresolved 2 files updated, 0 files merged, 0 files removed, 0 files unresolved 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) -merging e6da46716401 and 1c0a86e7db0d +merging e6da46716401 and 30d266f502e7 resolved: foo all conflicts resolved foo -changeset: 3:eaf80a943462 +changeset: 3:fa9a6defdcaf tag: tip parent: 2:e6da46716401 -parent: 1:1c0a86e7db0d +parent: 1:30d266f502e7 user: test date: Thu Jan 01 00:00:03 1970 +0000 -files: foo +files: foo foo2 description: merged