61 |
61 |
62 from mercurial.i18n import _ |
62 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 |
70 import os, re, errno, shutil |
70 import os, re, errno, shutil |
71 |
71 |
86 class dummyui(object): |
86 class dummyui(object): |
87 def debug(self, msg): |
87 def debug(self, msg): |
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 |
94 |
95 |
95 # Patch names looks like unix-file names. |
96 # Patch names looks like unix-file names. |
2909 del q.applied[:] |
2910 del q.applied[:] |
2910 q.applieddirty = True |
2911 q.applieddirty = True |
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, ' |
2936 'can specify revisions without this ' |
2918 'can specify revisions without this ' |
2937 'option)'), _('REV')), |
2919 'option)'), _('REV')), |