56 if checksubstate(repo): |
56 if checksubstate(repo): |
57 _("local changed subrepos found") # i18n tool detection |
57 _("local changed subrepos found") # i18n tool detection |
58 raise error.Abort(_("local changed subrepos found" + excsuffix)) |
58 raise error.Abort(_("local changed subrepos found" + excsuffix)) |
59 return s |
59 return s |
60 |
60 |
|
61 def _findupdatetarget(repo, nodes): |
|
62 unode, p2 = repo.changelog.parents(nodes[0]) |
|
63 |
|
64 if (util.safehasattr(repo, 'mq') and p2 != nullid |
|
65 and p2 in [x.node for x in repo.mq.applied]): |
|
66 unode = p2 |
|
67 |
|
68 return unode |
|
69 |
61 def strip(ui, repo, revs, update=True, backup=True, force=None, bookmarks=None): |
70 def strip(ui, repo, revs, update=True, backup=True, force=None, bookmarks=None): |
62 with repo.wlock(), repo.lock(): |
71 with repo.wlock(), repo.lock(): |
63 |
72 |
64 if update: |
73 if update: |
65 checklocalchanges(repo, force=force) |
74 checklocalchanges(repo, force=force) |
66 urev, p2 = repo.changelog.parents(revs[0]) |
75 urev = _findupdatetarget(repo, revs) |
67 if (util.safehasattr(repo, 'mq') and |
|
68 p2 != nullid |
|
69 and p2 in [x.node for x in repo.mq.applied]): |
|
70 urev = p2 |
|
71 hg.clean(repo, urev) |
76 hg.clean(repo, urev) |
72 repo.dirstate.write(repo.currenttransaction()) |
77 repo.dirstate.write(repo.currenttransaction()) |
73 |
78 |
74 repair.strip(ui, repo, revs, backup) |
79 repair.strip(ui, repo, revs, backup) |
75 |
80 |
194 del q.applied[start:end] |
199 del q.applied[start:end] |
195 q.savedirty() |
200 q.savedirty() |
196 |
201 |
197 revs = sorted(rootnodes) |
202 revs = sorted(rootnodes) |
198 if update and opts.get('keep'): |
203 if update and opts.get('keep'): |
199 urev, p2 = repo.changelog.parents(revs[0]) |
204 urev = _findupdatetarget(repo, revs) |
200 if (util.safehasattr(repo, 'mq') and p2 != nullid |
|
201 and p2 in [x.node for x in repo.mq.applied]): |
|
202 urev = p2 |
|
203 uctx = repo[urev] |
205 uctx = repo[urev] |
204 |
206 |
205 # only reset the dirstate for files that would actually change |
207 # only reset the dirstate for files that would actually change |
206 # between the working context and uctx |
208 # between the working context and uctx |
207 descendantrevs = repo.revs("%s::." % uctx.rev()) |
209 descendantrevs = repo.revs("%s::." % uctx.rev()) |