From f28638f71cbec73afc63ba67e649fc09128138af Mon Sep 17 00:00:00 2001 From: Michael Haggerty Date: Fri, 3 May 2013 16:28:20 +0200 Subject: [PATCH] Add a method Block.get_original_indices(). --- git-imerge | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/git-imerge b/git-imerge index a9692e5..78bf464 100755 --- a/git-imerge +++ b/git-imerge @@ -799,6 +799,13 @@ class Block(object): self._check_indexes(i1, i2) return (i1, i2) + def get_original_indexes(self, i1, i2): + """Return the original indexes corresponding to (i1,i2) in this block. + + This function supports negative indexes.""" + + return self._normalize_indexes((i1, i2)) + def set_value(self, i1, i2, value): """Set the MergeRecord for integer indexes (i1, i2). @@ -983,6 +990,10 @@ class SubBlock(Block): self._start1 = start1 self._start2 = start2 + def get_original_indexes(self, i1, i2): + i1, i2 = self._normalize_indexes((i1, i2)) + return self._block.get_original_indexes(i1 + self._start1, i2 + self._start2) + def set_value(self, i1, i2, sha1, flags): self._check_indexes(i1, i2) self._block.set_value(i1 + self._start1, i2 + self._start2, sha1, flags)