##// END OF EJS Templates
strip: move the strip helper function for mq to strip...
Pierre-Yves David -
r19825:4b499706 default
parent child Browse files
Show More
@@ -63,7 +63,7 b' from mercurial.i18n import _'
63 from mercurial.node import bin, hex, short, nullid, nullrev
63 from mercurial.node import bin, hex, short, nullid, nullrev
64 from mercurial.lock import release
64 from mercurial.lock import release
65 from mercurial import commands, cmdutil, hg, scmutil, util, revset
65 from mercurial import commands, cmdutil, hg, scmutil, util, revset
66 from mercurial import repair, extensions, error, phases, bookmarks
66 from mercurial import extensions, error, phases, bookmarks
67 from mercurial import patch as patchmod
67 from mercurial import patch as patchmod
68 from mercurial import localrepo
68 from mercurial import localrepo
69 from mercurial import subrepo
69 from mercurial import subrepo
@@ -88,6 +88,7 b' except KeyError:'
88 pass
88 pass
89 stripext = extensions.load(dummyui(), 'strip', '')
89 stripext = extensions.load(dummyui(), 'strip', '')
90
90
91 strip = stripext.strip
91 checksubstate = stripext.checksubstate
92 checksubstate = stripext.checksubstate
92 checklocalchanges = stripext.checklocalchanges
93 checklocalchanges = stripext.checklocalchanges
93
94
@@ -2911,25 +2912,6 b' def save(ui, repo, **opts):'
2911 q.savedirty()
2912 q.savedirty()
2912 return 0
2913 return 0
2913
2914
2914 def strip(ui, repo, revs, update=True, backup="all", force=None):
2915 wlock = lock = None
2916 try:
2917 wlock = repo.wlock()
2918 lock = repo.lock()
2919
2920 if update:
2921 checklocalchanges(repo, force=force)
2922 urev, p2 = repo.changelog.parents(revs[0])
2923 if p2 != nullid and p2 in [x.node for x in repo.mq.applied]:
2924 urev = p2
2925 hg.clean(repo, urev)
2926 repo.dirstate.write()
2927
2928 repair.strip(ui, repo, revs, backup)
2929 finally:
2930 release(lock, wlock)
2931
2932
2933 @command("strip",
2915 @command("strip",
2934 [
2916 [
2935 ('r', 'rev', [], _('strip specified revision (optional, '
2917 ('r', 'rev', [], _('strip specified revision (optional, '
@@ -1,5 +1,8 b''
1 from mercurial.i18n import _
1 from mercurial.i18n import _
2 from mercurial import cmdutil, util
2 from mercurial import cmdutil, hg, util
3 from mercurial.node import nullid
4 from mercurial.lock import release
5 from mercurial import repair
3
6
4 cmdtable = {}
7 cmdtable = {}
5 command = cmdutil.command(cmdtable)
8 command = cmdutil.command(cmdtable)
@@ -34,3 +37,21 b' def checklocalchanges(repo, force=False,'
34 raise util.Abort(_("local changed subrepos found" + excsuffix))
37 raise util.Abort(_("local changed subrepos found" + excsuffix))
35 return m, a, r, d
38 return m, a, r, d
36
39
40 def strip(ui, repo, revs, update=True, backup="all", force=None):
41 wlock = lock = None
42 try:
43 wlock = repo.wlock()
44 lock = repo.lock()
45
46 if update:
47 checklocalchanges(repo, force=force)
48 urev, p2 = repo.changelog.parents(revs[0])
49 if p2 != nullid and p2 in [x.node for x in repo.mq.applied]:
50 urev = p2
51 hg.clean(repo, urev)
52 repo.dirstate.write()
53
54 repair.strip(ui, repo, revs, backup)
55 finally:
56 release(lock, wlock)
57
General Comments 0
You need to be logged in to leave comments. Login now