601 |
601 |
602 self.ui.warn(_("patch didn't work out, merging %s\n") % patch) |
602 self.ui.warn(_("patch didn't work out, merging %s\n") % patch) |
603 |
603 |
604 # apply failed, strip away that rev and merge. |
604 # apply failed, strip away that rev and merge. |
605 hg.clean(repo, head) |
605 hg.clean(repo, head) |
606 self.strip(repo, [n], update=False, backup='strip') |
606 strip(self.ui, repo, [n], update=False, backup='strip') |
607 |
607 |
608 ctx = repo[rev] |
608 ctx = repo[rev] |
609 ret = hg.merge(repo, rev) |
609 ret = hg.merge(repo, rev) |
610 if ret: |
610 if ret: |
611 raise util.Abort(_("update returned %d") % ret) |
611 raise util.Abort(_("update returned %d") % ret) |
1101 raise |
1101 raise |
1102 self.removeundo(repo) |
1102 self.removeundo(repo) |
1103 finally: |
1103 finally: |
1104 release(wlock) |
1104 release(wlock) |
1105 |
1105 |
1106 def strip(self, repo, revs, update=True, backup="all", force=None): |
|
1107 wlock = lock = None |
|
1108 try: |
|
1109 wlock = repo.wlock() |
|
1110 lock = repo.lock() |
|
1111 |
|
1112 if update: |
|
1113 checklocalchanges(repo, force=force) |
|
1114 urev, p2 = repo.changelog.parents(revs[0]) |
|
1115 if p2 != nullid and p2 in [x.node for x in self.applied]: |
|
1116 urev = p2 |
|
1117 hg.clean(repo, urev) |
|
1118 repo.dirstate.write() |
|
1119 |
|
1120 repair.strip(self.ui, repo, revs, backup) |
|
1121 finally: |
|
1122 release(lock, wlock) |
|
1123 |
|
1124 def isapplied(self, patch): |
1106 def isapplied(self, patch): |
1125 """returns (index, rev, patch)""" |
1107 """returns (index, rev, patch)""" |
1126 for i, a in enumerate(self.applied): |
1108 for i, a in enumerate(self.applied): |
1127 if a.name == patch: |
1109 if a.name == patch: |
1128 return (i, a.node, a.name) |
1110 return (i, a.node, a.name) |
1441 repo.dirstate.normal(f) |
1423 repo.dirstate.normal(f) |
1442 repo.setparents(qp, nullid) |
1424 repo.setparents(qp, nullid) |
1443 for patch in reversed(self.applied[start:end]): |
1425 for patch in reversed(self.applied[start:end]): |
1444 self.ui.status(_("popping %s\n") % patch.name) |
1426 self.ui.status(_("popping %s\n") % patch.name) |
1445 del self.applied[start:end] |
1427 del self.applied[start:end] |
1446 self.strip(repo, [rev], update=False, backup='strip') |
1428 strip(self.ui, repo, [rev], update=False, backup='strip') |
1447 for s, state in repo['.'].substate.items(): |
1429 for s, state in repo['.'].substate.items(): |
1448 repo['.'].sub(s).get(state) |
1430 repo['.'].sub(s).get(state) |
1449 if self.applied: |
1431 if self.applied: |
1450 self.ui.write(_("now at: %s\n") % self.applied[-1].name) |
1432 self.ui.write(_("now at: %s\n") % self.applied[-1].name) |
1451 else: |
1433 else: |
1644 |
1626 |
1645 # assumes strip can roll itself back if interrupted |
1627 # assumes strip can roll itself back if interrupted |
1646 repo.setparents(*cparents) |
1628 repo.setparents(*cparents) |
1647 self.applied.pop() |
1629 self.applied.pop() |
1648 self.applieddirty = True |
1630 self.applieddirty = True |
1649 self.strip(repo, [top], update=False, |
1631 strip(self.ui, repo, [top], update=False, backup='strip') |
1650 backup='strip') |
|
1651 except: # re-raises |
1632 except: # re-raises |
1652 repo.dirstate.invalidate() |
1633 repo.dirstate.invalidate() |
1653 raise |
1634 raise |
1654 |
1635 |
1655 try: |
1636 try: |
1817 pp = repo.dirstate.parents() |
1798 pp = repo.dirstate.parents() |
1818 if rev in pp: |
1799 if rev in pp: |
1819 update = True |
1800 update = True |
1820 else: |
1801 else: |
1821 update = False |
1802 update = False |
1822 self.strip(repo, [rev], update=update, backup='strip') |
1803 strip(self.ui, repo, [rev], update=update, backup='strip') |
1823 if qpp: |
1804 if qpp: |
1824 self.ui.warn(_("saved queue repository parents: %s %s\n") % |
1805 self.ui.warn(_("saved queue repository parents: %s %s\n") % |
1825 (short(qpp[0]), short(qpp[1]))) |
1806 (short(qpp[0]), short(qpp[1]))) |
1826 if qupdate: |
1807 if qupdate: |
1827 self.ui.status(_("updating queue directory\n")) |
1808 self.ui.status(_("updating queue directory\n")) |
2298 if dr.local(): |
2279 if dr.local(): |
2299 repo = dr.local() |
2280 repo = dr.local() |
2300 if qbase: |
2281 if qbase: |
2301 ui.note(_('stripping applied patches from destination ' |
2282 ui.note(_('stripping applied patches from destination ' |
2302 'repository\n')) |
2283 'repository\n')) |
2303 repo.mq.strip(repo, [qbase], update=False, backup=None) |
2284 strip(ui, repo, [qbase], update=False, backup=None) |
2304 if not opts.get('noupdate'): |
2285 if not opts.get('noupdate'): |
2305 ui.note(_('updating destination repository\n')) |
2286 ui.note(_('updating destination repository\n')) |
2306 hg.update(repo, repo.changelog.tip()) |
2287 hg.update(repo, repo.changelog.tip()) |
2307 |
2288 |
2308 @command("qcommit|qci", |
2289 @command("qcommit|qci", |
2942 if checksubstate(repo): |
2923 if checksubstate(repo): |
2943 _("local changed subrepos found") # i18n tool detection |
2924 _("local changed subrepos found") # i18n tool detection |
2944 raise util.Abort(_("local changed subrepos found" + excsuffix)) |
2925 raise util.Abort(_("local changed subrepos found" + excsuffix)) |
2945 return m, a, r, d |
2926 return m, a, r, d |
2946 |
2927 |
|
2928 def strip(ui, repo, revs, update=True, backup="all", force=None): |
|
2929 wlock = lock = None |
|
2930 try: |
|
2931 wlock = repo.wlock() |
|
2932 lock = repo.lock() |
|
2933 |
|
2934 if update: |
|
2935 checklocalchanges(repo, force=force) |
|
2936 urev, p2 = repo.changelog.parents(revs[0]) |
|
2937 if p2 != nullid and p2 in [x.node for x in repo.mq.applied]: |
|
2938 urev = p2 |
|
2939 hg.clean(repo, urev) |
|
2940 repo.dirstate.write() |
|
2941 |
|
2942 repair.strip(ui, repo, revs, backup) |
|
2943 finally: |
|
2944 release(lock, wlock) |
|
2945 |
2947 |
2946 |
2948 @command("strip", |
2947 @command("strip", |
2949 [ |
2948 [ |
2950 ('r', 'rev', [], _('strip specified revision (optional, ' |
2949 ('r', 'rev', [], _('strip specified revision (optional, ' |
2951 'can specify revisions without this ' |
2950 'can specify revisions without this ' |
2960 ('n', '', None, _('ignored (DEPRECATED)')), |
2959 ('n', '', None, _('ignored (DEPRECATED)')), |
2961 ('k', 'keep', None, _("do not modify working copy during strip")), |
2960 ('k', 'keep', None, _("do not modify working copy during strip")), |
2962 ('B', 'bookmark', '', _("remove revs only reachable from given" |
2961 ('B', 'bookmark', '', _("remove revs only reachable from given" |
2963 " bookmark"))], |
2962 " bookmark"))], |
2964 _('hg strip [-k] [-f] [-n] [-B bookmark] [-r] REV...')) |
2963 _('hg strip [-k] [-f] [-n] [-B bookmark] [-r] REV...')) |
2965 def strip(ui, repo, *revs, **opts): |
2964 def stripcmd(ui, repo, *revs, **opts): |
2966 """strip changesets and all their descendants from the repository |
2965 """strip changesets and all their descendants from the repository |
2967 |
2966 |
2968 The strip command removes the specified changesets and all their |
2967 The strip command removes the specified changesets and all their |
2969 descendants. If the working directory has uncommitted changes, the |
2968 descendants. If the working directory has uncommitted changes, the |
2970 operation is aborted unless the --force flag is supplied, in which |
2969 operation is aborted unless the --force flag is supplied, in which |
3093 bookmarks.setcurrent(repo, None) |
3092 bookmarks.setcurrent(repo, None) |
3094 del marks[mark] |
3093 del marks[mark] |
3095 marks.write() |
3094 marks.write() |
3096 ui.write(_("bookmark '%s' deleted\n") % mark) |
3095 ui.write(_("bookmark '%s' deleted\n") % mark) |
3097 |
3096 |
3098 repo.mq.strip(repo, revs, backup=backup, update=update, |
3097 strip(ui, repo, revs, backup=backup, update=update, force=opts.get('force')) |
3099 force=opts.get('force')) |
|
3100 |
3098 |
3101 return 0 |
3099 return 0 |
3102 |
3100 |
3103 @command("qselect", |
3101 @command("qselect", |
3104 [('n', 'none', None, _('disable all guards')), |
3102 [('n', 'none', None, _('disable all guards')), |