Patchwork [V3] archive: report the node as "{p1node}+" when archiving a dirty wdir()

login
register
mail settings
Submitter Matt Harbison
Date June 18, 2015, 12:40 a.m.
Message ID <978941d6a9fecdb003c5.1434588020@Envy>
Download mbox | patch
Permalink /patch/9700/
State Accepted
Headers show

Comments

Matt Harbison - June 18, 2015, 12:40 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1434510885 14400
#      Tue Jun 16 23:14:45 2015 -0400
# Node ID 978941d6a9fecdb003c5c5d7c9dda5321d94db89
# Parent  39f2759a274226581b309c215629643d01fccf7a
archive: report the node as "{p1node}+" when archiving a dirty wdir()

This is more useful than reporting all 'f's, allowing the archive to be diffed
against a specific revision to see what changed.
Matt Mackall - June 19, 2015, 4:02 a.m.
On Wed, 2015-06-17 at 20:40 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1434510885 14400
> #      Tue Jun 16 23:14:45 2015 -0400
> # Node ID 978941d6a9fecdb003c5c5d7c9dda5321d94db89
> # Parent  39f2759a274226581b309c215629643d01fccf7a
> archive: report the node as "{p1node}+" when archiving a dirty wdir()

Queued for default, thanks.

Patch

diff --git a/mercurial/archival.py b/mercurial/archival.py
--- a/mercurial/archival.py
+++ b/mercurial/archival.py
@@ -67,8 +67,14 @@ 
 def buildmetadata(ctx):
     '''build content of .hg_archival.txt'''
     repo = ctx.repo()
+    hex = ctx.hex()
+    if ctx.rev() is None:
+        hex = ctx.p1().hex()
+        if ctx.dirty():
+            hex += '+'
+
     base = 'repo: %s\nnode: %s\nbranch: %s\n' % (
-        _rootctx(repo).hex(), ctx.hex(), encoding.fromlocal(ctx.branch()))
+        _rootctx(repo).hex(), hex, encoding.fromlocal(ctx.branch()))
 
     tags = ''.join('tag: %s\n' % t for t in ctx.tags()
                    if repo.tagtype(t) == 'global')
diff --git a/tests/test-subrepo-deep-nested-change.t b/tests/test-subrepo-deep-nested-change.t
--- a/tests/test-subrepo-deep-nested-change.t
+++ b/tests/test-subrepo-deep-nested-change.t
@@ -187,6 +187,14 @@ 
   ../wdir/sub1/sub2/folder/test.txt
   ../wdir/sub1/sub2/sub2
 
+  $ cat ../wdir/.hg_archival.txt
+  repo: 7f491f53a367861f47ee64a80eb997d1f341b77a
+  node: 9bb10eebee29dc0f1201dcf5977b811a540255fd+
+  branch: default
+  latesttag: null
+  latesttagdistance: 4
+  changessincelatesttag: 3
+
 Attempting to archive 'wdir()' with a missing file is handled gracefully
   $ rm sub1/sub1
   $ rm -r ../wdir
@@ -204,6 +212,16 @@ 
 
 Continue relative path printing + subrepos
   $ hg update -Cq
+  $ rm -r ../wdir
+  $ hg archive -S -r 'wdir()' ../wdir
+  $ cat ../wdir/.hg_archival.txt
+  repo: 7f491f53a367861f47ee64a80eb997d1f341b77a
+  node: 9bb10eebee29dc0f1201dcf5977b811a540255fd
+  branch: default
+  latesttag: null
+  latesttagdistance: 4
+  changessincelatesttag: 3
+
   $ touch sub1/sub2/folder/bar
   $ hg addremove sub1/sub2
   adding sub1/sub2/folder/bar (glob)