3r1co / hg4j

Automatically exported from code.google.com/p/hg4j
GNU General Public License v2.0
0 stars 1 forks source link

Exception in thread "main" java.lang.IllegalArgumentException: Bad left range boundary 10 in [0..0] #6

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
In fact it's a class not found exception. I think it caused by the below code 
HgDataFile.java
----------------------------------

 public void contentWithFilters(int revision, ByteChannel sink)
        throws HgDataStreamException, IOException, CancelledException
    {
        content(revision, new FilterByteChannel(sink, getRepo().getFiltersFromRepoToWorkingDir(getPath())));
    }

----------------------------------

The method getFiltersFromRepoToWorkingDir is a package level. 
you can use the attachment to reproduce the bug.

Original issue reported on code.google.com by xwch...@gmail.com on 22 Apr 2011 at 9:31

Attachments:

GoogleCodeExporter commented 8 years ago
I doubt method visibility may result in IllegalArgumentException. The 
exception's message (and it's apparent from the sample code) suggests you try 
to read revision 10 of a file that has single revision only. I believe there's 
confusion in revision numbers - right now in hg4j revision numbers are of 
"low-level" kind, reflecting revisions of that particular file, not of the 
whole repository. Imagine, you've got repository with two files, changed each 
file twice, make a commit after each change. After that, repository (and 
changelog and manifest) would have 4 revisions, while each file would have 2 
revisions only. 

Perhaps, use of per-revlog revision numbers not the best design decision, but 
there's rationale behind it.

 I didn't quite understand what the sample tries to accomplish, and thus can't suggest a fix. Perhaps, there are gaps in HgStatus object (shall give access to specific file revision?) or the task you try to solve needs complete manifest access.

Original comment by tikhomir...@gmail.com on 24 Apr 2011 at 1:58

GoogleCodeExporter commented 8 years ago
I am using the latest source code from main repository.
http://hg.hg4j.com/hg4j/

Original comment by xwch...@gmail.com on 24 Apr 2011 at 2:20

GoogleCodeExporter commented 8 years ago
Just as I said the root caused is "Class Not found", but this exception has 
been wrapped as "IllegalArgumentException"

Original comment by xwch...@gmail.com on 24 Apr 2011 at 2:23

GoogleCodeExporter commented 8 years ago
I can't run your example to reproduce the issue because I don't have repository 
you try to iterate. Could you please copy whole stacktrace here (if there are 
few exceptions, all of them)?

There's single place where IAE with the message "Bad left range boundary..." is 
thrown, it's explicit (specific condition shall be met) and doesn't wrap 
anything else. Besides, HgDataFile *is* inside the same package with 
HgRepository with method "getFiltersFromRepoToWorkingDir", thus any visibility 
issue would be violation of JLS.

Original comment by tikhomir...@gmail.com on 24 Apr 2011 at 5:06

GoogleCodeExporter commented 8 years ago
Below is the whole stack

Exception in thread "main" java.lang.IllegalArgumentException: Bad left range 
boundary 10 in [0..0]
    at org.tmatesoft.hg.internal.RevlogStream.iterate(RevlogStream.java:196)
    at org.tmatesoft.hg.repo.HgDataFile.content(HgDataFile.java:142)
    at org.tmatesoft.hg.repo.HgDataFile.contentWithFilters(HgDataFile.java:110)
    at org.tmatesoft.hg.core.HgCatCommand.execute(HgCatCommand.java:121)
    at org.tmatesoft.hg.test.TestHgStatusCommand$1.handleStatus(TestHgStatusCommand.java:41)
    at org.tmatesoft.hg.core.HgStatusCommand$Mediator.added(HgStatusCommand.java:237)
    at org.tmatesoft.hg.repo.HgStatusCollector.walk(HgStatusCollector.java:239)
    at org.tmatesoft.hg.repo.HgStatusCollector.change(HgStatusCollector.java:160)
    at org.tmatesoft.hg.core.HgStatusCommand.execute(HgStatusCommand.java:183)
    at org.tmatesoft.hg.test.TestHgStatusCommand.run(TestHgStatusCommand.java:30)
    at org.tmatesoft.hg.test.TestHgStatusCommand.main(TestHgStatusCommand.java:65)

Original comment by xwch...@gmail.com on 26 Apr 2011 at 9:24

GoogleCodeExporter commented 8 years ago
Try to replace 10 with 0 in the catCommand.revision(10) line in your sample. 
With that change your sample will run, I'm sure.

I believe you shall use HgLogCommand instead of HgSatusCommand. Right now your 
code does something like:
`hg status --change 9`          <--- basically, iterate changes between 8th and 
9th revisions
foreach <file reported by status above> do
  `hg cat --rev 10 file file > /dev/null`  <--- try to cat revision 10 of a file
endforeach

and it doesn't make too much sense to me.

Instead, try:
HgLogCommand().range(9,9).execute(Handler() {
  next(HgChangeset cset) {
     foreach (FileRevision fr : cset.getAddedFiles()) {
        fr.putContentTo(ByteChannel);
     }
  }
})
this would process content of files that were added to the repo in revision 9. 
(There are also HgChangeset#getModifiedFiles and #getRemovedFiles()).

Original comment by tikhomir...@gmail.com on 26 Apr 2011 at 3:01

GoogleCodeExporter commented 8 years ago
No response, assume issue resolved.
Feel free to re-open if needed.

Original comment by tikhomir...@gmail.com on 19 May 2011 at 3:37