0

我在我的根目录上做了一个递归 sed,当我尝试提交,或者除了 hg --help 之外对 hg 做任何事情时,我得到一个堆栈跟踪。当我执行 sed 时,我错误地认为 .hg 目录是写保护的。

该仓库在我的机器上是本地的。

有什么方法可以让我恢复我的变更日志或提交评论?00changelog.i我在目录中找到了一个名为的文件.hg,但它是一个不执行的二进制文件。

sed 命令:

find . -type f -exec sed -i.bak "s/sim-config.h/config.h/g" {} \;
find . -type f -exec sed -i.bak "s/av-config.h/config.h/g" {} \;

堆栈跟踪:

Traceback (most recent call last):
  File "/usr/bin/hg", line 27, in <module>
    mercurial.dispatch.run()
  File "/usr/lib/python2.6/site-packages/mercurial/dispatch.py", line 16, in run
    sys.exit(dispatch(sys.argv[1:]))
  File "/usr/lib/python2.6/site-packages/mercurial/dispatch.py", line 30, in dispatch
    return _runcatch(u, args)
  File "/usr/lib/python2.6/site-packages/mercurial/dispatch.py", line 50, in _runcatch
    return _dispatch(ui, args)
  File "/usr/lib/python2.6/site-packages/mercurial/dispatch.py", line 470, in _dispatch
    return runcommand(lui, repo, cmd, fullargs, ui, options, d)
  File "/usr/lib/python2.6/site-packages/mercurial/dispatch.py", line 340, in runcommand
    ret = _runcommand(ui, options, cmd, d)
  File "/usr/lib/python2.6/site-packages/mercurial/dispatch.py", line 521, in _runcommand
    return checkargs()
  File "/usr/lib/python2.6/site-packages/mercurial/dispatch.py", line 475, in checkargs
return cmdfunc()
  File "/usr/lib/python2.6/site-packages/mercurial/dispatch.py", line 469, in <lambda>
    d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
  File "/usr/lib/python2.6/site-packages/mercurial/util.py", line 401, in check
    return func(*args, **kwargs)
  File "/usr/lib/python2.6/site-packages/mercurial/commands.py", line 712, in commit
    node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
  File "/usr/lib/python2.6/site-packages/mercurial/cmdutil.py", line 1151, in commit
    return commitfunc(ui, repo, message, match(repo, pats, opts), opts)
  File "/usr/lib/python2.6/site-packages/mercurial/commands.py", line 710, in commitfunc
    editor=e, extra=extra)
  File "/usr/lib/python2.6/site-packages/mercurial/localrepo.py", line 787, in commit
    changes = self.status(match=match, clean=force)
  File "/usr/lib/python2.6/site-packages/mercurial/localrepo.py", line 1015, in status
    listclean, listunknown)
  File "/usr/lib/python2.6/site-packages/mercurial/dirstate.py", line 614, in status
    dmap = self._map
  File "/usr/lib/python2.6/site-packages/mercurial/util.py", line 156, in __get__
    result = self.func(obj)
  File "/usr/lib/python2.6/site-packages/mercurial/dirstate.py", line 58, in _map
    self._read()
  File "/usr/lib/python2.6/site-packages/mercurial/dirstate.py", line 228, in _read
    p = parsers.parse_dirstate(self._map, self._copymap, st)
4

1 回答 1

1

如果您没有可以替换.hg克隆的上游源,则可能取决于文件的损坏程度。然而,正如您所注意到的,Mercurial 在内部以二进制格式存储文件,这使得手动修复变得更加困难。

大概您没有sed -i.bak使用备份进行就地备份(这将使恢复变得容易)。

您可以执行以下操作:

find .hg -mmin -60 -print

查看过去(例如)60 分钟内修改了哪些文件。也许没有太多修改,你可以找到一些方法来扭转sed命令对该文件的影响(但如果你运行类似的东西,那将是不可能的/foo/d)。

将来,可能值得在http://bitbucket.org/上注册一个免费帐户,这将为您提供免费的私人存储库托管和良好的备份位置。

于 2013-07-19T16:15:27.317 回答