[PATCH STABLE] archive: don't assume '.' is being archived for changessincelatesttag

Matt Harbison mharbison72 at gmail.com
Thu Jun 25 21:52:08 CDT 2015


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1435281407 14400
#      Thu Jun 25 21:16:47 2015 -0400
# Branch stable
# Node ID 523cd6aa9b6c093b038d1a639c82727fba3a6f87
# Parent  6047b60cdd0984b60191bdb3b272d87c2691ffe4
archive: don't assume '.' is being archived for changessincelatesttag

Hardcoding '.' is wrong, and yielded strange results when archiving old
revisions.  For example, when archiving the cset that adds the signature to 3.4
(c48850339988), the resulting value was previously 51 (the number of commits on
stable between 3.4 and today), even though it was a direct descendant of a tag,
with a {latesttagdistance} of 2.  This still includes all other _ancestor_ paths
not included in {latesttag}.

Note that archiving wdir() currently blows up several lines above this when
building the 'base' variable.  Since wdir() isn't documented, ignore that it
needs work to handle wdir() here for now.

diff --git a/mercurial/archival.py b/mercurial/archival.py
--- a/mercurial/archival.py
+++ b/mercurial/archival.py
@@ -75,7 +75,8 @@
         cmdutil.show_changeset(repo.ui, repo, opts).show(ctx)
         ltags, dist = repo.ui.popbuffer().split('\n')
         ltags = ltags.split(':')
-        changessince = len(repo.revs('only(.,%s)', ltags[0]))
+        # XXX: ctx.rev() needs to be handled differently with wdir()
+        changessince = len(repo.revs('only(%d,%s)', ctx.rev(), ltags[0]))
         tags = ''.join('latesttag: %s\n' % t for t in ltags)
         tags += 'latesttagdistance: %s\n' % dist
         tags += 'changessincelatesttag: %s\n' % changessince
diff --git a/tests/test-glog.t b/tests/test-glog.t
--- a/tests/test-glog.t
+++ b/tests/test-glog.t
@@ -2013,6 +2013,16 @@
   |
   o  0 add a
   
+  $ hg archive -r 7 archive
+  $ grep changessincelatesttag archive/.hg_archival.txt
+  changessincelatesttag: 1
+  $ rm -r archive
+
+changessincelatesttag with no prior tag
+  $ hg archive -r 4 archive
+  $ grep changessincelatesttag archive/.hg_archival.txt
+  changessincelatesttag: 5
+
   $ hg export 'all()'
   # HG changeset patch
   # User test


More information about the Mercurial-devel mailing list