Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8125275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:45:51+00:00 2026-06-06T06:45:51+00:00

BRIEF: hg clone creates path default in /.hg/hgrc, set to where you cloned from.

  • 0

BRIEF:

hg clone creates path “default” in /.hg/hgrc, set to where you cloned from.

Q: is it possible to disable this automatically?

DETAIL:

This is already partially answered.

In Can you prevent default-push, but allow pull? we see how to set default-push, in some hgrc file such as /.hg/hgrc, or (my preference), in ~/.hgrc

In Is hg clone equivalent to hg (init→pull)
Tim Henigan says that hg clone = init; pull; hg update default; setting up default path in /.hg/hgrc.

Although elsewhere we see that this is not quite true. hg clone may differ, e.g., in that it does hard link sharing. Lacking an official statement of equivalence…

Now, disabling default-push helps a lot.

But… I have fallen into the habit of doing “hg push default”. Which somewhat defaets the p;urpose.

By the way: reason I am doing this, wanting to disable the default: workflow that goes master->workspace->staging_area->master. I do many clones of the master. Modifying /.hg/hgrc to edit [path] default each time I do a cline is a pain. Doing “hg push” or “hg push default” in any of the workspaces can be bad. Instead I need to push to the staging area, ad only from the staging area am I allowed to push to the master.

(I have tried master<->staging_area<->workspace, i.e. always cloning from the sdtaging area. But I found this confusing. Plus, the part that I haven’t said yet: my project makes me delete or collapse history, which adds an additional level of confusion and error-prone-ness.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T06:45:52+00:00Added an answer on June 6, 2026 at 6:45 am

    Here’s the post-clone hook I came up with:

     [hooks]
     post-clone = perl ~/bin/delete-default-from-.hgrc "$HG_PATS"
    

    and the perl script is below.

    I’d still like to find a one-liner.

    #!/usr/local/bin/perl
    use strict;
    
    print "editing <repo>/.hg/hgrc to to remove [paths] / default";
    
    # Hand tested
    # cd ~/mips/uarch-perf-sim/psim+stuff/f; rm -rf k; hg clone ../m k
    # cd ~/mips/uarch-perf-sim/psim+stuff/f; rm -rf k; hg clone ../m
    
    my $debug = 0;
    
    
    my $hg_pats = $ARGV[0];
    die "Usage: delete-default-from-.hgrc HG_PATS (from post-clone hook)\n" if !exists $ARGV[0] || exists $ARGV[2];
    
    
    # expect HG_PATS from post-clone hook
    
    #['../m']
    #['../m', 'target']"
    #['../m', '../target']"
    
    my $from;
    my $target;
    
    if( $hg_pats =~ m/^\['([^']+)'\]$/ ) {
        $from = $1;
        $target = $from;
        # delete paths if target implicit
        $target =~ s{.*/}{};
        print "from-only: $target\n" if $debug;
    } elsif( $hg_pats =~ m/^\['([^']+)',\s+'([^']+)'\]$/ ) {
        $from = $1;
        $target = $2;
        # do NOT delete paths if target explicit
        print "from to: $target\n" if $debug;
    } else {
        die "expected HG_PATS, got: $hg_pats\n";
    }
    
    die "clone target not found: $target\n" if ! -d $target;
    
    my $hgrc = "$target/.hg/hgrc";
    die "clone target/.hg/hgrc not found: $hgrc\n" if ! -r "$hgrc";
    
    open( my $in, "<$hgrc" ) || die "could not open $hgrc to read (edit)\n";
    unlink "$hgrc.tmp";
    open( my $out, ">$hgrc.tmp" ) || die "could not open $hgrc.tmp to write\n";
    
    my $section = '';
    my $paths_found;
    my $paths_default_found;
    while( my $line = <$in> ) {
        chomp($line);
        print "line = $line\n" if $debug;
    
        if( $line =~ m/^\[paths\]/ ) {
        $section = "[paths]";
            $paths_found++;
        }
        elsif( $line =~ m/^\[/ ) {
        $section = $line;
        }
        elsif( ($section eq "[paths]") and ($line =~ m/^\s*default\s*=/) ) {
        $line =~ s/default/default-cloned-from/;
            $paths_default_found++;
        }
        print $out $line."\n";
    }
    
    die "[paths] section not found in $hgrc" if ! $paths_found;
    die "[paths] / default not found in $hgrc" if ! $paths_default_found;
    
    system("echo '<diff edited $hgrc>';diff -U10 $hgrc $hgrc.tmp; echo '</diff>'");
    
    
    unlink "$hgrc.orig";
    die "could not unlink older $hgrc.orig" if -e "$hgrc.orig";
    
    rename "$hgrc","$hgrc.orig" || die "could not rename $hgrc to $hgrc.orig";
    
    rename "$hgrc.tmp","$hgrc" || die "could not rename $hgrc.tmp to $hgrc";
    
    system("echo '$hgrc:';cat $hgrc");
    
    exit(0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Brief: This is a past exam question from a Miranda exam but the syntax
Brief synopsis, this code works beautifully and does what it is supposed except with
Brief version of my question: This code crashes the compiler. pThread[0] = new boost::thread(
In brief, I need to do something like this: I have a folder with
This is homework but the lesson gives me the answer already. I'm having trouble
I will try to be as brief as possible... I have published a very
brief overview so this is in context, I have an application in java that
Brief: Does anyone know if it possible to add a custom_target in CMake that
Brief Context: Hi, I am a university student (behind proxy 10.3.100.211:8080), new to ROR,
Brief question What command can I use to make my DataSet refresh it's connection

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.