Index: /CMT/HEAD/ChangeLog
===================================================================
--- /CMT/HEAD/ChangeLog	(revision 677)
+++ /CMT/HEAD/ChangeLog	(revision 678)
@@ -1,2 +1,8 @@
+2016-05-18    <rybkin@lal.in2p3.fr> 527
+
+	* mgr/cmt_svn_checkout.py: For trunk checkout, skip the check whether
+	trunk corresponds to a particular tag if CMTHEADVERSION is unset, empty,
+	or its value starts with '!'
+
 2014-02-04    <rybkin@lal.in2p3.fr> 526
 
Index: /CMT/HEAD/mgr/cmt_svn_checkout.py
===================================================================
--- /CMT/HEAD/mgr/cmt_svn_checkout.py	(revision 677)
+++ /CMT/HEAD/mgr/cmt_svn_checkout.py	(revision 678)
@@ -24,6 +24,6 @@
 """
 
-__version__ = '0.8.0'
-__date__ = 'Wed Jul 31 2013'
+__version__ = '0.9.0'
+__date__ = 'Wed May 18 2016'
 __author__ = 'Grigory Rybkin'
 
@@ -204,20 +204,29 @@
         self.with_version_directory = with_version_directory
         self.cleanup = cleanup
-        self.head_version = head_version
-        self.env()
-
-    def env(self):
-        if self.head_version is None:
-            self.set_head_version(os.getenv('CMTHEADVERSION', 'HEAD'))
-#        print >>sys.stderr, 'env: set head_version: %s' % self.head_version
+        if head_version:
+            self.set_head_version(head_version)
+        else:
+            self.set_head_version(os.getenv('CMTHEADVERSION', ''))
 
     def set_head_version(self, version):
-        self.head_version = str(version).replace('<package>', '%(package)s').replace('<PACKAGE>', '%(PACKAGE)s').replace('<revision>', '%(revision)i')
+        if not version:
+            self.head_version = ''
+            self.head_version_tag = False
+        elif version.startswith('!'):
+            # it may be appropriate to strip the leading '!'
+            # that will require synchronization with C++ code, however
+            # self.head_version = version[1:]
+            self.head_version = version
+            self.head_version_tag = False
+        else:
+            self.head_version = version
+            self.head_version_tag = True
 
     def eval_head_version(self, m):
-        return self.head_version % \
-               {'package' : m.package,
-                'PACKAGE' : m.package.upper(),
-                'revision' : m.info.last_changed_rev}
+        return str(self.head_version).replace('<package>', '%(package)s').replace('<PACKAGE>', '%(PACKAGE)s').replace('<revision>', '%(revision)i') % \
+            {'package' : m.package,
+             'PACKAGE' : m.package.upper(),
+             'revision' : m.info.last_changed_rev} \
+             or 'HEAD'
 
     def write(self, p, version):
@@ -597,7 +606,26 @@
             if self.version is None:
                 m.head = True
-                m.version = self.trunk_tag(m, client_context) or \
-                            cmt_context.eval_head_version(m)
-#                print >>sys.stderr, 'set version: %s' % m.version
+                if cmt_context.head_version_tag:
+                    m.version = self.trunk_tag(m, client_context) or \
+                        cmt_context.eval_head_version(m)
+                else:
+                    trunk = posixpath.join(m.url, self.trunk)
+                    cmd = 'svn info %s' % trunk
+                    scc, out = Utils.getstatusoutput(cmd)
+                    logger.debug('%s\n%s' % (cmd, out))
+                    if scc != 0:
+                        logger.error('%s\n%s' % (cmd, out))
+                        sc += 1; continue
+                    p = r'last\s+changed\s+rev:\s+(?P<rev>\d+)'
+                    M = re.search(p, out, re.I)
+                    if M:
+                        class info(object): pass
+                        info.last_changed_rev = int(M.group('rev'))
+                        self.info_receiver(trunk, info, m)
+                        logger.debug('last_changed_rev: %d' % info.last_changed_rev)
+                    else:
+                        logger.warning('%s: last_changed_rev: Not found' % trunk)
+                    m.version = cmt_context.eval_head_version(m)
+                logger.debug('set version: %s' % m.version)
             else:
                 m.head = False
