On Thu, Mar 21, 2013 at 01:59:07PM +0800, Paul Wise wrote:

> Unfortunately there is a lot of variation in the clean commands of
> various VCSes, so it would need to handle that. Some commands take extra
> arguments for cleaning only subtrees etc. Maybe something like this:
> 
> clean = if [ $1 = -f ] ; then shift; $vcs_clean_act "$@"; else 
> $vcs_clean_noact "$@"; fi
> git_clean_noact = git clean -dx --dry-run "$@"
> git_clean_act = git clean -dx --force "$@"

I wasn't able to figure out how to make the above work so I implemented
it another way, patch attached. If you can figure out how to implement
it more cleanly using my suggestion above that would be great.

-- 
bye,
pabs

https://wiki.debian.org/PaulWise

From 0f2b412081e3f9ad0630c7424620f6be025e274c Mon Sep 17 00:00:00 2001
From: Paul Wise <[email protected]>
Date: Sun, 10 Mar 2013 14:21:03 +0800
Subject: [PATCH] Add a clean command that works like git clean -dxn with -f to
 delete option.

---
 debian/control |  2 +-
 mr             | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+), 1 deletion(-)

diff --git a/debian/control b/debian/control
index 2518539..64c5f26 100644
--- a/debian/control
+++ b/debian/control
@@ -11,7 +11,7 @@ Package: myrepos
 Architecture: all
 Section: vcs
 Depends: ${misc:Depends}
-Suggests: subversion, git-core | git (>= 1:1.7), cvs, bzr, mercurial, darcs, fossil, vcsh, liburi-perl, curl, ack-grep
+Suggests: subversion, subversion-tools, git-core | git (>= 1:1.7), cvs, kdesdk-scripts, bzr, mercurial, darcs, fossil, vcsh, liburi-perl, curl, ack-grep
 Provides: mr
 Replaces: mr
 Recommends: libwww-perl, libhtml-parser-perl, libio-pty-easy-perl, perl
diff --git a/mr b/mr
index 18e8761..7319f98 100755
--- a/mr
+++ b/mr
@@ -12,6 +12,8 @@ B<mr> [options] update
 
 B<mr> [options] status
 
+B<mr> [options] clean [-f]
+
 B<mr> [options] commit [-m "message"]
 
 B<mr> [options] record [-m "message"]
@@ -80,6 +82,12 @@ Displays a status report for each repository, showing what
 uncommitted changes are present in the repository. For distributed version
 control systems, also shows unpushed local branches.
 
+=item clean
+
+Print ignored files, untracked files and other cruft in the working directory.
+
+The optional -f parameter allows removing the files as well as printing them.
+
 =item commit (or ci)
 
 Commits changes to each repository. (By default, changes are pushed to the
@@ -2012,6 +2020,64 @@ git_svn_fetch = git svn fetch
 darcs_fetch = darcs fetch
 hg_fetch = hg pull
 
+svn_clean = 
+	if [ "x$1" = x-f ] ; then
+		shift
+		svn-clean "$@"
+	else
+		svn-clean --print "$@"
+	fi
+git_clean = 
+	if [ "x$1" = x-f ] ; then
+		shift
+		git clean -dx --force "$@"
+	else
+		git clean -dx --dry-run "$@"
+	fi
+git_svn_clean = 
+	if [ "x$1" = x-f ] ; then
+		shift
+		git clean -dx --force "$@"
+	else
+		git clean -dx --dry-run "$@"
+	fi
+bzr_clean = 
+	if [ "x$1" = x-f ] ; then
+		shift
+		bzr clean-tree --verbose --force --ignored --unknown --detritus "$@"
+	else
+		bzr clean-tree --verbose --dry-run --ignored --unknown --detritus "$@"
+	fi
+cvs_clean = 
+        if [ "x$1" = x-f ] ; then
+		shift
+		cvs-clean "$@"
+	else
+		cvs-clean --dry-run "$@"
+	fi
+hg_clean = 
+	if [ "x$1" = x-f ] ; then
+		shift
+		hg purge --print --all "$@"
+		hg purge --all "$@"
+	else
+		hg purge --print --all "$@"
+	fi
+fossil_clean = 
+	if [ "x$1" = x-f ] ; then
+		shift
+		fossil clean --dry-run --dotfiles --emptydirs "$@"
+	else
+		fossil clean --force --dotfiles --emptydirs "$@"
+	fi
+vcsh_commit = 
+	if [ "x$1" = x-f ] ; then
+		shift
+		vcsh run "$MR_REPO" git clean -dx "$@"
+	else
+		vcsh run "$MR_REPO" git clean -dx --dry-run "$@"
+	fi
+
 svn_status = svn status "$@"
 git_status = git status -s "$@" || true; git --no-pager log --branches --not --remotes --simplify-by-decoration --decorate --oneline || true
 bzr_status = bzr status --short "$@"; bzr missing
-- 
2.1.0

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to