hgext/evolve.py
changeset 1020 155949287628
parent 1019 0c733dab0036
child 1021 200f2d9b9f39
equal deleted inserted replaced
1019:0c733dab0036 1020:155949287628
  1951     The --include option specifies patterns to uncommit.
  1951     The --include option specifies patterns to uncommit.
  1952     The --exclude option specifies patterns to keep in the commit.
  1952     The --exclude option specifies patterns to keep in the commit.
  1953 
  1953 
  1954     Return 0 if changed files are uncommitted.
  1954     Return 0 if changed files are uncommitted.
  1955     """
  1955     """
  1956     lock = repo.lock()
  1956 
       
  1957     wlock = lock = None
  1957     try:
  1958     try:
  1958         wlock = repo.wlock()
  1959         wlock = repo.wlock()
  1959         try:
  1960         lock = repo.lock()
  1960             wctx = repo[None]
  1961         wctx = repo[None]
  1961             if len(wctx.parents()) <= 0:
  1962         if len(wctx.parents()) <= 0:
  1962                 raise util.Abort(_("cannot uncommit null changeset"))
  1963             raise util.Abort(_("cannot uncommit null changeset"))
  1963             if len(wctx.parents()) > 1:
  1964         if len(wctx.parents()) > 1:
  1964                 raise util.Abort(_("cannot uncommit while merging"))
  1965             raise util.Abort(_("cannot uncommit while merging"))
  1965             old = repo['.']
  1966         old = repo['.']
  1966             if old.phase() == phases.public:
  1967         if old.phase() == phases.public:
  1967                 raise util.Abort(_("cannot rewrite immutable changeset"))
  1968             raise util.Abort(_("cannot rewrite immutable changeset"))
  1968             if len(old.parents()) > 1:
  1969         if len(old.parents()) > 1:
  1969                 raise util.Abort(_("cannot uncommit merge changeset"))
  1970             raise util.Abort(_("cannot uncommit merge changeset"))
  1970             oldphase = old.phase()
  1971         oldphase = old.phase()
  1971             updatebookmarks = _bookmarksupdater(repo, old.node())
  1972         updatebookmarks = _bookmarksupdater(repo, old.node())
  1972             # Recommit the filtered changeset
  1973         # Recommit the filtered changeset
  1973             newid = None
  1974         newid = None
  1974             if (pats or opts.get('include') or opts.get('exclude')
  1975         if (pats or opts.get('include') or opts.get('exclude')
  1975                 or opts.get('all')):
  1976             or opts.get('all')):
  1976                 match = scmutil.match(old, pats, opts)
  1977             match = scmutil.match(old, pats, opts)
  1977                 newid = _commitfiltered(repo, old, match)
  1978             newid = _commitfiltered(repo, old, match)
  1978             if newid is None:
  1979         if newid is None:
  1979                 raise util.Abort(_('nothing to uncommit'),
  1980             raise util.Abort(_('nothing to uncommit'),
  1980                                  hint=_("use --all to uncommit all files"))
  1981                              hint=_("use --all to uncommit all files"))
  1981             # Move local changes on filtered changeset
  1982         # Move local changes on filtered changeset
  1982             createmarkers(repo, [(old, (repo[newid],))])
  1983         createmarkers(repo, [(old, (repo[newid],))])
  1983             retractboundary(repo, oldphase, [newid])
  1984         retractboundary(repo, oldphase, [newid])
  1984             repo.dirstate.setparents(newid, node.nullid)
  1985         repo.dirstate.setparents(newid, node.nullid)
  1985             _uncommitdirstate(repo, old, match)
  1986         _uncommitdirstate(repo, old, match)
  1986             updatebookmarks(newid)
  1987         updatebookmarks(newid)
  1987             if not repo[newid].files():
  1988         if not repo[newid].files():
  1988                 ui.warn(_("new changeset is empty\n"))
  1989             ui.warn(_("new changeset is empty\n"))
  1989                 ui.status(_('(use "hg prune ." to remove it)\n'))
  1990             ui.status(_('(use "hg prune ." to remove it)\n'))
  1990         finally:
       
  1991             wlock.release()
       
  1992     finally:
  1991     finally:
  1993         lock.release()
  1992         lockmod.release(lock, wlock)
  1994 
  1993 
  1995 @eh.wrapcommand('commit')
  1994 @eh.wrapcommand('commit')
  1996 def commitwrapper(orig, ui, repo, *arg, **kwargs):
  1995 def commitwrapper(orig, ui, repo, *arg, **kwargs):
  1997     if kwargs.get('amend', False):
  1996     if kwargs.get('amend', False):
  1998         lock = None
  1997         lock = None