Opened 7 years ago

Closed 7 years ago

#12128 closed defect (fixed)

"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 Merged in: sage-4.8.alpha4
Authors: Jeroen Demeyer Reviewers: Michael Orlitzky
Report Upstream: N/A Work issues:
Branch: Commit:
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 (1)

12128_root_hg_verify.patch (752 bytes) - added by jdemeyer 7 years ago.

Download all attachments as: .zip

Change History (4)

Changed 7 years ago by jdemeyer

comment:1 Changed 7 years ago by jdemeyer

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

comment:2 Changed 7 years 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 7 years ago by jdemeyer

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