Patchwork [1,of,6,V2] subrepo: introduce storeclean helper functions

login
register
mail settings
Submitter Angel Ezquerra
Date March 9, 2013, 12:12 a.m.
Message ID <252c0f551d94b790f503.1362787954@Angel-PC.localdomain>
Download mbox | patch
Permalink /patch/1087/
State Accepted
Commit 1fa4edb8456e4084fe18432fdcc3440c93a6a704
Headers show

Comments

Angel Ezquerra - March 9, 2013, 12:12 a.m.
# HG changeset patch
# User Angel Ezquerra <angel.ezquerra@gmail.com>
# Date 1360969620 -3600
#      Sat Feb 16 00:07:00 2013 +0100
# Node ID 252c0f551d94b790f50361cf67f14ff7fcb029b0
# Parent  a07be895373394be66ba38b1ff111e26aca03ac8
subrepo: introduce storeclean 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):