Confirmed users
571
edits
(add mass cancellation script) |
(drop code for mfi command because Treeherder autosuggests Bugzilla product and component, add command prompt code for macOS / zsh) |
||
Line 14: | Line 14: | ||
Successful cancellations are indicated by `exception 'canceled'`. | Successful cancellations are indicated by `exception 'canceled'`. | ||
== Active tree in command line prompt == | == Active tree in command line prompt == | ||
Let the command line prompt which tree was active when the last command finished, how many patches are applied locally and if there are uncommitted changes (including files not tracked by version control). | Let the command line prompt which tree was active when the last command finished, how many patches are applied locally and if there are uncommitted changes (including files not tracked by version control). | ||
=== Linux (bash) === | |||
* In your home directory, open the file called <code>.bashrc</code>. | * In your home directory, open the file called <code>.bashrc</code>. | ||
* Find this line <pre>unset color_prompt force_color_prompt</pre> | * Find this line <pre>unset color_prompt force_color_prompt</pre> | ||
Line 116: | Line 73: | ||
* Save and close the file. | * Save and close the file. | ||
'''New''' console windows will show the active tree, the number of patches applied locally and untracked changes including files not tracked by version control (e.g. .rej files from a conflict). | '''New''' console windows will show the active tree, the number of patches applied locally and untracked changes including files not tracked by version control (e.g. .rej files from a conflict). | ||
Example: <pre>user@VirtualBox ~/mozilla/mozilla-unified beta(+2+changes) $</pre> | |||
The active repository is '''beta''', there are '''2 local commits''' and '''untracked changes''' (more information about those with '''hg status'''). | |||
If you pulled new changes from the server but didn't update the active repository to those, the script will try to find a different tree for which the working directory has all the changesets and e.g. show a big number of changesets for the tree due to that (e.g. <code>central(+67)</code>) or a question mark if it finds no tree fulfilling that condition (<code>(?)</code>). | |||
=== macOS (zsh) === | |||
* In your home directory, check if the file <code>.zshrc</code> exists (file manager must show hidden files starting with "."). | |||
* If it is missing, create a text file with that name. | |||
* Open the <code>.zshrc</code> file. | |||
* Append the following code to the file's content: | |||
<pre> | |||
setopt PROMPT_SUBST | |||
function hg_info() { | |||
declare tipRevision=`hg log -r . -T {node} 2> /dev/null` | |||
if [[ -z "$tipRevision" ]];then | |||
echo '' | |||
return | |||
fi | |||
declare fxheads=`hg fxheads -T '{label("log.changeset", node)} {label("log.tag", join(fxheads, "+"))}\n' 2> /dev/null` | |||
declare shortestDistance=-2 # Not found | |||
declare shortestDistanceTrees='' | |||
while read -r line; do | |||
IFS=', ' read -r -A array <<< "$line" | |||
declare headRevision=${array[1]} | |||
declare headTrees=${array[2]} | |||
declare distance=`hg log -r $headRevision::. --template x | wc -c` | |||
declare distance=$((distance-1)) | |||
if [[ "$distance" -gt -1 ]];then | |||
if [[ "$shortestDistance" -eq -2 ]];then | |||
declare shortestDistance=$distance | |||
declare shortestDistanceTrees=$headTrees | |||
elif [[ "$distance" -lt "$shortestDistance" ]];then | |||
declare shortestDistance=$distance | |||
declare shortestDistanceTrees=$headTrees | |||
fi | |||
fi | |||
done <<< "$fxheads" | |||
# echo "shortest distance for $shortestDistanceTrees with distance $shortestDistance" | |||
declare bash_string='' | |||
if [[ "$shortestDistanceTrees" == '' ]];then | |||
declare bash_string=' (?' | |||
else | |||
declare bash_string=' '$shortestDistanceTrees | |||
if [[ "$shortestDistance" -eq 0 ]];then | |||
declare bash_string=$bash_string'(0' | |||
else | |||
declare bash_string=$bash_string'(+'$shortestDistance'' | |||
fi | |||
fi | |||
declare uncommitChanges=`hg status` | |||
if [[ -z "$uncommitChanges" ]];then | |||
declare bash_string=$bash_string')' | |||
else | |||
declare bash_string=$bash_string'+changes)' | |||
fi | |||
echo "$bash_string" | |||
} | |||
export PROMPT='%n@%m %F{green}%~%F{yellow}$(hg_info)%F{white} %# ' | |||
</pre> | |||
* In the console terminal, run the following command to reload the behavior of command prompt: <code>source ~/.zshrc</code> | |||
The console should show the active tree, the number of patches applied locally and untracked changes including files not tracked by version control (e.g. .rej files from a conflict). | |||
Example: <pre>user@VirtualBox ~/mozilla/mozilla-unified beta(+2+changes) $</pre> | Example: <pre>user@VirtualBox ~/mozilla/mozilla-unified beta(+2+changes) $</pre> | ||
The active repository is '''beta''', there are '''2 local commits''' and '''untracked changes''' (more information about those with '''hg status'''). | The active repository is '''beta''', there are '''2 local commits''' and '''untracked changes''' (more information about those with '''hg status'''). | ||
If you pulled new changes from the server but didn't update the active repository to those, the script will try to find a different tree for which the working directory has all the changesets and e.g. show a big number of changesets for the tree due to that (e.g. <code>central(+67)</code>) or a question mark if it finds no tree fulfilling that condition (<code>(?)</code>). | If you pulled new changes from the server but didn't update the active repository to those, the script will try to find a different tree for which the working directory has all the changesets and e.g. show a big number of changesets for the tree due to that (e.g. <code>central(+67)</code>) or a question mark if it finds no tree fulfilling that condition (<code>(?)</code>). |