- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我使用命令(从 ~ 执行)生成了一个 diff.txt 文件:
diff -r /full/path/to/directory/A /full/path/to/directory/B > diff.txt
生成的 diff 文件看起来不错。
现在我跑(总是从~)
patch -p0 <diff.txt
或者我也试过:
patch <diff.txt
我希望它将更改应用于/full/path/to/directory/A 中的文件,以便在操作后它们将与/full/path/to/directory/B 中的文件相同
但它只说:* 在补丁输入中只发现了垃圾。
我错过了什么?
编辑:这是整个差异文件:
diff /media/DATA/lavoro/eclipse_workspace/ODK Collect/src/net/xxx/collect/android/activities/FormEntryActivity.java /media/DATA/lavoro/xxx/backups/odk src embedded maps/net/xxx/collect/android/activities/FormEntryActivity.java
21a22,27
>
> import com.google.android.maps.GeoPoint;
> import com.google.android.maps.MapActivity;
> import com.google.android.maps.MapView;
> import com.google.android.maps.MyLocationOverlay;
>
36a43
> import net.xxx.collect.android.widgets.GeoPointWidget;
50a58,60
> import android.location.Location;
> import android.location.LocationListener;
> import android.location.LocationManager;
86a97
> import java.util.List;
96,97c107,108
< public class FormEntryActivity extends Activity implements AnimationListener, FormLoaderListener,
< FormSavedListener, AdvanceToNextListener, OnGestureListener {
---
> public class FormEntryActivity extends MapActivity implements AnimationListener, FormLoaderListener,
> FormSavedListener, AdvanceToNextListener, OnGestureListener, LocationListener {
115a127,133
>
> // Release:
> private static final String GMAPS_API_KEY="0SH1_CwvF7Nn4_kT8NcGTc8vMCjrqIdpXOjSqcA";
>
> // Debug:
> //private static final String GMAPS_API_KEY="0SH1_CwvF7Nm8oPeWuNskdKCKKWZ1VlGx6mqTfg";
>
162a181,190
>
> private MapView mMapView;
> private boolean mGPSOn = false;
> private boolean mNetworkOn = false;
> private MyLocationOverlay mLocationOverlay;
> private LocationManager mLocationManager;
> private Location mLocation;
> private GeoPoint mGeoPoint;
>
> private boolean flingEnabled=true;
171a200
> Log.d(t, "onCreate "+(savedInstanceState==null?"":" with savedInstanceState"));
207a237,240
> Log.d(t, "savedInstanceState "+(newForm?"seems":"does not seem")+" to be a new form");
> }
> else {
> Log.d(t, "savedInstanceState does not have a newForm key");
223a257
> Log.d(t,"Last non configuration instance is a FormLoaderTask");
225a260
> Log.d(t,"Last non configuration instance is a SaveToDiskTask");
227a263
> Log.d(t,"Last non configuration instance is null");
228a265
> Log.d(t," and the form is not new");
298a336,360
>
>
> mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
> List<String> providers = mLocationManager.getProviders(true);
> for (String provider : providers) {
> if (provider.equalsIgnoreCase(LocationManager.GPS_PROVIDER)) {
> mGPSOn = true;
> }
> if (provider.equalsIgnoreCase(LocationManager.NETWORK_PROVIDER)) {
> mNetworkOn = true;
> }
> }
> if (!mGPSOn && !mNetworkOn) {
> Toast.makeText(getBaseContext(), getString(R.string.provider_disabled_error),
> Toast.LENGTH_SHORT).show();
> //finish();
> }
>
> }
>
> public void enableFling() {
> flingEnabled=true;
> }
> public void disableFling() {
> flingEnabled=false;
300d361
<
303a365
> Log.d(t,"onSavedInstanceState");
312a375
> Log.d(t,"onActivityResult "+requestCode+" "+resultCode+" "+intent.getAction());
457a521
> Log.d(t,"refreshCurrentView");
610a675
> Log.d(t,"onRetainNonConfigurationInstance");
612,613c677,680
< if (mFormLoaderTask != null && mFormLoaderTask.getStatus() != AsyncTask.Status.FINISHED)
< return mFormLoaderTask;
---
> if (mFormLoaderTask != null && mFormLoaderTask.getStatus() != AsyncTask.Status.FINISHED){
> Log.d(t," returning mFormLoaderTask");
>
> return mFormLoaderTask;
614a682,683
> }
>
616,618c685,689
< if (mSaveToDiskTask != null && mSaveToDiskTask.getStatus() != AsyncTask.Status.FINISHED)
< return mSaveToDiskTask;
<
---
> if (mSaveToDiskTask != null && mSaveToDiskTask.getStatus() != AsyncTask.Status.FINISHED) {
> Log.d(t," returning mSaveToDisk");
>
> return mSaveToDiskTask;
> }
620a692
> Log.d(t, " just saving answers. No need to pass mFormController");
622a695
> Log.d(t," returning null");
772c845
< private void showNextView() {
---
> public void showNextView() {
1316a1390,1391
> mLocationManager.removeUpdates(this);
> if (mLocationOverlay!=null) mLocationOverlay.disableMyLocation();
1322a1398
> Log.d(t,"nResume");
1323a1400,1407
> if (mLocationOverlay!=null) mLocationOverlay.enableMyLocation();
> if (mGPSOn) {
> mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
> }
> if (mNetworkOn) {
> mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
> }
>
1337a1422,1426
>
>
>
>
>
1367a1457,1477
> Log.d(t,"---- onDestroy ----");
> boolean problem=false;
> if (mFormLoaderTask != null && mFormLoaderTask.getStatus() != AsyncTask.Status.FINISHED){
> Log.d(t," I wish I could retain mFormLoaderTask");
> problem=true;
> }
> else if (mSaveToDiskTask != null && mSaveToDiskTask.getStatus() != AsyncTask.Status.FINISHED) {
> Log.d(t," I wish I could retain mSaveToDisk");
> problem=true;
> }
> else if (mFormController != null && currentPromptIsQuestion()) {
> Log.d(t, " I wish I had the opportunity to save answers");
> problem=true;
> }
>
> if (!problem) Log.d(t," everything seems ok");
>
>
>
>
>
1369c1479
< mFormLoaderTask.setFormLoaderListener(null);
---
> mFormLoaderTask.setFormLoaderListener(null);
1373a1484
> Log.d(t," Cancelling and destroying form loader task");
1376a1488,1489
> else Log.d(t," Not cancelling form loader task because it's not done");
>
1382a1496
> Log.d(t," Cancelling save to disk task");
1394a1509,1512
> if (mCurrentView!=null && mCurrentView instanceof ODKView)
> for (QuestionWidget qw : ((ODKView) mCurrentView).getWidgets()) {
> qw.onInAnimationDone();
> }
1607c1725,1726
< if (Math.abs(e1.getX() - e2.getX()) > 60 && Math.abs(e1.getY() - e2.getY()) < 60) {
---
> if (!flingEnabled) return false;
> if (Math.abs(e1.getX() - e2.getX()) > 60 && Math.abs(e1.getY() - e2.getY()) < 60) {
1631c1750
< // We don't wnat that, so cancel it.
---
> // We don't want that, so cancel it.
1645a1765,1842
>
>
> @Override
> protected boolean isRouteDisplayed() {
> // TODO Auto-generated method stub
> return false;
> }
>
> public MapView getMapView() {
> if (mMapView==null) {
> Log.d("FormEntryActivity", "Creating MapView");
> mMapView=new MapView(this, GMAPS_API_KEY);
> mMapView.setBuiltInZoomControls(true);
> mMapView.setSatellite(false);
> mMapView.getController().setZoom(16);
> createLocationOverlay();
> }
> return mMapView;
> }
> public MyLocationOverlay getLocationOverlay() {
> return mLocationOverlay;
> }
>
> public void createLocationOverlay() {
> Log.d("FormEntryActivity", "createLocationOverlay");
> mLocationOverlay=new MyLocationOverlay(this,mMapView);
> mMapView.getOverlays().add(mLocationOverlay);
> mLocationOverlay.enableMyLocation();
> }
>
>
> @Override
> public void onLocationChanged(Location location) {
> if (true) {
> Log.d("FormEntryActivity", "onLocationChanged");
> mLocation = location;
> if (mLocation != null) {
>
> mGeoPoint =
> new GeoPoint((int) (mLocation.getLatitude() * 1E6),
> (int) (mLocation.getLongitude() * 1E6));
> if (mCurrentView!=null && mCurrentView instanceof ODKView)
> for (QuestionWidget qw : ((ODKView) mCurrentView).getWidgets()) {
> if (qw instanceof GeoPointWidget) {
> ((GeoPointWidget)qw).onLocationChanged();
> }
> }
>
> }
> }
> }
> public GeoPoint getGeoPoint() {
> return mGeoPoint;
> }
> public Location getLocation() {
> return mLocation;
> }
>
>
> @Override
> public void onProviderDisabled(String provider) {
> // TODO Auto-generated method stub
>
> }
>
>
> @Override
> public void onProviderEnabled(String provider) {
> // TODO Auto-generated method stub
>
> }
>
>
> @Override
> public void onStatusChanged(String provider, int status, Bundle extras) {
> // TODO Auto-generated method stub
>
> }
diff -r /media/DATA/lavoro/eclipse_workspace/ODK Collect/src/net/xxx/collect/android/widgets/GeoPointWidget.java /media/DATA/lavoro/xxx/backups/odk src embedded maps/net/xxx/collect/android/widgets/GeoPointWidget.java
19a20,24
>
> import com.google.android.maps.GeoPoint;
> import com.google.android.maps.MapView;
> import com.google.android.maps.Overlay;
>
27a33
> import android.location.Location;
31a38
> import android.view.ViewGroup;
34a42
> import android.widget.RelativeLayout;
37a46
> import java.util.List;
47a57
> private Button mAcceptButton;
55c65,73
<
---
>
> private MapView mMapView;
> private FormEntryActivity mFEA;
> private TextView mLocationStatus;
>
> private RelativeLayout mMapContainerLayout;
>
> private LinearLayout.LayoutParams lp;
> RelativeLayout.LayoutParams rlp;
59c77,79
<
---
>
>
>
113c133
< if (mAppearance != null && mAppearance.equalsIgnoreCase("maps")) {
---
> if (mAppearance == null || mAppearance.equalsIgnoreCase("maps")) {
133,141c153
< Intent i = null;
< if (mUseMaps) {
< i = new Intent(getContext(), GeoPointMapActivity.class);
< } else {
< i = new Intent(getContext(), GeoPointActivity.class);
< }
< ((Activity) getContext()).startActivityForResult(i,
< FormEntryActivity.LOCATION_CAPTURE);
< mWaitingForData = true;
---
> launchMap();
148,149c160,186
<
< addView(mGetLocationButton);
---
> mFEA=(FormEntryActivity)context;
> //addView(mGetLocationButton);
> Log.d("GeoPointWidget","Adding ViewMap in constructor");
>
> setUpMapContainer();
> }
>
> protected void setUpMapContainer() {
> lp=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
> lp.setMargins(0, 0, 0, 0);
>
> rlp=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
> rlp.setMargins(0, 0, 0, 0);
>
> mMapContainerLayout=new RelativeLayout(mFEA);
> mMapContainerLayout.setLayoutParams(lp);
>
> this.addView(mMapContainerLayout);
> }
>
> @Override
> protected void addQuestionText(FormEntryPrompt p) {
> return;
> }
>
> private void launchMap() {
> Intent i = null;
151c188,190
< addView(mViewButton);
---
> i = new Intent(getContext(), GeoPointMapActivity.class);
> } else {
> i = new Intent(getContext(), GeoPointActivity.class);
153c192,270
< addView(mAnswerDisplay);
---
> ((Activity) getContext()).startActivityForResult(i,
> FormEntryActivity.LOCATION_CAPTURE);
> mWaitingForData = true;
> }
> @Override
> public void onInAnimationDone() {
> addMapView();
> }
>
> protected void addMapView() {
> if (mUseMaps) {
> //addView(mViewButton);
> mMapView=(mFEA).getMapView();
> if (mMapView.getParent()!=null) {
> ((ViewGroup)(mMapView.getParent())).removeView(mMapView);
>
> }
>
> mMapView.setLayoutParams(rlp);
> mMapContainerLayout.addView(mMapView);
>
> View mapButtons=View.inflate(mFEA, R.layout.map_buttons_layout, null);
> mMapContainerLayout.addView(mapButtons);
>
> mLocationStatus=(TextView)findViewById(R.id.location_status);
>
>
>
> /*
> this.setLayoutParams(lp);
> LinearLayout p=this;
> while (p!=null) {
> if (p.getParent()!=null && p.getParent() instanceof LinearLayout) {
> p.setLayoutParams(lp);
> p.invalidate();
> p=(LinearLayout)(p.getParent());
>
> }
> else {
> break;
> }
> }
> if (p.getParent()!=null && p.getParent() instanceof RelativeLayout) {
> RelativeLayout r=(RelativeLayout)(p.getParent());
> RelativeLayout.LayoutParams lpr=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
> lpr.setMargins(0,0,0,0);
> p.setLayoutParams(lpr);
> r.invalidate();
> }
> */
> mMapView.setClickable(true);
> mMapView.setBuiltInZoomControls(true);
> mMapView.displayZoomControls(false);
> mMapView.setSatellite(false);
> mMapView.getController().setZoom(24);
> List<Overlay> overlays=mMapView.getOverlays();
> if (overlays.size()==0) {
> Log.d("GeoPointWidget","Creating Location Overlay (from constructor)");
> mFEA.createLocationOverlay();
> }
> mMapView.invalidate();
>
> mAcceptButton=(Button)findViewById(R.id.accept_location);
> //mAcceptButton.setEnabled(false);
> mAcceptButton.setText(R.string.cancel_location);
> mAcceptButton.setOnClickListener(new View.OnClickListener() {
> @Override
> public void onClick(View v) {
> acceptOrSkip();
> }
> });
>
>
> if (mFEA.getGeoPoint()!=null) onLocationChanged();
>
> mFEA.disableFling();
> }
> //addView(mAnswerDisplay);
>
155d271
<
163a280,284
>
> private void acceptOrSkip() {
> mFEA.enableFling();
> mFEA.showNextView();
> }
269a391,414
> }
> private String truncateFloat(float f) {
> return new DecimalFormat("#.##").format(f);
> }
> public void onLocationChanged() {
> //We need the mLocationStatus text view
> if (mMapView==null) return;
> if (mLocationStatus!=null)
> mLocationStatus.setText(getContext().getString(R.string.location_provider_accuracy,
> mFEA.getLocation().getProvider(), truncateFloat(mFEA.getLocation().getAccuracy())));
> if (mAcceptButton!=null) mAcceptButton.setText(R.string.accept_location);
> Log.d("GeoPointWidget","onLocationChanged. Overlays: "+(mMapView.getOverlays().size()));
> GeoPoint gp=mFEA.getGeoPoint();
> if (gp!=null) mMapView.getController().animateTo(mFEA.getGeoPoint());
> List<Overlay> overlays=mMapView.getOverlays();
> if (overlays.size()==0) {
> Log.d("GeoPointWidget","Creating Location Overlay");
> mFEA.createLocationOverlay();
> }
> Location location=mFEA.getLocation();
> if (location!=null) {
> setBinaryData(location.getLatitude() + " " + location.getLongitude() + " "
> + location.getAltitude() + " " + location.getAccuracy(), false);
> }
diff -r /media/DATA/lavoro/eclipse_workspace/ODK Collect/src/net/xxx/collect/android/widgets/ImageWidget.java /media/DATA/lavoro/xxx/backups/odk src embedded maps/net/xxx/collect/android/widgets/ImageWidget.java
330c330,335
< if (mBinaryName==null) {
---
>
> }
>
> @Override
> public void onInAnimationDone() {
> if (mBinaryName==null) {
diff -r /media/DATA/lavoro/eclipse_workspace/ODK Collect/src/net/xxx/collect/android/widgets/QuestionWidget.java /media/DATA/lavoro/xxx/backups/odk src embedded maps/net/xxx/collect/android/widgets/QuestionWidget.java
147a148,151
>
> public void onInAnimationDone() {
>
> }
最佳答案
使用“diff -ruN path1 path2”生成差异,使用“patch -p{N} < patchfile”应用补丁,其中 N 确定要从差异中的文件中剥离的路径前缀。只需查看补丁并分析“差异”行,看看应该去掉什么。 (参见:man patch)。在应用补丁之前,请务必使用“patch --dry-run -p0 < patchfile”来确保一切都至少是合理的。
编辑:注意使用普通 diff
、统一 diff (-u
) 和上下文 diff (-c
),你会看到文件名根本不包含在“正常”差异中。 “diff”命令在那里,但没有要修补的文件名。 (另请注意,实际的“diff”输出因平台和程序而异,patch
必须进行一些插值以确定补丁格式,甚至尝试猜测如果你给了它错误的选项)。
$ diff -r -u a b
diff -r -u a/dir/file1 b/dir/file1
--- a/dir/file1 2012-08-02 18:27:30.050247358 -0700
+++ b/dir/file1 2012-08-02 18:27:27.190198620 -0700
@@ -1 +1 @@
-contents A
+contents B
$ diff -r -c a b
diff -r -c a/dir/file1 b/dir/file1
*** a/dir/file1 2012-08-02 18:27:30.050247358 -0700
--- b/dir/file1 2012-08-02 18:27:27.190198620 -0700
***************
*** 1 ****
! contents A
--- 1 ----
! contents B
$ diff -r a b
diff -r a/dir/file1 b/dir/file1
1c1
< contents A
---
> contents B
关于ubuntu - 补丁:补丁输入中只发现垃圾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11531693/
我正在尝试在站点列表中添加站点名称,以便在 publish:end:remote 上清除 HTML 缓存事件。 mysite 但是,它没有按预期工
我正在尝试使用不同目录中的多个文件制作补丁。我不想包含所有未提交的文件,因为我有很多不适用于补丁。 我知道这个命令可以使用特定文件创建补丁,唯一的问题是这是一个文件: svn diff -up ori
我经常使用 gnu-utils 补丁和差异。使用 git,我经常这样做: git diff 通常简单的更改会创建一个大补丁,因为唯一的更改是,例如,添加一个 if/else 循环,并且里面的所有内容都
我使用命令(从 ~ 执行)生成了一个 diff.txt 文件: diff -r /full/path/to/directory/A /full/path/to/directory/B > diff.t
我正在编写一个项目,我需要通过网络传输一组相似的图像。为了加快速度,我考虑过做大多数电影编解码器所做的事情。有关键帧,然后发送更改。 现在,我得到的是一组 BufferedImage,因此类似于文本文
我正在尝试将更改拆分为多个提交,但在手动编辑大块时我遇到了问题。 原始大块头: @@ -116,8 +116,8 @@ context context -
我想自动测试一组仍然干净利落地适用于(更新的)代码库的补丁。为此,我打算运行 patch -p 1 a echo b > b diff -Nu a b > p rm a b patch -p 1 <
我已经从一个模块中导入了一个类,但是当我尝试在没有模块作为前缀的情况下修补类名时,我得到一个类型错误: TypeError: Need a valid target to patch. You sup
最近我从 SVN 迁移到 git,我的团队已经开始在新的 git 存储库中工作。 后来我发现了一些转换问题,并从 SVN 制作了第二个 git repo,并进行了一些修复和历史重写。 现在我有了 SV
我正在尝试为我的应用程序创建一个补丁。实现描述的示例 here按预期工作。但是,每个版本的文件都存储在单独的目录中。 1.0 版文件在 c:sample\1.0 中,1.1 版文件在 c:sample
首先请原谅我的长文,但我会尽量详细。 我正在为一个开源项目 (DSpace) 进行开发。我没有对他们的 SVN 存储库的提交权限,所以我查看了源代码并一直使用 git 来管理我的版本控制。 在我的开发
有没有办法自动 merge (interdiff)2 个头分支和 1 个基分支之间的冲突? 我试图在补丁级别做这件事 版本A是我的基础 VersionB 是 VersionA 的分支 VersionB
我正在尝试申请 this修补到 MinGW 上的 GCC 以获取它 to compile GDC 2 ,但我不知道如何。 (我对 GCC 的内部结构还很陌生,甚至对一般的 *nix 工具也很陌生。)我
我对软件开发很陌生,所以这无疑是一个非常基本的问题。我得到了一个开源项目的 mercurial repo。我复制了它并做了一些工作。 promise 。工作更多,然后进行了第二次提交。所以我的树看起来
我想对这个错误 ( http://code.djangoproject.com/ticket/13095 ) 应用补丁,但我以前从未做过,也不知道从哪里开始。谁能给我指点教程? 最佳答案 在 Linu
我前段时间使用 p4 diff 生成了一个补丁。命令。 然而,现在我想应用它,我意识到没有办法在 Perforce 中应用补丁。 由于我没有使用 -du选项,补丁是那种晦涩难懂的 perforce 格
我可以使用 NSIS 的 Vpatch 生成从一个版本到另一个版本的补丁文件。假设我有 mydll.dll 版本 1,我有一个补丁可以将它更新到版本 2。然后我又有了一个新版本,因此我生成了另一个补丁
我有一个补丁,用 hg export 42 制作在另一个存储库中,修改文件 asd/fgh/foo/bar.c asd/fgh/foo/fish.h boo/hoo.txt 我需要将此补丁导入具有如下
我们有一个相当大的库,我们需要定期将其导入(然后修补)到我们的代码库中。 SVN Book 似乎推荐了一个“vendor branch”方案,我们保留了“vendor drops”的补丁版本。这会起作
我正在家里用 tensorflow 玩卷积神经网络(顺便说一句,我已经完成了 udacity 深度学习类(class),所以我有理论基础)。 运行卷积时,patch 的大小会产生什么影响?当图像变大/
我是一名优秀的程序员,十分优秀!