Patchwork [13,of,21,RFC] merge: linear updates to censored data revisions produce empty files

login
register
mail settings
Submitter michaeljedgar@gmail.com
Date Sept. 11, 2014, 12:26 a.m.
Message ID <4004f1fed45d6ea2a882.1410395174@adgar-macbookpro3.roam.corp.google.com>
Download mbox | patch
Permalink /patch/5788/
State Changes Requested
Headers show

Comments

michaeljedgar@gmail.com - Sept. 11, 2014, 12:26 a.m.
# HG changeset patch
# User Mike Edgar <adgar@google.com>
# Date 1410322526 14400
#      Wed Sep 10 00:15:26 2014 -0400
# Node ID 4004f1fed45d6ea2a88272895a5e12ccf28cad0c
# Parent  c81c9a42fb6f1b2f402e4e6607fe2a531469b08e
merge: linear updates to censored data revisions produce empty files

The same configuration check done in verify is done in update to determine if
the update should be rejected or should substitute the empty file.
Matt Mackall - Sept. 11, 2014, 5:55 p.m.
On Wed, 2014-09-10 at 20:26 -0400, michaeljedgar@gmail.com wrote:
> # HG changeset patch
> # User Mike Edgar <adgar@google.com>
> # Date 1410322526 14400
> #      Wed Sep 10 00:15:26 2014 -0400
> # Node ID 4004f1fed45d6ea2a88272895a5e12ccf28cad0c
> # Parent  c81c9a42fb6f1b2f402e4e6607fe2a531469b08e
> merge: linear updates to censored data revisions produce empty files
> 
> The same configuration check done in verify is done in update to determine if
> the update should be rejected or should substitute the empty file.

Also too burdensome. This needs a helper (perhaps a method on filectx).

Patch

diff -r c81c9a42fb6f -r 4004f1fed45d mercurial/merge.py
--- a/mercurial/merge.py	Wed Sep 10 00:17:54 2014 -0400
+++ b/mercurial/merge.py	Wed Sep 10 00:15:26 2014 -0400
@@ -7,10 +7,11 @@ 
 
 import struct
 
-from node import nullid, nullrev, hex, bin
+from node import nullid, nullrev, hex, bin, short
 from i18n import _
 from mercurial import obsolete
 import error as errormod, util, filemerge, copies, subrepo, worker, dicthelpers
+import censor
 import errno, os, shutil
 
 _pack = struct.pack
@@ -597,7 +598,15 @@ 
         repo.ui.debug(" %s: %s -> g\n" % (f, msg))
         if verbose:
             repo.ui.note(_("getting %s\n") % f)
-        wwrite(f, fctx(f).data(), args[0])
+        try:
+            data = fctx(f).data()
+        except errormod.CensoredNodeError, e:
+            if not censor.allowed(repo, f, e.node):
+                raise util.Abort(_('file %s censored at revision %s')
+                                 % (f, short(mctx.node())))
+            repo.ui.warn(_('warning: censored file is empty: %s\n') % f)
+            data = ''
+        wwrite(f, data, args[0])
         if i == 100:
             yield i, f
             i = 0