# HG changeset patch # User Jun Wu # Date 1465993720 -3600 # Node ID cf79525f507cb4af4258987c7939aa3cc475e30c # Parent 6bc2a2f619231364e12916f94f3d9ff76fb4a412 maps: change branchedits to accept revnum directly This makes tests easier to write. diff --git a/hgsubversion/maps.py b/hgsubversion/maps.py --- a/hgsubversion/maps.py +++ b/hgsubversion/maps.py @@ -370,8 +370,8 @@ class RevMap(dict): self._hashes = dict((v, k) for (k, v) in self._origiteritems()) return self._hashes - def branchedits(self, branch, rev): - check = lambda x: x[0][1] == branch and x[0][0] < rev.revnum + def branchedits(self, branch, revnum): + check = lambda x: x[0][1] == branch and x[0][0] < revnum return sorted(filter(check, self._origiteritems()), reverse=True) def branchmaxrevnum(self, branch, maxrevnum): @@ -579,12 +579,12 @@ class SqliteRevMap(collections.MutableMa self._hashes = self.ReverseRevMap(self) return self._hashes - def branchedits(self, branch, rev): + def branchedits(self, branch, revnum): return [((r[0], r[1] or None), bytes(r[2])) for r in self._query('SELECT rev, branch, hash FROM revmap ' + 'WHERE rev < ? AND branch = ? ' + 'ORDER BY rev DESC, branch DESC', - (rev.revnum, branch or ''))] + (revnum, branch or ''))] def branchmaxrevnum(self, branch, maxrev): for row in self._query('SELECT rev FROM revmap ' + diff --git a/hgsubversion/replay.py b/hgsubversion/replay.py --- a/hgsubversion/replay.py +++ b/hgsubversion/replay.py @@ -103,7 +103,7 @@ def _convert_rev(ui, meta, svn, r, tbdel closebranches = {} for branch in tbdelta['branches'][1]: - branchedits = meta.revmap.branchedits(branch, rev) + branchedits = meta.revmap.branchedits(branch, rev.revnum) if len(branchedits) < 1: # can't close a branch that never existed continue diff --git a/hgsubversion/stupid.py b/hgsubversion/stupid.py --- a/hgsubversion/stupid.py +++ b/hgsubversion/stupid.py @@ -568,7 +568,7 @@ def fetch_branchrev(svn, meta, branch, b return files, filectxfn def checkbranch(meta, r, branch): - branchedits = meta.revmap.branchedits(branch, r) + branchedits = meta.revmap.branchedits(branch, r.revnum) if not branchedits: return None branchtip = branchedits[0][1]