Issue a warning if "-r ." is used with two working directory parents.
authorThomas Arendsen Hein <thomas@intevation.de>
Wed, 06 Jun 2007 19:05:18 +0200
changeset 4510 e0bc2c575044
parent 4509 9d1380e5c8c5
child 4511 1d46169ec197
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.
mercurial/localrepo.py
tests/test-log
tests/test-log.out
--- a/mercurial/localrepo.py	Wed Jun 06 18:28:48 2007 +0200
+++ b/mercurial/localrepo.py	Wed Jun 06 19:05:18 2007 +0200
@@ -437,9 +437,12 @@
 
     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)
--- a/tests/test-log	Wed Jun 06 18:28:48 2007 +0200
+++ b/tests/test-log	Wed Jun 06 19:05:18 2007 +0200
@@ -47,6 +47,7 @@
 # log --follow tests
 hg init ../follow
 cd ../follow
+
 echo base > base
 hg ci -Ambase -d '1 0'
 
@@ -71,8 +72,15 @@
 
 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'
 
--- a/tests/test-log.out	Wed Jun 06 18:28:48 2007 +0200
+++ b/tests/test-log.out	Wed Jun 06 19:05:18 2007 +0200
@@ -144,6 +144,23 @@
 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