Mercurial > hg
comparison hgext/mq.py @ 7620:fbfd92d51540
mq: refactor the pop code to be more readable and allow more changes
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Mon, 12 Jan 2009 09:53:55 +0100 |
parents | e9da3de01e0a |
children | 6d891df43a5f |
comparison
equal
deleted
inserted
replaced
7619:e9da3de01e0a | 7620:fbfd92d51540 |
---|---|
991 # Allow qpop -a to work repeatedly, | 991 # Allow qpop -a to work repeatedly, |
992 # but not qpop without an argument | 992 # but not qpop without an argument |
993 self.ui.warn(_("no patches applied\n")) | 993 self.ui.warn(_("no patches applied\n")) |
994 return not all | 994 return not all |
995 | 995 |
996 if all: | |
997 start = 0 | |
998 elif patch: | |
999 start = info[0] + 1 | |
1000 else: | |
1001 start = len(self.applied) - 1 | |
1002 | |
1003 if start >= len(self.applied): | |
1004 self.ui.warn(_("qpop: %s is already at the top\n") % patch) | |
1005 return | |
1006 | |
996 if not update: | 1007 if not update: |
997 parents = repo.dirstate.parents() | 1008 parents = repo.dirstate.parents() |
998 rr = [ revlog.bin(x.rev) for x in self.applied ] | 1009 rr = [ revlog.bin(x.rev) for x in self.applied ] |
999 for p in parents: | 1010 for p in parents: |
1000 if p in rr: | 1011 if p in rr: |
1002 update = True | 1013 update = True |
1003 | 1014 |
1004 if not force and update: | 1015 if not force and update: |
1005 self.check_localchanges(repo) | 1016 self.check_localchanges(repo) |
1006 | 1017 |
1007 self.applied_dirty = 1; | 1018 self.applied_dirty = 1 |
1008 end = len(self.applied) | 1019 end = len(self.applied) |
1009 if not patch: | 1020 rev = revlog.bin(self.applied[start].rev) |
1010 if all: | |
1011 popi = 0 | |
1012 else: | |
1013 popi = len(self.applied) - 1 | |
1014 else: | |
1015 popi = info[0] + 1 | |
1016 if popi >= end: | |
1017 self.ui.warn(_("qpop: %s is already at the top\n") % patch) | |
1018 return | |
1019 info = [ popi ] + [self.applied[popi].rev, self.applied[popi].name] | |
1020 | |
1021 start = info[0] | |
1022 rev = revlog.bin(info[1]) | |
1023 | |
1024 if update: | 1021 if update: |
1025 top = self.check_toppatch(repo) | 1022 top = self.check_toppatch(repo) |
1026 | 1023 |
1027 if repo.changelog.heads(rev) != [revlog.bin(self.applied[-1].rev)]: | 1024 if repo.changelog.heads(rev) != [revlog.bin(self.applied[-1].rev)]: |
1028 raise util.Abort(_("popping would remove a revision not " | 1025 raise util.Abort(_("popping would remove a revision not " |