Closed mvance closed 14 years ago
on my Windows machine on every repo it stops with: abort: The process cannot access the file because it is being used by another process
someone who owns a windows machine will have to look into this. otherwise, when everything else is done on this project, i'll rent an AWS instance to check it out.
mvance, do you get the same results when you try gclone instead of clone?
When I try the following:
hg gclone git://git.example.com/git/example.git
. . .I get a message saying "hg: unknown command 'gclone'." I'm pretty sure that I either don't have hg-git installed correctly or that the Windows version of Mercurial is not recognizing it for some reason.
Hi, mvance. I just tried adding the following to the end of my Mercurial.ini's [extensions] section on XP, with a fresh Mercurial 1.2.1 from berkwood.com and hg-git cloned from Scotty's Bitbucket repo:
[extensions] hgext.bookmarks = hgext.hg-git = C:/hg-git
... and Mercurial recognized hg gclone. It seemed to work with both forward and backward slashes in the path name inside the .ini file.
One thing that's happened to me with some Windows distributions of Mercurial is that the Mercurial.ini file I edit can turn out to be a different one than the one Hg is loading. (For example, if I didn't clean up after migrating from a source install to TortoiseHg).
Can you try modding your Mercurial.ini to add one of the extensions bundled with Mercurial? Actually, since you've turned on bookmarks above, that's a good one to try: what happens when you type "hg book" at the command line? If it doesn't recognize that command, I'd try a hard drive search for other Mercurial.ini instances.
TBD, I'm getting the "cannot access this file" error on gclone with Windows, too. Let me take a peek at it this afternoon and see what I can turn up.
Undees,
That was it. I had both a C:\Program Files\Mercurial\Mercurial.ini and a C:\Program Files\TortoiseHg\Mercurial.ini file. Adding the extension in the TortoiseHg version did the trick.
Thanks!
I spoke too soon. The gclone process eventually dies with the same error message TBD mentioned above, "abort: The process cannot access the file because it is being used by another process"
I tried gcloning two two different repositories, with the same result.
One step closer. I found when the error is happening, but don't have a fix yet. In object_store.py/move_in_pack(), the function is trying to os.rename() a file that's still open, which Windows is crazily fussy about. It's easy enough to change os.rename() to shutil.copyfile(), and we're on to the next error:
fetching from : origin exporting git objects Counting objects: 255, done. Compressing objects: 100% (122/122), done. Total 255 (delta 118), reused 255 (delta 118) importing Git objects into Hg *\* unknown exception encountered, details follow *\* report bug details to http://www.selenic.com/mercurial/bts *\* or mercurial@selenic.com *\* Mercurial Distributed SCM (version 1.2.1) *\* Extensions loaded: bookmarks, hg-git, win32text Traceback (most recent call last): File "hg", line 27, inFile "mercurial\dispatch.pyc", line 16, in run File "mercurial\dispatch.pyc", line 25, in dispatch File "mercurial\dispatch.pyc", line 41, in _runcatch File "mercurial\dispatch.pyc", line 372, in _dispatch File "mercurial\dispatch.pyc", line 247, in runcommand File "mercurial\dispatch.pyc", line 417, in _runcommand File "mercurial\dispatch.pyc", line 377, in checkargs File "mercurial\dispatch.pyc", line 371, in File "mercurial\util.pyc", line 718, in check File "C:/hg-git__init__.py", line 38, in gclone git.fetch('origin') File "C:/hg-git\git_handler.py", line 116, in fetch self.import_git_objects(remote_name) File "C:/hg-git\git_handler.py", line 442, in import_git_objects for head, sha in self.git.remote_refs(remote_name).iteritems(): File "C:\hg-git\dulwich\repo.py", line 296, in remote_refs ret[name] = self._get_ref(os.path.join(root, name)) File "C:\hg-git\dulwich\repo.py", line 182, in _get_ref assert len(contents) == 41, 'Invalid ref in %s' % file AssertionError: Invalid ref in C:\path\to\repo.hg\git\refs\remotes\origin\master
remotes\origin\master is pointing to what looks like a valid SHA-1. Copied the hash to refs\heads\master, and tried a "git log". Invalid HEAD, saith Git. Pack file is the same as on the Mac side, but the index file is 32 bytes longer than its Mac counterpart. Guessing a newline error, and sure enough, ^Ms all over the diff.
write_pack_index_v2
is opening the .idx file in 'w' mode instead of 'wb'. Made the change, and am now getting an assertion failure on len(contents). The saga continuums.
The assertion failure was caused by a trailing carriage return in the hex representation of the hash. In repo.py, I changed _get_ref
to this:
def _get_ref(self, file):
f = open(file, 'rb')
try:
contents = f.read().strip()
if contents.startswith(SYMREF):
ref = contents[len(SYMREF):]
return self.ref(ref)
assert len(contents) == 40, 'Invalid ref in %s' % file
return contents
finally:
f.close()
And started choking in the bookmark import. Turns out there are other places in pack.py that need open() to be given 'rb' or 'wb' instead of 'r' or 'w'. Fixed those, and got a clean gclone on WinXP!
Need to clean up and check in.
Checked in at http://github.com/undees/hg-git. I'll send a pull request.
undees: made a glcone on your hg repository. works great. thanks for the fix.
i've pulled these changes in
I now get the following error trying to glone on two different repositories I've tried:
"abort: could not lock working directory of example-hg: Permission denied"
Hi, mvance. I'm having trouble replicating this--perhaps it's version-specific or repo-specific? I'm using Mercurial 1.2.1 with a fresh download of hg-git revision 7b7361 from schacon's github repo, and cloning this repo:
hg gclone git://github.com/undees/sandbox.git
Does the error persist with this Mercurial / hg-git version, and this repo?
Undees, thanks for sticking with this and helping out so much. Switching to the latest version you referenced above seems to have fixed the issue for me.
Thanks again!
I tried adding the following lines to my c:\program files\mercurial\Mercurial.ini file:
hgext.bookmarks = hgext.hg-git = C:\etc\hg-git
... but it doesn't seem to be working. When I enter hg help, I don't see any of the new commands listed (gfetch, gpush, etc). When I try to do a git checkout, I get the same error that I get on a machine without hg-git installed:
C:\temp\example>hg clone git://git.example.com/git/example.git abort: repository git://git.example.com/git/example.git not found!
Any idea what I'm missing?
Thanks!