Patchwork [1,of,5] subrepo: introduce cleanstore helper functions

login
register
mail settings
Submitter Angel Ezquerra
Date Feb. 16, 2013, 12:27 p.m.
Message ID <b56117a1b968211a464c.1361017645@Angel-PC.localdomain>
Download mbox | patch
Permalink /patch/1015/
State Superseded, archived
Headers show

Comments

Angel Ezquerra - Feb. 16, 2013, 12:27 p.m.
# HG changeset patch
# User Angel Ezquerra <angel.ezquerra@gmail.com>
# Date 1360969620 -3600
# Node ID b56117a1b968211a464c4ba674539052328d3336
# Parent  013fcd112f13f31a35ea6a40d8cd1c6923cdaf20
subrepo: introduce cleanstore helper functions

These helper functions are currently unused but will be used to implement the
cleanstore method that will be introduced later.

Patch

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -14,6 +14,19 @@ 
 
 nullstate = ('', '', 'empty')
 
+
+def _getstorehashcachename(remotepath):
+    '''get a unique filename for the store hash cache of a remote repository'''
+    return util.sha1(remotepath).hexdigest()[0:12]
+
+def _calcfilehash(filename):
+    data = ''
+    if os.path.exists(filename):
+        fd = open(filename)
+        data = fd.read()
+        fd.close()
+    return util.sha1(data).hexdigest()
+
 class SubrepoAbort(error.Abort):
     """Exception class used to avoid handling a subrepo error more than once"""
     def __init__(self, *args, **kw):