changeset 1184:43384d2782dc

svnmeta: move revmap.youngest to meta.lastpulled Using our new generator, we factor out revmap.youngest and renamed it to the same name as the config file 'lastpulled' because that is the name of the file and is arguably less confusing to read.
author Sean Farley <sean.michael.farley@gmail.com>
date Mon, 24 Mar 2014 11:20:44 -0500
parents 09b20039192c
children 65ca78ac2ee1
files hgsubversion/maps.py hgsubversion/svnmeta.py hgsubversion/wrappers.py
diffstat 3 files changed, 9 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/maps.py
+++ b/hgsubversion/maps.py
@@ -197,12 +197,6 @@ class RevMap(dict):
     def __init__(self, meta):
         dict.__init__(self)
         self.meta = meta
-        self.ypath = os.path.join(meta.metapath, 'lastpulled')
-        # TODO(durin42): Consider moving management of the youngest
-        # file to svnmeta itself rather than leaving it here.
-        # must load youngest file first, or else self._load() can
-        # clobber the info
-        self._youngest = util.load(self.ypath, 0)
         self.oldest = 0
 
         if os.path.isfile(self.meta.revmap_file):
@@ -210,15 +204,6 @@ class RevMap(dict):
         else:
             self._write()
 
-    def _set_youngest(self, rev):
-        self._youngest = max(self._youngest, rev)
-        util.dump(self._youngest, self.ypath)
-
-    def _get_youngest(self):
-        return self._youngest
-
-    youngest = property(_get_youngest, _set_youngest)
-
     def hashes(self):
         return dict((v, k) for (k, v) in self.iteritems())
 
@@ -247,8 +232,8 @@ class RevMap(dict):
             else:
                 branch = branch[:-1]
             revnum = int(revnum)
-            if revnum > self.youngest or not self.youngest:
-                self.youngest = revnum
+            if revnum > self.meta.lastpulled or not self.meta.lastpulled:
+                self.meta.lastpulled = revnum
             if revnum < self.oldest or not self.oldest:
                 self.oldest = revnum
             dict.__setitem__(self, (revnum, branch), node.bin(ha))
@@ -264,8 +249,8 @@ class RevMap(dict):
         b = branch or ''
         f.write(str(revnum) + ' ' + node.hex(ha) + ' ' + b + '\n')
         f.close()
-        if revnum > self.youngest or not self.youngest:
-            self.youngest = revnum
+        if revnum > self.meta.lastpulled or not self.meta.lastpulled:
+            self.meta.lastpulled = revnum
         if revnum < self.oldest or not self.oldest:
             self.oldest = revnum
         dict.__setitem__(self, (revnum, branch), ha)
--- a/hgsubversion/svnmeta.py
+++ b/hgsubversion/svnmeta.py
@@ -32,6 +32,8 @@ class SVNMeta(object):
         self.subdir = subdir
         self._revmap = None
 
+        self._gen_cachedconfig('lastpulled', 0, configname=False)
+
         author_host = self.ui.config('hgsubversion', 'defaulthost', uuid)
         authors = util.configpath(self.ui, 'authormap')
         self.usebranchnames = self.ui.configbool('hgsubversion',
--- a/hgsubversion/wrappers.py
+++ b/hgsubversion/wrappers.py
@@ -97,7 +97,7 @@ def incoming(orig, ui, repo, origsource=
     meta = repo.svnmeta(svn.uuid, svn.subdir)
 
     ui.status('incoming changes from %s\n' % other.svnurl)
-    svnrevisions = list(svn.revisions(start=meta.revmap.youngest))
+    svnrevisions = list(svn.revisions(start=meta.lastpulled))
     if opts.get('newest_first'):
         svnrevisions.reverse()
     # Returns 0 if there are incoming changes, 1 otherwise.
@@ -391,7 +391,7 @@ def pull(repo, source, heads=[], force=F
             meta.branchmap['default'] = branch
 
         ui = repo.ui
-        start = meta.revmap.youngest
+        start = meta.lastpulled
         origrevcount = len(meta.revmap)
 
         if start <= 0:
@@ -485,7 +485,7 @@ def pull(repo, source, heads=[], force=F
         util.swap_out_encoding(old_encoding)
 
     if lastpulled is not None:
-        meta.revmap.youngest = lastpulled
+        meta.lastpulled = lastpulled
     revisions = len(meta.revmap) - oldrevisions
 
     if revisions == 0: