Ticket #12128 (closed defect: fixed)

Opened 18 months ago

Last modified 18 months ago

"hg verify" is not a proper way to check whether there is an hg repo

Reported by: jdemeyer Owned by: GeorgSWeber
Priority: blocker Milestone: sage-4.8
Component: build Keywords:
Cc: vbraun, mjo Work issues:
Report Upstream: N/A Reviewers: Michael Orlitzky
Authors: Jeroen Demeyer Merged in: sage-4.8.alpha4
Dependencies: Stopgaps:

Description

From the root spkg-install:

# see if there is a valid Mercurial repository in $SAGE_ROOT
hg verify 1>/dev/null 2>/dev/null

Unfortunately, this is a bad way to check for Mercurial repository because this can succeed even if there is no SAGE_ROOT/.hg but a .hg in some parent directory.

I propose to change this to

if [ -d .hg ]; then

Attachments

12128_root_hg_verify.patch Download (752 bytes) - added by jdemeyer 18 months ago.

Change History

Changed 18 months ago by jdemeyer

comment:1 Changed 18 months ago by jdemeyer

  • Status changed from new to needs_review
  • Authors set to Jeroen Demeyer

comment:2 Changed 18 months ago by mjo

  • Cc mjo added
  • Reviewers set to Michael Orlitzky
  • Status changed from needs_review to positive_review

At first I though this was trading one edge case for another (albeit less likely) one. It seems, however, that testing for a .hg directory is as good as it gets.

First of all, the issue is valid:

$ cd ~/tmp
tmp $ hg init
tmp $ mkdir subdir
tmp $ cd subdir
subdir $ hg verify
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
0 files, 0 changesets, 0 total revisions

Within subdir, I thought there would be an issue: we can have an .hg subdirectory that isn't Mercurial data. However, it looks like Mercurial itself ignores that fact:

subdir $ ls -a
total 8.0K
drwxr-xr-x 2 mjo mjo 4.0K 2011-12-09 15:38 .
drwxr-xr-x 4 mjo mjo 4.0K 2011-12-09 15:38 ..
subdir $ hg root
/home/mjo/tmp
subdir $ mkdir .hg
subdir $ hg root
/home/mjo/tmp/subdir

Moreover, hg verify and the like work with just an empty .hg directory. So, we don't gain anything by doing both tests.

comment:3 Changed 18 months ago by jdemeyer

  • Status changed from positive_review to closed
  • Resolution set to fixed
  • Merged in set to sage-4.8.alpha4
Note: See TracTickets for help on using tickets.