comparison hgext/mq.py @ 5980:dcda0c90125c

mq: pop/refresh: avoid losing revisions not managed by mq We already disallow committing on top of an mq revision exactly to avoid losing this new revision during a qpop/qrefresh, so this can be seen as an additional safety check. If this is not enough to fix issue844, it should at least prevent it from happening.
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Sun, 03 Feb 2008 21:03:46 -0200
parents b4858eb4b58f
children ca2af0c81c9a
comparison
equal deleted inserted replaced
5979:b4858eb4b58f 5980:dcda0c90125c
859 info = [ popi ] + [self.applied[popi].rev, self.applied[popi].name] 859 info = [ popi ] + [self.applied[popi].rev, self.applied[popi].name]
860 860
861 start = info[0] 861 start = info[0]
862 rev = revlog.bin(info[1]) 862 rev = revlog.bin(info[1])
863 863
864 if update:
865 top = self.check_toppatch(repo)
866
867 if repo.changelog.heads(rev) != [revlog.bin(self.applied[-1].rev)]:
868 raise util.Abort("popping would remove a revision not "
869 "managed by this patch queue")
870
864 # we know there are no local changes, so we can make a simplified 871 # we know there are no local changes, so we can make a simplified
865 # form of hg.update. 872 # form of hg.update.
866 if update: 873 if update:
867 top = self.check_toppatch(repo)
868 qp = self.qparents(repo, rev) 874 qp = self.qparents(repo, rev)
869 changes = repo.changelog.read(qp) 875 changes = repo.changelog.read(qp)
870 mmap = repo.manifest.read(changes[0]) 876 mmap = repo.manifest.read(changes[0])
871 m, a, r, d, u = repo.status(qp, top)[:5] 877 m, a, r, d, u = repo.status(qp, top)[:5]
872 if d: 878 if d:
913 wlock = repo.wlock() 919 wlock = repo.wlock()
914 try: 920 try:
915 self.check_toppatch(repo) 921 self.check_toppatch(repo)
916 (top, patchfn) = (self.applied[-1].rev, self.applied[-1].name) 922 (top, patchfn) = (self.applied[-1].rev, self.applied[-1].name)
917 top = revlog.bin(top) 923 top = revlog.bin(top)
924 if repo.changelog.heads(top) != [top]:
925 raise util.Abort("cannot refresh a revision with children")
918 cparents = repo.changelog.parents(top) 926 cparents = repo.changelog.parents(top)
919 patchparent = self.qparents(repo, top) 927 patchparent = self.qparents(repo, top)
920 message, comments, user, date, patchfound = self.readheaders(patchfn) 928 message, comments, user, date, patchfound = self.readheaders(patchfn)
921 929
922 patchf = self.opener(patchfn, 'r+') 930 patchf = self.opener(patchfn, 'r+')