| 1 |
<?xml version="1.0" encoding="utf-8"?> |
| 2 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 3 |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| 4 |
<head> |
| 5 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 6 |
<meta name="generator" content="Docutils 0.21.2: https://docutils.sourceforge.io/" /> |
| 7 |
<title>Working with Phases</title> |
| 8 |
<link rel="stylesheet" href="../style.css" type="text/css" /> |
| 9 |
</head> |
| 10 |
<body> |
| 11 |
<div class="document" id="working-with-phases"> |
| 12 |
<span id="topic-phases"></span> |
| 13 |
<h1 class="title">Working with Phases</h1> |
| 14 |
|
| 15 |
<div class="contents htmlonly topic" id="contents"> |
| 16 |
<p class="topic-title"><a class="reference internal" href="#top">Contents</a></p> |
| 17 |
<ul class="simple"> |
| 18 |
<li><a class="reference internal" href="#what-are-phases" id="toc-entry-1">What are phases?</a></li> |
| 19 |
<li><a class="reference internal" href="#how-are-phases-managed" id="toc-entry-2">How are phases managed?</a></li> |
| 20 |
<li><a class="reference internal" href="#phases-and-servers" id="toc-entry-3">Phases and servers</a></li> |
| 21 |
<li><a class="reference internal" href="#examples" id="toc-entry-4">Examples</a></li> |
| 22 |
</ul> |
| 23 |
</div> |
| 24 |
<div class="section" id="what-are-phases"> |
| 25 |
<span id="phases"></span><h1><a class="toc-backref" href="#contents">What are phases?</a></h1> |
| 26 |
<p>Phases are a system for tracking which changesets have been or should |
| 27 |
be shared. This helps prevent common mistakes when modifying history |
| 28 |
(for instance, with the mq or rebase extensions).</p> |
| 29 |
<p>Each changeset in a repository is in one of the following phases:</p> |
| 30 |
<blockquote> |
| 31 |
<ul class="simple"> |
| 32 |
<li>public : changeset is visible on a public server</li> |
| 33 |
<li>draft : changeset is not yet published</li> |
| 34 |
<li>secret : changeset should not be pushed, pulled, or cloned</li> |
| 35 |
</ul> |
| 36 |
</blockquote> |
| 37 |
<p>These phases are ordered (public < draft < secret) and no changeset |
| 38 |
can be in a lower phase than its ancestors. For instance, if a |
| 39 |
changeset is public, all its ancestors are also public. Lastly, |
| 40 |
changeset phases should only be changed towards the public phase.</p> |
| 41 |
</div> |
| 42 |
<div class="section" id="how-are-phases-managed"> |
| 43 |
<h1><a class="toc-backref" href="#contents">How are phases managed?</a></h1> |
| 44 |
<p>For the most part, phases should work transparently. By default, a |
| 45 |
changeset is created in the draft phase and is moved into the public |
| 46 |
phase when it is pushed to another repository.</p> |
| 47 |
<p>Once changesets become public, extensions like mq and rebase will |
| 48 |
refuse to operate on them to prevent creating duplicate changesets. |
| 49 |
Phases can also be manually manipulated with the <a class="reference external" href="hg-phase.html"><tt class="docutils literal">hg phase</tt></a> command |
| 50 |
if needed. See <a class="reference external" href="hg.1.html#-v"><tt class="docutils literal">hg help <span class="pre">-v</span> phase</tt></a> for examples.</p> |
| 51 |
<p>To make your commits secret by default, put this in your |
| 52 |
configuration file:</p> |
| 53 |
<pre class="literal-block"> |
| 54 |
[phases] |
| 55 |
new-commit = secret |
| 56 |
</pre> |
| 57 |
</div> |
| 58 |
<div class="section" id="phases-and-servers"> |
| 59 |
<h1><a class="toc-backref" href="#contents">Phases and servers</a></h1> |
| 60 |
<p>Normally, all servers are <tt class="docutils literal">publishing</tt> by default. This means:</p> |
| 61 |
<pre class="literal-block"> |
| 62 |
- all draft changesets that are pulled or cloned appear in phase |
| 63 |
public on the client |
| 64 |
|
| 65 |
- all draft changesets that are pushed appear as public on both |
| 66 |
client and server |
| 67 |
|
| 68 |
- secret changesets are neither pushed, pulled, or cloned |
| 69 |
</pre> |
| 70 |
<div class="admonition note"> |
| 71 |
<p class="first admonition-title">Note</p> |
| 72 |
<p class="last">Pulling a draft changeset from a publishing server does not mark it |
| 73 |
as public on the server side due to the read-only nature of pull.</p> |
| 74 |
</div> |
| 75 |
<p>Sometimes it may be desirable to push and pull changesets in the draft |
| 76 |
phase to share unfinished work. This can be done by setting a |
| 77 |
repository to disable publishing in its configuration file:</p> |
| 78 |
<pre class="literal-block"> |
| 79 |
[phases] |
| 80 |
publish = False |
| 81 |
</pre> |
| 82 |
<p>See <a class="reference external" href="hgrc.5.html"><tt class="docutils literal">hg help config</tt></a> for more information on configuration files.</p> |
| 83 |
<div class="admonition note"> |
| 84 |
<p class="first admonition-title">Note</p> |
| 85 |
<p class="last">Servers running older versions of Mercurial are treated as |
| 86 |
publishing.</p> |
| 87 |
</div> |
| 88 |
<div class="admonition note"> |
| 89 |
<p class="first admonition-title">Note</p> |
| 90 |
<p class="last">Changesets in secret phase are not exchanged with the server. This |
| 91 |
applies to their content: file names, file contents, and changeset |
| 92 |
metadata. For technical reasons, the identifier (e.g. d825e4025e39) |
| 93 |
of the secret changeset may be communicated to the server.</p> |
| 94 |
</div> |
| 95 |
</div> |
| 96 |
<div class="section" id="examples"> |
| 97 |
<h1><a class="toc-backref" href="#contents">Examples</a></h1> |
| 98 |
<blockquote> |
| 99 |
<ul> |
| 100 |
<li><p class="first">list changesets in draft or secret phase:</p> |
| 101 |
<pre class="literal-block"> |
| 102 |
hg log -r "not public()" |
| 103 |
</pre> |
| 104 |
</li> |
| 105 |
<li><p class="first">change all secret changesets to draft:</p> |
| 106 |
<pre class="literal-block"> |
| 107 |
hg phase --draft "secret()" |
| 108 |
</pre> |
| 109 |
</li> |
| 110 |
<li><p class="first">forcibly move the current changeset and descendants from public to draft:</p> |
| 111 |
<pre class="literal-block"> |
| 112 |
hg phase --force --draft . |
| 113 |
</pre> |
| 114 |
</li> |
| 115 |
<li><p class="first">show a list of changeset revisions and each corresponding phase:</p> |
| 116 |
<pre class="literal-block"> |
| 117 |
hg log --template "{rev} {phase}\n" |
| 118 |
</pre> |
| 119 |
</li> |
| 120 |
<li><p class="first">resynchronize draft changesets relative to a remote repository:</p> |
| 121 |
<pre class="literal-block"> |
| 122 |
hg phase -fd "outgoing(URL)" |
| 123 |
</pre> |
| 124 |
</li> |
| 125 |
</ul> |
| 126 |
</blockquote> |
| 127 |
<p>See <a class="reference external" href="hg-phase.html"><tt class="docutils literal">hg help phase</tt></a> for more information on manually manipulating phases.</p> |
| 128 |
</div> |
| 129 |
</div> |
| 130 |
</body> |
| 131 |
</html> |