Mercurial: Getting changed files from revision?

I can’t get my head around how I can get only the files that were changed in my last revision, and not the complete repo, which i get by using Clone. This would be super helpful to for instance, deploy the last changed files.

What do I do?

  • Remove experimental branch
  • Mercurial Hg-Git: Clone from a local directory?
  • Mercurial: “abandoned transaction found - run hg recover”. Recover does not work
  • Can I use Subversion for a multi gigabyte data set?
  • How to obtain the folder where the Pipeline Jenkinsfile is checked out (Jenkins)
  • Using mercurial and beyond compare 3(bc3) as the diff tool? help needed
  • Thanks

  • How to automate version code incrementing in AndroidManifest?
  • How do I do a 'git status' so it doesn't display untracked files without using .gitignore?
  • Svn or Git client (or plugin) to find missing or broken files
  • Using git version control for PHP development
  • Handling outdated dependencies in Gerrit
  • Pushing without a commit in Mercurial or Git
  • 3 Solutions collect form web for “Mercurial: Getting changed files from revision?”

    Martin has the right way to get a list of what files have changed in a revision, and I’ve upvoted his answer, but just to expand on why your question is a little off:

    In Mercurial every location has a full copy with all changes. If you’re going to use Mercurial to deploy to your server then you have to clone everything to your server — once. After that push/pull will move over only the (compressed) changesets that the server doesn’t already have.

    If you don’t want to have everything that ever was on the server, then you need to use something other than mercurial for your deployment, perhaps something fed from the status commands Martin showed or a snapshot created from hg archive.

    Personally, I’m okay with having full history on my servers, and just do a hg pull ; hg update on the server for each new deployment. It’s tidy and efficient.

    You cannot transfer just some files — you must always have a full clone locally. So I suggest you make that once and then pull in changes incrementally.

    You should then use hg status to show the names of files changes been revisions. You normally use hg status to see which files are changes compared to the working copy parent revision, but you can pass --rev to status to see changes between any two revisions!

    So use

    $ hg status --change tip
    

    to see which files were changed in the tip changeset. Use

     $ hg pull
     $ hg status --rev .:tip
    

    to see what files will be changed when you do a hg update after a pull. The update will take you from the current working directory parent, denoted by ., to the tip, assuming you are on the same named branch as tip. Otherwise hg update will take you to the tip-most changeset on your current branch.

    You can use a template to hg log or hg tip to get all filenames:

    hg tip --template '{files}'
    

    or to get e.g. all files changed/added/modified by changeset 5:

     hg log -r5  --template '{files}'
    

    You can read more about templates Mercurial: The Definitive Guide, Chapter 11. Customizing the output of Mercurial or short help with hg help templating`

    If you want to do something to the files e.g grep through them:

    hg tip --template '{files}' | xargs grep foo  
    

    Careful this will break with filenames containing spaces!

    To process all kinds of filenames something more complicated is needed (thanks to mg on #mercurial for the tip):

    We need multiline styles for this suppose a file named zerosep contains:

    changeset = "{files}"
    file = "{file}\0"
    

    Then you can use this to produce a \0 separated list of filenames and process it with xargs -0:

    hg tip --style zerosep | xargs -0 grep foo
    

    Information how this works can be found in: Listing files on multiple lines

    Git Baby is a git and github fan, let's start git clone.