[PATCH 1 of 5 RFC] largefiles: make the protocol hack for replacing heads with lheads more precise

Mads Kiilerich mads at kiilerich.com
Thu Oct 10 02:35:49 UTC 2013


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1381372119 -7200
#      Thu Oct 10 04:28:39 2013 +0200
# Node ID 0b23c2624ea5134c2b1b6586e539bb92210fc484
# Parent  e828975722c8ff632f08cbeb84ec184da2952823
largefiles: make the protocol hack for replacing heads with lheads more precise

Before the hack would replace 'heads' with 'lheads' no matter where it occured
in a batch command string.

Instead we will use a regexp to more carefully only match the 'heads' commands.

diff --git a/hgext/largefiles/proto.py b/hgext/largefiles/proto.py
--- a/hgext/largefiles/proto.py
+++ b/hgext/largefiles/proto.py
@@ -5,6 +5,7 @@
 
 import os
 import urllib2
+import re
 
 from mercurial import error, httppeer, util, wireproto
 from mercurial.wireproto import batchable, future
@@ -166,9 +167,11 @@
         args['cmds'] = args['cmds'].replace('heads ', 'lheads ')
     return ssholdcallstream(self, cmd, **args)
 
+headsre = re.compile(r'(^|;)heads\b')
+
 def httprepocallstream(self, cmd, **args):
     if cmd == 'heads' and self.capable('largefiles'):
         cmd = 'lheads'
     if cmd == 'batch' and self.capable('largefiles'):
-        args['cmds'] = args['cmds'].replace('heads ', 'lheads ')
+        args['cmds'] = headsre.sub('lheads', args['cmds'])
     return httpoldcallstream(self, cmd, **args)



More information about the Mercurial-devel mailing list