[PATCH] Use KDiff3's labeling capability
Alexis S. L. Carvalho
alexis at cecm.usp.br
Sat Feb 17 08:28:33 UTC 2007
Thus spake tailgunner at smtp.ru:
> KDiff3 is able to label files being merged - we label them
> with names of the branches they come from.
>
> diff -r 0f35560bc179 -r b36c8f543f08 hgmerge
> --- a/hgmerge Wed Feb 14 01:05:09 2007 +0300
> +++ b/hgmerge Wed Feb 14 01:05:09 2007 +0300
> @@ -81,6 +81,15 @@ failure() {
> mv "$BACKUP" "$LOCAL"
> cleanup
> exit 1
> +}
> +
> +file_label() {
> + brname=$(hg log -r $1 | grep ^branch: | awk '{print $2}')
> + if [ -n "$brname" ]; then
> + echo "[$2 branch: $brname] $HG_FILE"
> + else
> + echo "[$2] $HG_FILE"
> + fi
> }
>
> # Ask if the merge was successful
> @@ -116,6 +125,11 @@ if [ -n "$MERGE" -o -n "$DIFF3" ]; then
> fi
> fi
>
> +# some merge tools (kdiff3) allow us to label the files being merged
> +OTHER_LABEL=$(file_label $HG_OTHER_NODE other)
> +MY_LABEL=$(file_label $HG_MY_NODE my)
> +BASE_LABEL="[base revision]"
I'm slightly worried about the cost of 2 hg log -r <x> here - for the
kernel repo, a single hg log -r <x> takes about 1s for me (mostly
because of the cost of calculating tags). At this point in hgmerge,
you'll probably have to resolve the conflicts interactively, so this may
not be prohibitively expensive, but it's still a lot of time.
The correct thing to do is obviously to speed up calculation of tags,
but while that's not done, I can see two ways to speed this up:
- pass the branch names in $HG_MY_BRANCH and $HG_OTHER_BRANCH variables
(maybe caching the parents of a workingctx)
- pass either the full hash nodes or the revision numbers to the merge
script and fix the changeset templater code so that a
hg log -r <rev> --template '{branch}\n' works (well, maybe there's
some template to print just the branch and I just don't know about
it...). Using either the full hash or the revision number should
allow us to find the revision without loading the tags.
Alexis
More information about the Mercurial-devel
mailing list