Issue a warning if "-r ." is used with two working directory parents.

Rationale for not aborting instead:
The first parent is usually more important as it is the local branch
during a merge and commands like 'hg diff' and 'hg diff -r.' behave still
identically (except for the warning of course).

Added a test for log -r. with one and two parents.
This commit is contained in:
Thomas Arendsen Hein 2007-06-06 19:05:18 +02:00
parent df8762ba4d
commit cf1ee4e625
3 changed files with 29 additions and 1 deletions

View File

@ -437,9 +437,12 @@ class localrepository(repo.repository):
def lookup(self, key):
if key == '.':
key = self.dirstate.parents()[0]
key, second = self.dirstate.parents()
if key == nullid:
raise repo.RepoError(_("no revision checked out"))
if second != nullid:
self.ui.warn(_("warning: working directory has two parents, "
"tag '.' uses the first\n"))
elif key == 'null':
return nullid
n = self.changelog._match(key)

View File

@ -47,6 +47,7 @@ hg log -pv d
# log --follow tests
hg init ../follow
cd ../follow
echo base > base
hg ci -Ambase -d '1 0'
@ -71,8 +72,15 @@ hg log -f -r 1:tip
hg up -C 3
hg merge tip
echo % log -r . with two parents
hg log -r .
hg ci -mm12 -d '1 0'
echo % log -r . with one parent
hg log -r .
echo postm >> b1
hg ci -Amb1.1 -d'1 0'

View File

@ -144,6 +144,23 @@ summary: b1
2 files updated, 0 files merged, 1 files removed, 0 files unresolved
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
% log -r . with two parents
warning: working directory has two parents, tag '.' uses the first
changeset: 3:e62f78d544b4
parent: 1:3d5bf5654eda
user: test
date: Thu Jan 01 00:00:01 1970 +0000
summary: b1
% log -r . with one parent
changeset: 5:302e9dd6890d
tag: tip
parent: 3:e62f78d544b4
parent: 4:ddb82e70d1a1
user: test
date: Thu Jan 01 00:00:01 1970 +0000
summary: m12
% log --follow-first
changeset: 6:2404bbcab562
tag: tip