[PATCH 2 of 2 phases] phases: add a phases command to display and manipulate phases
pierre-yves.david at logilab.fr
pierre-yves.david at logilab.fr
Tue Jan 10 12:46:46 CST 2012
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1326221135 -3600
# Node ID 7d7e43c1437fb024509fcdb5696635aea6763f34
# Parent 9b6069f654f15658f9bd6101a2675208fa77d41b
phases: add a phases command to display and manipulate phases
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -16,10 +16,11 @@ import sshserver, hgweb, hgweb.server, c
import match as matchmod
import merge as mergemod
import minirst, revset, fileset
import dagparser, context, simplemerge
import random, setdiscovery, treediscovery, dagutil
+import phases as phasesmod
table = {}
command = cmdutil.command(table)
@@ -4208,10 +4209,65 @@ def paths(ui, repo, search=None):
for name, path in ui.configitems("paths"):
if ui.quiet:
ui.write("%s\n" % name)
else:
ui.write("%s = %s\n" % (name, util.hidepassword(path)))
+ at command('^phase',
+ [('p', 'public', False, _('Set changeset to public')),
+ ('d', 'draft', False, _('Set changeset to draft')),
+ ('s', 'secret', False, _('Set changeset to secret')),
+ ('f', 'force', False, _('allow to move boundary backward')),
+ ('r', 'rev', [], _('target revision')),
+ ],
+ _('[-p|-d|-s] [-f] [-C] [-r] REV'))
+def phase(ui, repo, *revs, **opts):
+ """set or show the current phase name
+
+ See :hg:`help phases` for more information about phases if you are
+ not familliar with this concept.
+
+ With no argument, show the phase name of specified revisions.
+
+ With on one of `--public`, `--draft` or `--secret`, change the phase value.
+
+ Unless -f/--force is specified, :hg:`phase` won't move changeset from a
+ lower phase to an higher phase. Phase are ordered as follow:
+
+ public < draft < secret.
+ """
+ # search for a unique phase argument
+ targetphase = None
+ for idx, name in enumerate(phasesmod.phasenames):
+ if opts[name]:
+ if targetphase is not None:
+ raise util.Abort('only one phase can be specified')
+ targetphase = idx
+
+ # look for specified revision
+ revs = list(revs)
+ revs.extend(opts['rev'])
+ if not revs:
+ raise NotImplementedError('working directory phase not implemented '
+ 'yet')
+ lock = None
+ if targetphase is None:
+ # display
+ for ctx in repo.set('%lr', revs):
+ ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr()))
+ else:
+ lock = repo.lock()
+ try:
+ # set phase
+ nodes = [ctx.node() for ctx in repo.set('%lr', revs)]
+ if not nodes:
+ raise util.Abort(_('empty revision set'))
+ phasesmod.advanceboundary(repo, targetphase, nodes)
+ if opts['force']:
+ phasesmod.retractboundary(repo, targetphase, nodes)
+ finally:
+ lock.release()
+
def postincoming(ui, repo, modheads, optupdate, checkout):
if modheads == 0:
return
if optupdate:
diff --git a/mercurial/help/phases.txt b/mercurial/help/phases.txt
--- a/mercurial/help/phases.txt
+++ b/mercurial/help/phases.txt
@@ -1,5 +1,7 @@
+(for :hg:`phase` command see :hg:`help phase`)
+
Basic Concept
=============
A 'changeset phases' is an indicator that tells us how a changeset is
manipulated and communicated. The details of each phase is described below,
diff --git a/tests/test-alias.t b/tests/test-alias.t
--- a/tests/test-alias.t
+++ b/tests/test-alias.t
@@ -332,10 +332,11 @@ invalid global arguments for normal comm
export dump the header and diffs for one or more changesets
forget forget the specified files on the next commit
init create a new repository in the given directory
log show revision history of entire repository or files
merge merge working directory with another revision
+ phase set or show the current phase name
pull pull changes from the specified source
push push changes to the specified destination
remove remove the specified files on the next commit
serve start stand-alone webserver
status show changed files in the working directory
@@ -358,10 +359,11 @@ invalid global arguments for normal comm
export dump the header and diffs for one or more changesets
forget forget the specified files on the next commit
init create a new repository in the given directory
log show revision history of entire repository or files
merge merge working directory with another revision
+ phase set or show the current phase name
pull pull changes from the specified source
push push changes to the specified destination
remove remove the specified files on the next commit
serve start stand-alone webserver
status show changed files in the working directory
@@ -384,10 +386,11 @@ invalid global arguments for normal comm
export dump the header and diffs for one or more changesets
forget forget the specified files on the next commit
init create a new repository in the given directory
log show revision history of entire repository or files
merge merge working directory with another revision
+ phase set or show the current phase name
pull pull changes from the specified source
push push changes to the specified destination
remove remove the specified files on the next commit
serve start stand-alone webserver
status show changed files in the working directory
diff --git a/tests/test-commandserver.py.out b/tests/test-commandserver.py.out
--- a/tests/test-commandserver.py.out
+++ b/tests/test-commandserver.py.out
@@ -24,10 +24,11 @@ basic commands:
export dump the header and diffs for one or more changesets
forget forget the specified files on the next commit
init create a new repository in the given directory
log show revision history of entire repository or files
merge merge working directory with another revision
+ phase set or show the current phase name
pull pull changes from the specified source
push push changes to the specified destination
remove remove the specified files on the next commit
serve start stand-alone webserver
status show changed files in the working directory
diff --git a/tests/test-debugcomplete.t b/tests/test-debugcomplete.t
--- a/tests/test-debugcomplete.t
+++ b/tests/test-debugcomplete.t
@@ -30,10 +30,11 @@ Show all commands except debug commands
manifest
merge
outgoing
parents
paths
+ phase
pull
push
recover
remove
rename
@@ -196,10 +197,11 @@ Show all commands + options
export: output, switch-parent, rev, text, git, nodates
forget: include, exclude
init: ssh, remotecmd, insecure
log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, branch, prune, hidden, patch, git, limit, no-merges, stat, style, template, include, exclude
merge: force, rev, preview, tool
+ phase: public, draft, secret, force, rev
pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
push: force, rev, bookmark, branch, new-branch, ssh, remotecmd, insecure
remove: after, force, include, exclude
serve: accesslog, daemon, daemon-pipefds, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate
status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, copies, print0, rev, change, include, exclude, subrepos
diff --git a/tests/test-globalopts.t b/tests/test-globalopts.t
--- a/tests/test-globalopts.t
+++ b/tests/test-globalopts.t
@@ -309,10 +309,11 @@ Testing -h/--help:
manifest output the current or given revision of the project manifest
merge merge working directory with another revision
outgoing show changesets not found in the destination
parents show the parents of the working directory or revision
paths show aliases for remote repositories
+ phase set or show the current phase name
pull pull changes from the specified source
push push changes to the specified destination
recover roll back an interrupted transaction
remove remove the specified files on the next commit
rename rename files; equivalent of copy + remove
@@ -391,10 +392,11 @@ Testing -h/--help:
manifest output the current or given revision of the project manifest
merge merge working directory with another revision
outgoing show changesets not found in the destination
parents show the parents of the working directory or revision
paths show aliases for remote repositories
+ phase set or show the current phase name
pull pull changes from the specified source
push push changes to the specified destination
recover roll back an interrupted transaction
remove remove the specified files on the next commit
rename rename files; equivalent of copy + remove
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -13,10 +13,11 @@ Short help:
export dump the header and diffs for one or more changesets
forget forget the specified files on the next commit
init create a new repository in the given directory
log show revision history of entire repository or files
merge merge working directory with another revision
+ phase set or show the current phase name
pull pull changes from the specified source
push push changes to the specified destination
remove remove the specified files on the next commit
serve start stand-alone webserver
status show changed files in the working directory
@@ -34,10 +35,11 @@ Short help:
export dump the header and diffs for one or more changesets
forget forget the specified files on the next commit
init create a new repository in the given directory
log show revision history of entire repository or files
merge merge working directory with another revision
+ phase set or show the current phase name
pull pull changes from the specified source
push push changes to the specified destination
remove remove the specified files on the next commit
serve start stand-alone webserver
status show changed files in the working directory
@@ -79,10 +81,11 @@ Short help:
manifest output the current or given revision of the project manifest
merge merge working directory with another revision
outgoing show changesets not found in the destination
parents show the parents of the working directory or revision
paths show aliases for remote repositories
+ phase set or show the current phase name
pull pull changes from the specified source
push push changes to the specified destination
recover roll back an interrupted transaction
remove remove the specified files on the next commit
rename rename files; equivalent of copy + remove
@@ -155,10 +158,11 @@ Short help:
manifest output the current or given revision of the project manifest
merge merge working directory with another revision
outgoing show changesets not found in the destination
parents show the parents of the working directory or revision
paths show aliases for remote repositories
+ phase set or show the current phase name
pull pull changes from the specified source
push push changes to the specified destination
recover roll back an interrupted transaction
remove remove the specified files on the next commit
rename rename files; equivalent of copy + remove
@@ -223,10 +227,12 @@ Test short command list with verbose opt
create a new repository in the given directory
log, history:
show revision history of entire repository or files
merge:
merge working directory with another revision
+ phase:
+ set or show the current phase name
pull:
pull changes from the specified source
push:
push changes to the specified destination
remove, rm:
@@ -539,10 +545,11 @@ Test command without options
export dump the header and diffs for one or more changesets
forget forget the specified files on the next commit
init create a new repository in the given directory
log show revision history of entire repository or files
merge merge working directory with another revision
+ phase set or show the current phase name
pull pull changes from the specified source
push push changes to the specified destination
remove remove the specified files on the next commit
serve start stand-alone webserver
status show changed files in the working directory
@@ -566,10 +573,11 @@ Test command without options
export dump the header and diffs for one or more changesets
forget forget the specified files on the next commit
init create a new repository in the given directory
log show revision history of entire repository or files
merge merge working directory with another revision
+ phase set or show the current phase name
pull pull changes from the specified source
push push changes to the specified destination
remove remove the specified files on the next commit
serve start stand-alone webserver
status show changed files in the working directory
@@ -641,10 +649,11 @@ Test that default list of commands omits
manifest output the current or given revision of the project manifest
merge merge working directory with another revision
outgoing show changesets not found in the destination
parents show the parents of the working directory or revision
paths show aliases for remote repositories
+ phase set or show the current phase name
pull pull changes from the specified source
push push changes to the specified destination
recover roll back an interrupted transaction
remove remove the specified files on the next commit
rename rename files; equivalent of copy + remove
diff --git a/tests/test-phases.t b/tests/test-phases.t
--- a/tests/test-phases.t
+++ b/tests/test-phases.t
@@ -24,11 +24,11 @@ Following commit are draft too
1 1 B
0 1 A
Draft commit are properly created over public one:
- $ hg pull -q . # XXX use the dedicated phase command once available
+ $ hg phase --public .
$ hglog
1 0 B
0 0 A
$ mkcommit C
@@ -152,5 +152,111 @@ Test revset
6 1 B'
$ hglog -r 'secret()'
4 2 E
5 2 H
7 2 merge B' and E
+
+Test phase command
+===================
+
+initial picture
+
+ $ cat >> $HGRCPATH << EOF
+ > [extensions]
+ > hgext.graphlog=
+ > EOF
+ $ hg log -G --template "{rev} {phase} {desc}\n"
+ @ 7 secret merge B' and E
+ |\
+ | o 6 draft B'
+ | |
+ +---o 5 secret H
+ | |
+ o | 4 secret E
+ | |
+ o | 3 draft D
+ | |
+ o | 2 draft C
+ |/
+ o 1 public B
+ |
+ o 0 public A
+
+
+display changesets phase
+
+(mixing -r and plain rev specification)
+
+ $ hg phase 1::4 -r 7
+ 1: public
+ 2: draft
+ 3: draft
+ 4: secret
+ 7: secret
+
+
+move changeset forward
+
+(with -r option)
+
+ $ hg phase --public -r 2
+ $ hg log -G --template "{rev} {phase} {desc}\n"
+ @ 7 secret merge B' and E
+ |\
+ | o 6 draft B'
+ | |
+ +---o 5 secret H
+ | |
+ o | 4 secret E
+ | |
+ o | 3 draft D
+ | |
+ o | 2 public C
+ |/
+ o 1 public B
+ |
+ o 0 public A
+
+
+move changeset backward
+
+(without -r option)
+
+ $ hg phase --draft --force 2
+ $ hg log -G --template "{rev} {phase} {desc}\n"
+ @ 7 secret merge B' and E
+ |\
+ | o 6 draft B'
+ | |
+ +---o 5 secret H
+ | |
+ o | 4 secret E
+ | |
+ o | 3 draft D
+ | |
+ o | 2 draft C
+ |/
+ o 1 public B
+ |
+ o 0 public A
+
+
+move changeset forward and backward
+
+ $ hg phase --draft --force 1::4
+ $ hg log -G --template "{rev} {phase} {desc}\n"
+ @ 7 secret merge B' and E
+ |\
+ | o 6 draft B'
+ | |
+ +---o 5 secret H
+ | |
+ o | 4 draft E
+ | |
+ o | 3 draft D
+ | |
+ o | 2 draft C
+ |/
+ o 1 draft B
+ |
+ o 0 public A
+
diff --git a/tests/test-strict.t b/tests/test-strict.t
--- a/tests/test-strict.t
+++ b/tests/test-strict.t
@@ -24,10 +24,11 @@
export dump the header and diffs for one or more changesets
forget forget the specified files on the next commit
init create a new repository in the given directory
log show revision history of entire repository or files
merge merge working directory with another revision
+ phase set or show the current phase name
pull pull changes from the specified source
push push changes to the specified destination
remove remove the specified files on the next commit
serve start stand-alone webserver
status show changed files in the working directory
More information about the Mercurial-devel
mailing list