changeset 14850:a95242af945c stable

hgcia: Set default value of strip to -1 (issue2891) For backward compatibility the root path of the repository is not displayed unless the user has specified an explicit strip value.
author Cédric Krier <ced@b2ck.com>
date Sat, 09 Jul 2011 09:44:15 +0200
parents d87814992728
children f96c354493d7
files hgext/hgcia.py tests/test-hgcia.t
diffstat 2 files changed, 50 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/hgcia.py	Thu Jul 07 10:32:30 2011 +0200
+++ b/hgext/hgcia.py	Sat Jul 09 09:44:15 2011 +0200
@@ -81,6 +81,8 @@
         n = self.ctx.node()
         f = self.cia.repo.status(self.ctx.p1().node(), n)
         url = self.url or ''
+        if url and url[-1] == '/':
+            url = url[:-1]
         elems = []
         for path in f[0]:
             uri = '%s/diff/%s/%s' % (url, short(n), path)
@@ -141,8 +143,10 @@
         rev = '%d:%s' % (self.ctx.rev(), n)
         log = saxutils.escape(self.logmsg())
 
-        url = self.url and '<url>%s/rev/%s</url>' % (saxutils.escape(self.url),
-                                                     n) or ''
+        url = self.url
+        if url and url[-1] == '/':
+            url = url[:-1]
+        url = url and '<url>%s/rev/%s</url>' % (saxutils.escape(url), n) or ''
 
         msg = """
 <message>
@@ -190,7 +194,8 @@
         self.emailfrom = self.ui.config('email', 'from')
         self.dryrun = self.ui.configbool('cia', 'test')
         self.url = self.ui.config('web', 'baseurl')
-        self.stripcount = int(self.ui.config('cia', 'strip', 0))
+        # Default to -1 for backward compatibility
+        self.stripcount = int(self.ui.config('cia', 'strip', -1))
         self.root = self.strip(self.repo.root)
 
         style = self.ui.config('cia', 'style')
@@ -208,6 +213,8 @@
 
         path = util.pconvert(path)
         count = self.stripcount
+        if count < 0:
+            return ''
         while count > 0:
             c = path.find('/')
             if c == -1:
--- a/tests/test-hgcia.t	Thu Jul 07 10:32:30 2011 +0200
+++ b/tests/test-hgcia.t	Sat Jul 09 09:44:15 2011 +0200
@@ -46,9 +46,47 @@
         <author>test</author>
         <version>0:e63c23eaa88a</version>
         <log>foo</log>
-        <url>http://hgserver/$TESTTMP/cia/rev/e63c23eaa88a</url>
-        <files><file uri="http://hgserver/$TESTTMP/cia/file/e63c23eaa88a/foo" action="add">foo</file></files>
+        <url>http://hgserver/rev/e63c23eaa88a</url>
+        <files><file uri="http://hgserver/file/e63c23eaa88a/foo" action="add">foo</file></files>
       </commit>
     </body>
     <timestamp>0</timestamp>
   </message>
+
+  $ cat >> $HGRCPATH <<EOF
+  > strip = 0
+  > EOF
+
+  $ echo bar > bar
+  $ hg ci -Ambar
+  adding bar
+  $ hg push ../cia
+  pushing to ../cia
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  
+  <message>
+    <generator>
+      <name>Mercurial (hgcia)</name>
+      <version>0.1</version>
+      <url>http://hg.kublai.com/mercurial/hgcia</url>
+      <user>testuser</user>
+    </generator>
+    <source>
+  <project>testproject</project>
+  <branch>default</branch>
+  </source>
+    <body>
+      <commit>
+        <author>test</author>
+        <version>1:c0c7cf58edc5</version>
+        <log>bar</log>
+        <url>http://hgserver/$TESTTMP/cia/rev/c0c7cf58edc5</url>
+        <files><file uri="http://hgserver/$TESTTMP/cia/file/c0c7cf58edc5/bar" action="add">bar</file></files>
+      </commit>
+    </body>
+    <timestamp>0</timestamp>
+  </message>