[PATCH 4 of 6 standalone-strip-long-version] strip: move the strip helper function for mq to strip
pierre-yves.david at ens-lyon.org
pierre-yves.david at ens-lyon.org
Thu Sep 26 21:57:49 UTC 2013
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1380231780 -7200
# Thu Sep 26 23:43:00 2013 +0200
# Node ID 52e9c06477ad06f33e8cd6b85757b3bc3759904c
# Parent a4f5d3d0086b7481ad2de9dc785f4455b4298265
strip: move the strip helper function for mq to strip
The next patch finally move the command. No joke! (hey, this is for issue3824)
diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -61,11 +61,11 @@ such as -f/--force or --exact are passed
from mercurial.i18n import _
from mercurial.node import bin, hex, short, nullid, nullrev
from mercurial.lock import release
from mercurial import commands, cmdutil, hg, scmutil, util, revset
-from mercurial import repair, extensions, error, phases, bookmarks
+from mercurial import extensions, error, phases, bookmarks
from mercurial import patch as patchmod
from mercurial import localrepo
from mercurial import subrepo
import os, re, errno, shutil
@@ -86,10 +86,11 @@ except KeyError:
class dummyui(object):
def debug(self, msg):
pass
stripext = extensions.load(dummyui(), 'strip', '')
+strip = stripext.strip
checksubstate = stripext.checksubstate
checklocalchanges = stripext.checklocalchanges
# Patch names looks like unix-file names.
@@ -2909,29 +2910,10 @@ def save(ui, repo, **opts):
del q.applied[:]
q.applieddirty = True
q.savedirty()
return 0
-def strip(ui, repo, revs, update=True, backup="all", force=None):
- wlock = lock = None
- try:
- wlock = repo.wlock()
- lock = repo.lock()
-
- if update:
- checklocalchanges(repo, force=force)
- urev, p2 = repo.changelog.parents(revs[0])
- if p2 != nullid and p2 in [x.node for x in repo.mq.applied]:
- urev = p2
- hg.clean(repo, urev)
- repo.dirstate.write()
-
- repair.strip(ui, repo, revs, backup)
- finally:
- release(lock, wlock)
-
-
@command("strip",
[
('r', 'rev', [], _('strip specified revision (optional, '
'can specify revisions without this '
'option)'), _('REV')),
diff --git a/hgext/strip.py b/hgext/strip.py
--- a/hgext/strip.py
+++ b/hgext/strip.py
@@ -1,7 +1,10 @@
from mercurial.i18n import _
-from mercurial import cmdutil, util
+from mercurial import cmdutil, hg, util
+from mercurial.node import nullid
+from mercurial.lock import release
+from mercurial import repair
cmdtable = {}
command = cmdutil.command(cmdtable)
testedwith = 'internal'
@@ -32,5 +35,23 @@ def checklocalchanges(repo, force=False,
if checksubstate(repo):
_("local changed subrepos found") # i18n tool detection
raise util.Abort(_("local changed subrepos found" + excsuffix))
return m, a, r, d
+def strip(ui, repo, revs, update=True, backup="all", force=None):
+ wlock = lock = None
+ try:
+ wlock = repo.wlock()
+ lock = repo.lock()
+
+ if update:
+ checklocalchanges(repo, force=force)
+ urev, p2 = repo.changelog.parents(revs[0])
+ if p2 != nullid and p2 in [x.node for x in repo.mq.applied]:
+ urev = p2
+ hg.clean(repo, urev)
+ repo.dirstate.write()
+
+ repair.strip(ui, repo, revs, backup)
+ finally:
+ release(lock, wlock)
+
More information about the Mercurial-devel
mailing list