mercurial/commands.py
changeset 2651 e57df017640d
parent 2646 ddf404954092
parent 2648 f47432ae5376
child 2662 2c5d5cf35034
--- a/mercurial/commands.py	Wed Jul 19 14:22:08 2006 -0500
+++ b/mercurial/commands.py	Sun Jul 23 14:00:29 2006 -0500
@@ -2666,7 +2666,7 @@
     very useful to compare different revision, to go back to significant
     earlier versions or to mark branch points as releases, etc.
 
-    If no revision is given, the tip is used.
+    If no revision is given, the parent of the working directory is used.
 
     To facilitate version control, distribution, and merging of tags,
     they are stored as a file named ".hgtags" which is managed
@@ -2686,7 +2686,12 @@
     if rev_:
         r = hex(repo.lookup(rev_))
     else:
-        r = hex(repo.changelog.tip())
+        p1, p2 = repo.dirstate.parents()
+        if p1 == nullid:
+            raise util.Abort(_('no revision to tag'))
+        if p2 != nullid:
+            raise util.Abort(_('outstanding uncommitted merges'))
+        r = hex(p1)
 
     repo.tag(name, r, opts['local'], opts['message'], opts['user'],
              opts['date'])