# HG changeset patch # User Thomas Arendsen Hein # Date 1181149518 -7200 # Node ID e0bc2c575044f4840fdf59a042d3bde589fb4dc8 # Parent 9d1380e5c8c5e4356637ae8fcdbbafe0aa2bc10c 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. diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -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) diff --git a/tests/test-log b/tests/test-log --- a/tests/test-log +++ b/tests/test-log @@ -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' diff --git a/tests/test-log.out b/tests/test-log.out --- a/tests/test-log.out +++ b/tests/test-log.out @@ -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