Mercurial > hg
view tests/test-narrow.t @ 37210:2a2ce93e12f4
templatefuncs: add mailmap template function
This commit adds a template function to support the .mailmap file
in Mercurial repositories. The .mailmap file comes from git, and
can be used to map new emails and names for old commits. The general
use case is that someone may change their name or author commits
under different emails and aliases, which would make these
commits appear as though they came from different persons. The
file allows you to specify the correct name that should be used
in place of the author field specified in the commit.
The mailmap file has 4 possible formats used to map old "commit"
names to new "proper" names:
1. <proper@email.com> <commit@email.com>
2. Proper Name <commit@email.com>
3. Proper Name <proper@email.com> <commit@email.com>
4. Proper Name <proper@email.com> Commit Name <commit@email.com>
Essentially there is a commit email present in each mailmap entry,
that maps to either an updated name, email, or both. The final
possible format allows commits authored by a person who used
both an old name and an old email to map to a new name and email.
To parse the file, we split by spaces and build a name out
of every element that does not start with "<". Once we find an element
that does start with "<" we concatenate all the name elements that preceded
and add that as a parsed name. We then add the email as the first
parsed email. We repeat the process until the end of the line, or
a comment is found. We will be left with all parsed names in a list,
and all parsed emails in a list, with the 0 index being the proper
values and the 1 index being the commit values (if they were specified
in the entry).
The commit values are added as the keys to a dict, and with the proper
fields as the values. The mapname function takes the mapping object and
the commit author field and attempts to look for a corresponding entry.
To do so we try (commit name, commit email) first, and if no results are
returned then (None, commit email) is also looked up. This is due to
format 4 from above, where someone may have a mailmap entry with both
name and email, and if they don't it is possible they have an entry that
uses only the commit email.
Differential Revision: https://phab.mercurial-scm.org/D2904
author | Connor Sheehan <sheehan@mozilla.com> |
---|---|
date | Mon, 19 Mar 2018 11:16:21 -0400 |
parents | 068f520754ca |
children | e82a59bfc5e8 |
line wrap: on
line source
#testcases flat tree $ . "$TESTDIR/narrow-library.sh" #if tree $ cat << EOF >> $HGRCPATH > [experimental] > treemanifest = 1 > EOF #endif $ hg init master $ cd master $ cat >> .hg/hgrc <<EOF > [narrow] > serveellipses=True > EOF $ for x in `$TESTDIR/seq.py 0 10` > do > mkdir d$x > echo $x > d$x/f > hg add d$x/f > hg commit -m "add d$x/f" > done $ hg log -T "{node|short}: {desc}\n" *: add d10/f (glob) *: add d9/f (glob) *: add d8/f (glob) *: add d7/f (glob) *: add d6/f (glob) *: add d5/f (glob) *: add d4/f (glob) *: add d3/f (glob) *: add d2/f (glob) *: add d1/f (glob) *: add d0/f (glob) $ cd .. Error if '.' or '..' are in the directory to track. $ hg clone --narrow ssh://user@dummy/master foo --include ./asdf requesting all changes abort: "." and ".." are not allowed in narrowspec paths [255] $ hg clone --narrow ssh://user@dummy/master foo --include asdf/.. requesting all changes abort: "." and ".." are not allowed in narrowspec paths [255] $ hg clone --narrow ssh://user@dummy/master foo --include a/./c requesting all changes abort: "." and ".." are not allowed in narrowspec paths [255] Names with '.' in them are OK. $ hg clone --narrow ssh://user@dummy/master should-work --include a/.b/c requesting all changes adding changesets adding manifests adding file changes added 1 changesets with 0 changes to 0 files new changesets * (glob) updating to branch default 0 files updated, 0 files merged, 0 files removed, 0 files unresolved Test repo with local changes $ hg clone --narrow ssh://user@dummy/master narrow-local-changes --include d0 --include d3 --include d6 requesting all changes adding changesets adding manifests adding file changes added 6 changesets with 3 changes to 3 files new changesets *:* (glob) updating to branch default 3 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd narrow-local-changes $ cat >> $HGRCPATH << EOF > [experimental] > evolution=createmarkers > EOF $ echo local change >> d0/f $ hg ci -m 'local change to d0' $ hg co '.^' 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ echo local change >> d3/f $ hg ci -m 'local hidden change to d3' created new head $ hg ci --amend -m 'local change to d3' $ hg tracked --removeinclude d0 comparing with ssh://user@dummy/master searching for changes looking for local changes to affected paths The following changeset(s) or their ancestors have local changes not on the remote: * (glob) abort: local changes found (use --force-delete-local-changes to ignore) [255] Check that nothing was removed by the failed attempts $ hg tracked I path:d0 I path:d3 I path:d6 $ hg files d0/f d3/f d6/f $ find * d0 d0/f d3 d3/f d6 d6/f $ hg verify -q Force deletion of local changes $ hg log -T "{node|short}: {desc} {outsidenarrow}\n" *: local change to d3 (glob) *: local change to d0 (glob) *: add d10/f outsidenarrow (glob) *: add d6/f (glob) *: add d5/f outsidenarrow (glob) *: add d3/f (glob) *: add d2/f outsidenarrow (glob) *: add d0/f (glob) $ hg tracked --removeinclude d0 --force-delete-local-changes comparing with ssh://user@dummy/master searching for changes looking for local changes to affected paths The following changeset(s) or their ancestors have local changes not on the remote: * (glob) saved backup bundle to $TESTTMP/narrow-local-changes/.hg/strip-backup/*-narrow.hg (glob) deleting data/d0/f.i deleting meta/d0/00manifest.i (tree !) $ hg log -T "{node|short}: {desc} {outsidenarrow}\n" *: local change to d3 (glob) *: add d10/f outsidenarrow (glob) *: add d6/f (glob) *: add d5/f outsidenarrow (glob) *: add d3/f (glob) *: add d2/f outsidenarrow (glob) *: add d0/f outsidenarrow (glob) Can restore stripped local changes after widening $ hg tracked --addinclude d0 -q $ hg unbundle .hg/strip-backup/*-narrow.hg -q $ hg --hidden co -r 'desc("local change to d0")' -q $ cat d0/f 0 local change Pruned commits affecting removed paths should not prevent narrowing $ hg co '.^' 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg debugobsolete `hg log -T '{node}' -r 'desc("local change to d0")'` obsoleted 1 changesets $ hg tracked --removeinclude d0 comparing with ssh://user@dummy/master searching for changes looking for local changes to affected paths saved backup bundle to $TESTTMP/narrow-local-changes/.hg/strip-backup/*-narrow.hg (glob) deleting data/d0/f.i deleting meta/d0/00manifest.i (tree !) Updates off of stripped commit if necessary $ hg co -r 'desc("local change to d3")' -q $ echo local change >> d6/f $ hg ci -m 'local change to d6' $ hg tracked --removeinclude d3 --force-delete-local-changes comparing with ssh://user@dummy/master searching for changes looking for local changes to affected paths The following changeset(s) or their ancestors have local changes not on the remote: * (glob) * (glob) 2 files updated, 0 files merged, 0 files removed, 0 files unresolved saved backup bundle to $TESTTMP/narrow-local-changes/.hg/strip-backup/*-narrow.hg (glob) deleting data/d3/f.i deleting meta/d3/00manifest.i (tree !) $ hg log -T '{desc}\n' -r . add d10/f Updates to nullid if necessary $ hg tracked --addinclude d3 -q $ hg co null -q $ mkdir d3 $ echo local change > d3/f $ hg add d3/f $ hg ci -m 'local change to d3' created new head $ hg tracked --removeinclude d3 --force-delete-local-changes comparing with ssh://user@dummy/master searching for changes looking for local changes to affected paths The following changeset(s) or their ancestors have local changes not on the remote: * (glob) 0 files updated, 0 files merged, 1 files removed, 0 files unresolved saved backup bundle to $TESTTMP/narrow-local-changes/.hg/strip-backup/*-narrow.hg (glob) deleting data/d3/f.i deleting meta/d3/00manifest.i (tree !) $ hg id 000000000000 $ cd .. Can remove last include, making repo empty $ hg clone --narrow ssh://user@dummy/master narrow-empty --include d0 -r 5 adding changesets adding manifests adding file changes added 2 changesets with 1 changes to 1 files new changesets *:* (glob) updating to branch default 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd narrow-empty $ hg tracked --removeinclude d0 comparing with ssh://user@dummy/master searching for changes looking for local changes to affected paths deleting data/d0/f.i deleting meta/d0/00manifest.i (tree !) $ hg tracked $ hg files [1] $ test -d d0 [1] Do some work in the empty clone $ hg diff --change . $ hg branch foo marked working directory as branch foo (branches are permanent and global, did you want a bookmark?) $ hg ci -m empty $ hg pull -q Can widen the empty clone $ hg tracked --addinclude d0 comparing with ssh://user@dummy/master searching for changes no changes found saved backup bundle to $TESTTMP/narrow-empty/.hg/strip-backup/*-widen.hg (glob) adding changesets adding manifests adding file changes added 3 changesets with 1 changes to 1 files new changesets *:* (glob) $ hg tracked I path:d0 $ hg files d0/f $ find * d0 d0/f $ cd .. TODO(martinvonz): test including e.g. d3/g and then removing it once https://bitbucket.org/Google/narrowhg/issues/6 is fixed $ hg clone --narrow ssh://user@dummy/master narrow --include d0 --include d3 --include d6 --include d9 requesting all changes adding changesets adding manifests adding file changes added 8 changesets with 4 changes to 4 files new changesets *:* (glob) updating to branch default 4 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd narrow $ hg tracked I path:d0 I path:d3 I path:d6 I path:d9 $ hg tracked --removeinclude d6 comparing with ssh://user@dummy/master searching for changes looking for local changes to affected paths deleting data/d6/f.i deleting meta/d6/00manifest.i (tree !) $ hg tracked I path:d0 I path:d3 I path:d9 $ hg debugrebuildfncache fncache already up to date $ find * d0 d0/f d3 d3/f d9 d9/f $ hg verify -q $ hg tracked --addexclude d3/f comparing with ssh://user@dummy/master searching for changes looking for local changes to affected paths deleting data/d3/f.i $ hg tracked I path:d0 I path:d3 I path:d9 X path:d3/f $ hg debugrebuildfncache fncache already up to date $ find * d0 d0/f d9 d9/f $ hg verify -q $ hg tracked --addexclude d0 comparing with ssh://user@dummy/master searching for changes looking for local changes to affected paths deleting data/d0/f.i deleting meta/d0/00manifest.i (tree !) $ hg tracked I path:d3 I path:d9 X path:d0 X path:d3/f $ hg debugrebuildfncache fncache already up to date $ find * d9 d9/f Make a 15 of changes to d9 to test the path without --verbose (Note: using regexes instead of "* (glob)" because if the test fails, it produces more sensible diffs) $ hg tracked I path:d3 I path:d9 X path:d0 X path:d3/f $ for x in `$TESTDIR/seq.py 1 15` > do > echo local change >> d9/f > hg commit -m "change $x to d9/f" > done $ hg tracked --removeinclude d9 comparing with ssh://user@dummy/master searching for changes looking for local changes to affected paths The following changeset(s) or their ancestors have local changes not on the remote: ^[0-9a-f]{12}$ (re) ^[0-9a-f]{12}$ (re) ^[0-9a-f]{12}$ (re) ^[0-9a-f]{12}$ (re) ^[0-9a-f]{12}$ (re) ^[0-9a-f]{12}$ (re) ^[0-9a-f]{12}$ (re) ^[0-9a-f]{12}$ (re) ^[0-9a-f]{12}$ (re) ^[0-9a-f]{12}$ (re) ...and 5 more, use --verbose to list all abort: local changes found (use --force-delete-local-changes to ignore) [255] Now test it *with* verbose. $ hg tracked --removeinclude d9 --verbose comparing with ssh://user@dummy/master searching for changes looking for local changes to affected paths The following changeset(s) or their ancestors have local changes not on the remote: ^[0-9a-f]{12}$ (re) ^[0-9a-f]{12}$ (re) ^[0-9a-f]{12}$ (re) ^[0-9a-f]{12}$ (re) ^[0-9a-f]{12}$ (re) ^[0-9a-f]{12}$ (re) ^[0-9a-f]{12}$ (re) ^[0-9a-f]{12}$ (re) ^[0-9a-f]{12}$ (re) ^[0-9a-f]{12}$ (re) ^[0-9a-f]{12}$ (re) ^[0-9a-f]{12}$ (re) ^[0-9a-f]{12}$ (re) ^[0-9a-f]{12}$ (re) ^[0-9a-f]{12}$ (re) abort: local changes found (use --force-delete-local-changes to ignore) [255]